fixed inventory + using Sync bindings
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Sync.Primitives;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Attributes;
|
||||
using Gamesmiths.Forge.Core;
|
||||
@@ -34,7 +35,7 @@ public record struct EmpoweredActionPayload;
|
||||
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png"), Meta(typeof(IAutoNode))]
|
||||
public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandler
|
||||
public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandler, IDisposable
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
@@ -743,14 +744,45 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
}
|
||||
|
||||
// Inventory changes signal binding
|
||||
InventoryManager.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
||||
InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
||||
StartedFlyingBinding = InventoryManager.StartedFlyingAbilities.Bind();
|
||||
StartedFlyingBinding
|
||||
.OnAdd(behavior => WeaponSystem.GrantNewAbilityForEvent(WeaponSystem.WeaponEvent.StartedFlying, behavior))
|
||||
.OnRemove(behavior => WeaponSystem.RemoveAbilityForEvent(WeaponSystem.WeaponEvent.StartedFlying, behavior))
|
||||
.OnClear(() => WeaponSystem.RemoveAbilitiesForEvent(WeaponSystem.WeaponEvent.StartedFlying));
|
||||
FlyingTickBinding = InventoryManager.FlyingTickAbilities.Bind();
|
||||
FlyingTickBinding
|
||||
.OnAdd(behavior => WeaponSystem.GrantNewAbilityForEvent(WeaponSystem.WeaponEvent.FlyingTick, behavior))
|
||||
.OnRemove(behavior => WeaponSystem.RemoveAbilityForEvent(WeaponSystem.WeaponEvent.FlyingTick, behavior))
|
||||
.OnClear(() => WeaponSystem.RemoveAbilitiesForEvent(WeaponSystem.WeaponEvent.FlyingTick));
|
||||
StoppedFlyingBinding = InventoryManager.StoppedFlyingAbilities.Bind();
|
||||
StoppedFlyingBinding
|
||||
.OnAdd(behavior => WeaponSystem.GrantNewAbilityForEvent(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
|
||||
.OnRemove(behavior => WeaponSystem.RemoveAbilityForEvent(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
|
||||
.OnClear(() => WeaponSystem.RemoveAbilitiesForEvent(WeaponSystem.WeaponEvent.StoppedFlying));
|
||||
|
||||
// InventoryManager.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
||||
// InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
||||
}
|
||||
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding StartedFlyingBinding { get; set; }
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding FlyingTickBinding { get; set; }
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding StoppedFlyingBinding { get; set; }
|
||||
|
||||
public new void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
StartedFlyingBinding.Dispose();
|
||||
FlyingTickBinding.Dispose();
|
||||
StoppedFlyingBinding.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventAbilityAdded;
|
||||
InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventAbilityRemoved;
|
||||
// InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventAbilityAdded;
|
||||
// InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventAbilityRemoved;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user