using System.Collections.Generic; using Gamesmiths.Forge.Godot.Resources.Abilities; using Godot; using Movementtests.systems; namespace Movementtests.managers; public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, Resource ability) : RefCounted { public WeaponSystem.WeaponEvent ForEvent { get; private set; } = forEvent; public Resource Ability { get; private set; } = ability; } public partial class InventoryManager : Node { [Signal] public delegate void InventoryChangedEventHandler(); [Signal] public delegate void WeaponEventInventoryChangedEventHandler(); [Signal] public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data); [Signal] public delegate void WeaponEventAbilityRemovedEventHandler(WeaponEventAbilityData data); public Dictionary> WeaponEventsInventory { get; } = []; public static InventoryManager Instance { get; private set; } public override void _Ready() { Instance = this; WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet(); WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet(); WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet(); } public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior) { var inventoryForEvent = WeaponEventsInventory[forEvent]; var addedAbilityToInventory = inventoryForEvent.Add(abilityBehavior); if (!addedAbilityToInventory) return; EmitSignalWeaponEventInventoryChanged(); EmitSignalWeaponEventAbilityAdded(new WeaponEventAbilityData(forEvent, abilityBehavior)); } public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior) { var inventoryForEvent = WeaponEventsInventory[forEvent]; var removedFromInventory = inventoryForEvent.Remove(abilityBehavior); if (!removedFromInventory) return; EmitSignalWeaponEventInventoryChanged(); EmitSignalWeaponEventAbilityRemoved(new WeaponEventAbilityData(forEvent, abilityBehavior)); } }