fixed inventory + using Sync bindings
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 57s
Create tag and build when new code gets to main / Export (push) Successful in 5m13s

This commit is contained in:
2026-05-04 10:19:00 +02:00
parent 99f383be00
commit bed1384dc7
13 changed files with 258 additions and 124 deletions

View File

@@ -343,15 +343,20 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
{
foreach (var weaponEvent in Enum.GetValues<WeaponEvent>())
{
var abilities = GetGrantedAbilities(weaponEvent);
foreach (var ability in abilities.Values)
{
EffectsManager.RemoveEffect(ability);
}
abilities.Clear();
RemoveAbilitiesForEvent(weaponEvent);
}
}
public void RemoveAbilitiesForEvent(WeaponEvent weaponEvent)
{
var abilities = GetGrantedAbilities(weaponEvent);
foreach (var ability in abilities.Values)
{
EffectsManager.RemoveEffect(ability);
}
abilities.Clear();
}
public Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> GetGrantedAbilities(WeaponEvent forEvent)
{
var abilitiesMap = new Dictionary<WeaponEvent, Dictionary<ForgeAbilityBehavior, ActiveEffectHandle>>

View File

@@ -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