fixed a few issues
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 30s
Create tag and build when new code gets to main / Export (push) Successful in 6m0s

This commit is contained in:
2026-05-06 16:25:56 +02:00
parent bcc748ca6b
commit 7ba4a3db3f
22 changed files with 133 additions and 660 deletions

View File

@@ -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();

View File

@@ -31,11 +31,13 @@ public partial class WeaponInventory(
[Export]
public ForgeAbilityBehavior[] OnWeaponStoppedPlantedAbilities { get; set; } = onWeaponStoppedPlantedAbilities;
public Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]> EventMap { get; private set; } = [];
public WeaponInventory() : this([], [], [], [], [], [])
{
EventMap = new Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]>
}
public Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]> GetEventAbilitiesMap()
{
return new Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]>
{
{ WeaponSystem.WeaponEvent.StartedFlying, OnWeaponStartedFlyingAbilities },
{ WeaponSystem.WeaponEvent.StoppedFlying, OnWeaponStoppedFlyingAbilities },