wave behavior and fixed explosion
This commit is contained in:
86
managers/Inventory/InventoryManager.cs
Normal file
86
managers/Inventory/InventoryManager.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Sync.Primitives;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.managers;
|
||||
|
||||
|
||||
[GlobalClass, Meta(typeof(IAutoNode))]
|
||||
public partial class InventoryManager : Node, IDisposable
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
private AutoSet<ForgeAbilityBehavior> _startedFlyingAbilities = new();
|
||||
private AutoSet<ForgeAbilityBehavior> _flyingTickAbilities = new();
|
||||
private AutoSet<ForgeAbilityBehavior> _stoppedFlyingAbilities = new();
|
||||
|
||||
private AutoSet<ForgeAbilityBehavior> _startedPlantedAbilities = new();
|
||||
private AutoSet<ForgeAbilityBehavior> _plantedTickAbilities = new();
|
||||
private AutoSet<ForgeAbilityBehavior> _stoppedPlantedAbilities = new();
|
||||
|
||||
public IAutoSet<ForgeAbilityBehavior> StartedFlyingAbilities => _startedFlyingAbilities;
|
||||
public IAutoSet<ForgeAbilityBehavior> FlyingTickAbilities => _flyingTickAbilities;
|
||||
public IAutoSet<ForgeAbilityBehavior> StoppedFlyingAbilities => _stoppedFlyingAbilities;
|
||||
|
||||
public IAutoSet<ForgeAbilityBehavior> StartedPlantedAbilities => _startedPlantedAbilities;
|
||||
public IAutoSet<ForgeAbilityBehavior> PlantedTickAbilities => _plantedTickAbilities;
|
||||
public IAutoSet<ForgeAbilityBehavior> StoppedPlantedAbilities => _stoppedPlantedAbilities;
|
||||
|
||||
private readonly AutoMap<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>> _weaponEventsInventory = new();
|
||||
public IAutoMap<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>> WeaponEventsInventory => _weaponEventsInventory;
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
_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 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);
|
||||
|
||||
_startedFlyingAbilities.Dispose();
|
||||
_stoppedFlyingAbilities.Dispose();
|
||||
_flyingTickAbilities.Dispose();
|
||||
_startedPlantedAbilities.Dispose();
|
||||
_stoppedPlantedAbilities.Dispose();
|
||||
_plantedTickAbilities.Dispose();
|
||||
|
||||
_weaponEventsInventory.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var inventoryForEvent = _weaponEventsInventory[forEvent];
|
||||
inventoryForEvent.Add(abilityBehavior);
|
||||
}
|
||||
|
||||
public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var inventoryForEvent = _weaponEventsInventory[forEvent];
|
||||
inventoryForEvent.Remove(abilityBehavior);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user