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; public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior ability) : RefCounted { public WeaponSystem.WeaponEvent ForEvent { get; private set; } = forEvent; public ForgeAbilityBehavior Ability { get; private set; } = ability; } [GlobalClass, Meta(typeof(IAutoNode))] public partial class InventoryManager : Node, IDisposable { public override void _Notification(int what) => this.Notify(what); #region Signals [Signal] public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data); [Signal] public delegate void WeaponEventAbilityRemovedEventHandler(WeaponEventAbilityData data); #endregion private AutoSet _startedFlyingAbilities = new(); private AutoSet _flyingTickAbilities = new(); private AutoSet _stoppedFlyingAbilities = new(); public IAutoSet StartedFlyingAbilities => _startedFlyingAbilities; public IAutoSet FlyingTickAbilities => _flyingTickAbilities; public IAutoSet StoppedFlyingAbilities => _stoppedFlyingAbilities; private readonly AutoMap> _weaponEventsInventory = new(); public IAutoMap> WeaponEventsInventory => _weaponEventsInventory; public void OnReady() { _weaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = _startedFlyingAbilities; _weaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = _flyingTickAbilities; _weaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = _stoppedFlyingAbilities; } public void InitializeFromResource(WeaponInventory inventory) { _startedFlyingAbilities = new AutoSet(inventory.OnWeaponStartedFlyingAbilities); _flyingTickAbilities = new AutoSet(inventory.OnWeaponFlyingTickAbilities); _stoppedFlyingAbilities = new AutoSet(inventory.OnWeaponStoppedFlyingAbilities); } public new void Dispose() { GC.SuppressFinalize(this); _startedFlyingAbilities.Dispose(); _flyingTickAbilities.Dispose(); _stoppedFlyingAbilities.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); } }