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);
|
||||
}
|
||||
}
|
||||
1
managers/Inventory/InventoryManager.cs.uid
Normal file
1
managers/Inventory/InventoryManager.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cgwhrwfqsiing
|
||||
51
managers/Inventory/WeaponInventory.cs
Normal file
51
managers/Inventory/WeaponInventory.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.managers;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class WeaponInventory(
|
||||
ForgeAbilityBehavior[] onWeaponStartedFlyingAbilities,
|
||||
ForgeAbilityBehavior[] onWeaponFlyingTickAbilities,
|
||||
ForgeAbilityBehavior[] onWeaponStoppedFlyingAbilities,
|
||||
ForgeAbilityBehavior[] onWeaponStartedPlantedAbilities,
|
||||
ForgeAbilityBehavior[] onWeaponPlantedTickAbilities,
|
||||
ForgeAbilityBehavior[] onWeaponStoppedPlantedAbilities
|
||||
) : Resource
|
||||
{
|
||||
[ExportGroup("Flying abilities")]
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponStartedFlyingAbilities { get; set; } = onWeaponStartedFlyingAbilities;
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponFlyingTickAbilities { get; set; } = onWeaponFlyingTickAbilities;
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponStoppedFlyingAbilities { get; set; } = onWeaponStoppedFlyingAbilities;
|
||||
|
||||
[ExportGroup("Planted abilities")]
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponStartedPlantedAbilities { get; set; } = onWeaponStartedPlantedAbilities;
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponPlantedTickAbilities { get; set; } = onWeaponPlantedTickAbilities;
|
||||
[Export]
|
||||
public ForgeAbilityBehavior[] OnWeaponStoppedPlantedAbilities { get; set; } = onWeaponStoppedPlantedAbilities;
|
||||
|
||||
public WeaponInventory() : this([], [], [], [], [], [])
|
||||
{
|
||||
}
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]> GetEventAbilitiesMap()
|
||||
{
|
||||
return new Dictionary<WeaponSystem.WeaponEvent, ForgeAbilityBehavior[]>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, OnWeaponStartedFlyingAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, OnWeaponStoppedFlyingAbilities },
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, OnWeaponFlyingTickAbilities },
|
||||
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, OnWeaponStartedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, OnWeaponStoppedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, OnWeaponPlantedTickAbilities },
|
||||
};
|
||||
}
|
||||
}
|
||||
1
managers/Inventory/WeaponInventory.cs.uid
Normal file
1
managers/Inventory/WeaponInventory.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cgaahnfgxcrr6
|
||||
Reference in New Issue
Block a user