ashblue / unity-elastic-inventory

An easy to use Unity inventory framework built with scaling and extendability in mind
MIT License
45 stars 2 forks source link

GetAll with casting fails in some cases #20

Open ashblue opened 5 months ago

ashblue commented 5 months ago

When calling GetAll<T> with an item entry type (line 180). The cast will fail if you're using a custom item entry type and a custom item entry type that forks the base item entry. A LINQ cast is being made and it needs to be converted to a cast type that takes into account potential failure of the conversion.

// Add the items
inventory.Add(generic default item)
inventory.Add(new custom item entry)

// This now fails
var myCustomEntries = inventory.GetAll<MyCustomItemEntry>();