made the initial inventory loadout into a resource to initialize the injected dependency with
This commit is contained in:
@@ -1,36 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.managers;
|
||||
|
||||
public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, Resource ability)
|
||||
public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior ability)
|
||||
: RefCounted
|
||||
{
|
||||
public WeaponSystem.WeaponEvent ForEvent { get; private set; } = forEvent;
|
||||
public Resource Ability { get; private set; } = ability;
|
||||
public ForgeAbilityBehavior Ability { get; private set; } = ability;
|
||||
}
|
||||
|
||||
[GlobalClass]
|
||||
public partial class InventoryManager : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void InventoryChangedEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void WeaponEventInventoryChangedEventHandler();
|
||||
#region Signals
|
||||
|
||||
[Signal]
|
||||
public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data);
|
||||
[Signal]
|
||||
public delegate void WeaponEventAbilityRemovedEventHandler(WeaponEventAbilityData data);
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, HashSet<Resource>> WeaponEventsInventory { get; } = [];
|
||||
#endregion
|
||||
|
||||
public override void _Ready()
|
||||
public Dictionary<WeaponSystem.WeaponEvent, HashSet<ForgeAbilityBehavior>> WeaponEventsInventory { get;
|
||||
private set;
|
||||
} = [];
|
||||
|
||||
public void InitializeFromResource(WeaponInventory inventory)
|
||||
{
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet<Resource>();
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet<Resource>();
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet<Resource>();
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponFlyingTickAbilities);
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponStartedFlyingAbilities);
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponStoppedFlyingAbilities);
|
||||
}
|
||||
|
||||
public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
@@ -39,7 +43,6 @@ public partial class InventoryManager : Node
|
||||
var addedAbilityToInventory = inventoryForEvent.Add(abilityBehavior);
|
||||
if (!addedAbilityToInventory) return;
|
||||
|
||||
EmitSignalWeaponEventInventoryChanged();
|
||||
EmitSignalWeaponEventAbilityAdded(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
||||
}
|
||||
|
||||
@@ -49,7 +52,6 @@ public partial class InventoryManager : Node
|
||||
var removedFromInventory = inventoryForEvent.Remove(abilityBehavior);
|
||||
if (!removedFromInventory) return;
|
||||
|
||||
EmitSignalWeaponEventInventoryChanged();
|
||||
EmitSignalWeaponEventAbilityRemoved(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user