fixed a few issues
This commit is contained in:
@@ -33,44 +33,39 @@ public partial class InventoryManager : Node, IDisposable
|
||||
|
||||
private readonly AutoMap<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>> _weaponEventsInventory = new();
|
||||
public IAutoMap<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>> WeaponEventsInventory => _weaponEventsInventory;
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>> GetEventElements()
|
||||
{
|
||||
return new Dictionary<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, _startedFlyingAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, _stoppedFlyingAbilities},
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, _flyingTickAbilities },
|
||||
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, _startedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, _stoppedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, _plantedTickAbilities },
|
||||
};
|
||||
}
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
foreach (var (forEvent, behaviorSet) in GetEventElements())
|
||||
{
|
||||
_weaponEventsInventory[forEvent] = behaviorSet;
|
||||
}
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = _startedFlyingAbilities;
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = _stoppedFlyingAbilities;
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = _flyingTickAbilities;
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.StartedPlanted] = _startedPlantedAbilities;
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.StoppedPlanted] = _stoppedPlantedAbilities;
|
||||
_weaponEventsInventory[WeaponSystem.WeaponEvent.PlantedTick] = _plantedTickAbilities;
|
||||
}
|
||||
|
||||
public void InitializeFromResource(WeaponInventory inventory)
|
||||
{
|
||||
var elements = GetEventElements();
|
||||
foreach (var forEvent in elements.Keys)
|
||||
{
|
||||
elements[forEvent] = new AutoSet<ForgeAbilityBehavior>(inventory.EventMap[forEvent]);
|
||||
}
|
||||
var eventMap = inventory.GetEventAbilitiesMap();
|
||||
_startedFlyingAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.StartedFlying]);
|
||||
_stoppedFlyingAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.StoppedFlying]);
|
||||
_flyingTickAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.FlyingTick]);
|
||||
|
||||
_startedPlantedAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.StartedPlanted]);
|
||||
_stoppedPlantedAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.StoppedPlanted]);
|
||||
_plantedTickAbilities = new AutoSet<ForgeAbilityBehavior>(eventMap[WeaponSystem.WeaponEvent.PlantedTick]);
|
||||
}
|
||||
|
||||
public new void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
foreach (var element in GetEventElements().Values)
|
||||
element.Dispose();
|
||||
_startedFlyingAbilities.Dispose();
|
||||
_stoppedFlyingAbilities.Dispose();
|
||||
_flyingTickAbilities.Dispose();
|
||||
_startedPlantedAbilities.Dispose();
|
||||
_stoppedPlantedAbilities.Dispose();
|
||||
_plantedTickAbilities.Dispose();
|
||||
|
||||
_weaponEventsInventory.Dispose();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user