fixed a few issues
This commit is contained in:
@@ -115,7 +115,8 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
public required EventManager Events { get; set; }
|
||||
public required Variables SharedVariables { get; set; }
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, EventElements> EventElementsMap { get; private set; } = [];
|
||||
public Dictionary<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>.Binding> EventBindingsMap { get; private set; } = [];
|
||||
public Dictionary<WeaponSystem.WeaponEvent, IAutoSet<ForgeAbilityBehavior>> EventInventoryMap { get; private set; } = [];
|
||||
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding StartedFlyingBinding { get; set; }
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding FlyingTickBinding { get; set; }
|
||||
@@ -743,22 +744,32 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
}
|
||||
|
||||
// Inventory changes signal binding
|
||||
EventElementsMap = new Dictionary<WeaponSystem.WeaponEvent, EventElements>
|
||||
EventBindingsMap = new Dictionary<WeaponSystem.WeaponEvent, AutoSet<ForgeAbilityBehavior>.Binding>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, new EventElements(StartedFlyingBinding, InventoryManager.StartedFlyingAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, new EventElements(StoppedFlyingBinding, InventoryManager.StoppedFlyingAbilities)},
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, new EventElements(FlyingTickBinding, InventoryManager.FlyingTickAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, StartedFlyingBinding },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, StoppedFlyingBinding },
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, FlyingTickBinding },
|
||||
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, new EventElements(StartedPlantedBinding, InventoryManager.StartedPlantedAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, new EventElements(StoppedPlantedBinding, InventoryManager.StoppedPlantedAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, new EventElements(PlantedTickBinding, InventoryManager.PlantedTickAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, StartedPlantedBinding },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, StoppedPlantedBinding },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, PlantedTickBinding },
|
||||
};
|
||||
|
||||
foreach (var forEvent in EventElementsMap.Keys)
|
||||
EventInventoryMap = new Dictionary<WeaponSystem.WeaponEvent, IAutoSet<ForgeAbilityBehavior>>
|
||||
{
|
||||
var element = EventElementsMap[forEvent];
|
||||
element.Binding = element.Inventory.Bind();
|
||||
element.Binding
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, InventoryManager.StartedFlyingAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, InventoryManager.StoppedFlyingAbilities },
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, InventoryManager.FlyingTickAbilities },
|
||||
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, InventoryManager.StartedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, InventoryManager.StoppedPlantedAbilities },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, InventoryManager.PlantedTickAbilities },
|
||||
};
|
||||
|
||||
foreach (var forEvent in EventBindingsMap.Keys)
|
||||
{
|
||||
EventBindingsMap[forEvent] = EventInventoryMap[forEvent].Bind();
|
||||
EventBindingsMap[forEvent]
|
||||
.OnAdd(behavior => WeaponSystem.GrantNewAbilityForEvent(forEvent, behavior))
|
||||
.OnRemove(behavior => WeaponSystem.RemoveAbilityForEvent(forEvent, behavior))
|
||||
.OnClear(() => WeaponSystem.RemoveAbilitiesForEvent(forEvent));
|
||||
@@ -769,8 +780,8 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
foreach (var element in EventElementsMap.Values)
|
||||
element.Binding.Dispose();
|
||||
foreach (var binding in EventBindingsMap.Values)
|
||||
binding.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
@@ -2328,8 +2339,8 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
_hitEnemies.Add(entity);
|
||||
TriggerDamage();
|
||||
}
|
||||
if (enemy is IStunnable stunnable)
|
||||
stunnable.Stun();
|
||||
if (enemy is IDisableable disableable)
|
||||
disableable.Disable();
|
||||
}
|
||||
|
||||
public void OnWeaponDashFinished()
|
||||
@@ -2485,9 +2496,9 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
{
|
||||
TriggerSimpleDashThroughDamage(entity);
|
||||
}
|
||||
if (_targetObject is IStunnable stunnable)
|
||||
if (_targetObject is IDisableable disableable)
|
||||
{
|
||||
stunnable.Stun();
|
||||
disableable.Disable();
|
||||
}
|
||||
IsInvincible = false;
|
||||
_playerState.SendEvent("attack_finished");
|
||||
|
||||
Reference in New Issue
Block a user