Inventory Refactoring
Massively refactored everything related to entity inventory management We are no longer recalculating mass by iterating over the entire inventory any time anything changes, for example Gear is explicitly associated with hardpoints in the entity code This did introduce some bugs, will clean those up tomorrow
This commit is contained in:
parent
b0d7fa4904
commit
43f33546a3
22 changed files with 689 additions and 670 deletions
|
|
@ -54,15 +54,17 @@ public class StatModifier : IBehavior, IInitializableBehavior, IDisposableBehavi
|
|||
if (statField != null)
|
||||
{
|
||||
if (typeof(EquippableItemData).IsAssignableFrom(targetType))
|
||||
_stats = Entity.EquippedItems.Append(Entity.Hull)
|
||||
.Select(id => Context.Cache.Get<Gear>(id))
|
||||
_stats = Entity.Hardpoints
|
||||
.Select(hp => hp.Gear)
|
||||
.Where(gear => gear != null)
|
||||
.Where(gear => _data.RequireBehavior == null || gear.ItemData.Behaviors.Any(behavior => behavior.GetType() == _data.RequireBehavior))
|
||||
.Where(gear => gear.ItemData.GetType() == targetType)
|
||||
.Select(gear => statField.GetValue(gear.ItemData) as PerformanceStat)
|
||||
.ToArray();
|
||||
else
|
||||
_stats = Entity.EquippedItems.Append(Entity.Hull)
|
||||
.Select(id => Context.Cache.Get<Gear>(id))
|
||||
_stats = Entity.Hardpoints
|
||||
.Select(hp => hp.Gear)
|
||||
.Where(gear => gear != null)
|
||||
.Where(gear => _data.RequireBehavior == null || gear.ItemData.Behaviors.Any(behavior => behavior.GetType() == _data.RequireBehavior))
|
||||
.SelectMany(gear => gear.ItemData.Behaviors)
|
||||
.Where(behaviorData => behaviorData.GetType() == targetType)
|
||||
|
|
|
|||
Loading…
Reference in a new issue