diff --git a/Movement tests.csproj b/Movement tests.csproj
index a1c74c12..bd74a2d6 100644
--- a/Movement tests.csproj
+++ b/Movement tests.csproj
@@ -130,6 +130,7 @@
+
diff --git a/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu.gd b/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu.gd
index 3849ecc4..c23c37e1 100644
--- a/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu.gd
+++ b/addons/maaacks_game_template/base/scenes/overlaid_menu/overlaid_menu.gd
@@ -32,12 +32,21 @@ func _exit_tree() -> void:
func close() -> void:
menu_closing.emit()
+ hide()
+ queue_free()
+
+func hide_menu() -> void:
_scene_tree.paused = _initial_pause_state
Input.set_mouse_mode(_initial_mouse_mode)
if is_instance_valid(_initial_focus_control) and _initial_focus_control.is_inside_tree():
_initial_focus_control.focus_mode = _initial_focus_mode
_initial_focus_control.grab_focus()
- queue_free()
+
+ GUIDE.disable_mapping_context(menu_context)
+ for previous_context in previous_mapping_contexts:
+ GUIDE.enable_mapping_context(previous_context)
+
+ visible = false
func _handle_cancel_input() -> void:
close()
@@ -45,7 +54,7 @@ func _handle_cancel_input() -> void:
func _on_close_button_pressed() -> void:
close()
-func _enter_tree() -> void:
+func show_menu() -> void:
_scene_tree = get_tree()
_initial_pause_state = _scene_tree.paused
_initial_mouse_mode = Input.get_mouse_mode()
@@ -61,5 +70,11 @@ func _enter_tree() -> void:
for previous_context in previous_mapping_contexts:
GUIDE.disable_mapping_context(previous_context)
GUIDE.enable_mapping_context(menu_context)
+
+ visible = true
+
+func _enter_tree() -> void:
+ print("enter_tree")
+ show_menu()
back_action.triggered.connect(_handle_cancel_input)
diff --git a/forge/abilities/ForgeExplodingSwordBehavior.cs b/forge/abilities/ForgeExplodingSwordBehavior.cs
index c4ebb4d8..806eeb55 100644
--- a/forge/abilities/ForgeExplodingSwordBehavior.cs
+++ b/forge/abilities/ForgeExplodingSwordBehavior.cs
@@ -12,6 +12,7 @@ public class ExplodingSwordBehavior(PackedScene explosion, float radius) : IAbil
{
if (context.Owner is not Node3D owner)
{
+ GD.Print("Owner isn't a Node3D");
context.InstanceHandle.End();
return;
}
@@ -30,7 +31,6 @@ public class ExplodingSwordBehavior(PackedScene explosion, float radius) : IAbil
}
explo.Radius = radius;
- GD.Print("explosion");
owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explo);
explo.CallDeferred(Node3D.MethodName.SetGlobalPosition, owner.GlobalPosition);
diff --git a/forge/abilities/ForgeInstantEndBehavior.cs b/forge/abilities/ForgeInstantEndBehavior.cs
index f14de0ef..ea50174a 100644
--- a/forge/abilities/ForgeInstantEndBehavior.cs
+++ b/forge/abilities/ForgeInstantEndBehavior.cs
@@ -1,13 +1,20 @@
using Gamesmiths.Forge.Abilities;
+using Gamesmiths.Forge.Effects;
+using Gamesmiths.Forge.Godot.Resources;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
namespace Movementtests.forge.abilities;
-public class InstantEndBehavior : IAbilityBehavior
+public class InstantEndBehavior(ForgeEffectData? effectData) : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
+ if (effectData != null)
+ {
+ var effect = new Effect(effectData.GetEffectData(), new EffectOwnership(context.Owner, context.Owner));
+ context.Owner.EffectsManager.ApplyEffect(effect);
+ }
context.AbilityHandle.CommitAbility();
context.InstanceHandle.End();
}
@@ -19,5 +26,6 @@ public class InstantEndBehavior : IAbilityBehavior
[GlobalClass]
public partial class ForgeInstantEndBehavior : ForgeAbilityBehavior
{
- public override IAbilityBehavior GetBehavior() => new InstantEndBehavior();
+ [Export] public ForgeEffectData? OptionalEffectData { get; set; }
+ public override IAbilityBehavior GetBehavior() => new InstantEndBehavior(OptionalEffectData);
}
\ No newline at end of file
diff --git a/forge/resources/ability_datas/empowered_action.tres b/forge/resources/ability_datas/empowered_action.tres
index a38bd0e4..6e0081a0 100644
--- a/forge/resources/ability_datas/empowered_action.tres
+++ b/forge/resources/ability_datas/empowered_action.tres
@@ -1,84 +1,21 @@
[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://dccuj66egxfwh"]
+[ext_resource type="Resource" uid="uid://c4ea6ktafqe0r" path="res://forge/resources/effect_datas/temp_invincibility.tres" id="1_ent4t"]
+[ext_resource type="Script" uid="uid://c7s5v7ii4nujg" path="res://forge/abilities/ForgeInstantEndBehavior.cs" id="2_ent4t"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="2_prg0a"]
[ext_resource type="Script" uid="uid://dngf30hxy5go4" path="res://addons/forge/resources/components/ModifierTags.cs" id="3_k72m0"]
[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="4_5fdax"]
[ext_resource type="Script" uid="uid://2gm1hdhi8u08" path="res://addons/forge/resources/magnitudes/ForgeModifierMagnitude.cs" id="5_5qmmj"]
[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="6_yi0bg"]
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="7_0rp6y"]
-[ext_resource type="Script" uid="uid://cl5hudinl1rex" path="res://forge/abilities/ForgeEffectApplicationBehavior.cs" id="7_ent4t"]
[ext_resource type="Resource" uid="uid://dn7b8frkoxpxr" path="res://forge/resources/cues/player_mana_changed_cue.tres" id="8_0olwd"]
-[ext_resource type="Resource" uid="uid://cw2ytd34jsxj" path="res://forge/resources/tag_containers/immune_damage.tres" id="8_ent4t"]
[ext_resource type="Script" uid="uid://bdfcavbjyhxxa" path="res://addons/forge/resources/ForgeModifier.cs" id="9_wluo0"]
[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="10_2sq4o"]
[sub_resource type="Resource" id="Resource_xltxv"]
-script = ExtResource("3_k72m0")
-TagsToAdd = ExtResource("8_ent4t")
-metadata/_custom_type_script = "uid://dngf30hxy5go4"
-
-[sub_resource type="Resource" id="Resource_60xl1"]
-script = ExtResource("4_5fdax")
-BaseValue = 1.0
-
-[sub_resource type="Resource" id="Resource_2rev5"]
-script = ExtResource("4_5fdax")
-
-[sub_resource type="Resource" id="Resource_kxytj"]
-script = ExtResource("4_5fdax")
-
-[sub_resource type="Resource" id="Resource_e5nje"]
-script = ExtResource("4_5fdax")
-BaseValue = 1.0
-
-[sub_resource type="Resource" id="Resource_xc8ja"]
-script = ExtResource("4_5fdax")
-
-[sub_resource type="Resource" id="Resource_tan32"]
-script = ExtResource("4_5fdax")
-
-[sub_resource type="Resource" id="Resource_l52b0"]
-script = ExtResource("4_5fdax")
-BaseValue = 0.3
-metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
-
-[sub_resource type="Resource" id="Resource_6jn6y"]
-script = ExtResource("5_5qmmj")
-ScalableFloat = SubResource("Resource_l52b0")
-Coefficient = SubResource("Resource_e5nje")
-PreMultiplyAdditiveValue = SubResource("Resource_tan32")
-PostMultiplyAdditiveValue = SubResource("Resource_xc8ja")
-CalculatorCoefficient = SubResource("Resource_60xl1")
-CalculatorPreMultiplyAdditiveValue = SubResource("Resource_kxytj")
-CalculatorPostMultiplyAdditiveValue = SubResource("Resource_2rev5")
-metadata/_custom_type_script = "uid://2gm1hdhi8u08"
-
-[sub_resource type="Resource" id="Resource_ev6w4"]
-script = ExtResource("6_yi0bg")
-BaseValue = 1
-
-[sub_resource type="Resource" id="Resource_u8xa8"]
-script = ExtResource("6_yi0bg")
-BaseValue = 1
-
-[sub_resource type="Resource" id="Resource_xsfte"]
-script = ExtResource("7_0rp6y")
-Name = "ApplyInvincibility"
-Modifiers = []
-Components = Array[Object]([SubResource("Resource_xltxv")])
-Executions = null
-DurationType = 2
-Duration = SubResource("Resource_6jn6y")
-StackLimit = SubResource("Resource_u8xa8")
-InitialStack = SubResource("Resource_ev6w4")
-Cues = null
-metadata/_custom_type_script = "uid://b83hf13nj37k3"
-
-[sub_resource type="Resource" id="Resource_xh53a"]
-script = ExtResource("7_ent4t")
-EffectData = SubResource("Resource_xsfte")
-Name = "Apply invincibility"
-metadata/_custom_type_script = "uid://cl5hudinl1rex"
+script = ExtResource("2_ent4t")
+OptionalEffectData = ExtResource("1_ent4t")
+metadata/_custom_type_script = "uid://c7s5v7ii4nujg"
[sub_resource type="Resource" id="Resource_h116a"]
script = ExtResource("2_prg0a")
@@ -245,5 +182,5 @@ script = ExtResource("10_2sq4o")
Name = "Empowered Action"
CooldownEffects = [SubResource("Resource_egh2b")]
CostEffect = SubResource("Resource_mtef8")
-AbilityBehavior = SubResource("Resource_xh53a")
+AbilityBehavior = SubResource("Resource_xltxv")
metadata/_custom_type_script = "uid://dhxfbxh54pyxp"
diff --git a/forge/resources/effect_datas/temp_invincibility.tres b/forge/resources/effect_datas/temp_invincibility.tres
new file mode 100644
index 00000000..2de768c4
--- /dev/null
+++ b/forge/resources/effect_datas/temp_invincibility.tres
@@ -0,0 +1,70 @@
+[gd_resource type="Resource" script_class="ForgeEffectData" format=3 uid="uid://c4ea6ktafqe0r"]
+
+[ext_resource type="Resource" uid="uid://cw2ytd34jsxj" path="res://forge/resources/tag_containers/immune_damage.tres" id="1_suvh6"]
+[ext_resource type="Script" uid="uid://dngf30hxy5go4" path="res://addons/forge/resources/components/ModifierTags.cs" id="2_7y7k0"]
+[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="3_wdmyo"]
+[ext_resource type="Script" uid="uid://2gm1hdhi8u08" path="res://addons/forge/resources/magnitudes/ForgeModifierMagnitude.cs" id="4_m2dme"]
+[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="5_uck3v"]
+[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="6_gt48y"]
+
+[sub_resource type="Resource" id="Resource_xltxv"]
+script = ExtResource("2_7y7k0")
+TagsToAdd = ExtResource("1_suvh6")
+metadata/_custom_type_script = "uid://dngf30hxy5go4"
+
+[sub_resource type="Resource" id="Resource_60xl1"]
+script = ExtResource("3_wdmyo")
+BaseValue = 1.0
+
+[sub_resource type="Resource" id="Resource_2rev5"]
+script = ExtResource("3_wdmyo")
+
+[sub_resource type="Resource" id="Resource_kxytj"]
+script = ExtResource("3_wdmyo")
+
+[sub_resource type="Resource" id="Resource_e5nje"]
+script = ExtResource("3_wdmyo")
+BaseValue = 1.0
+
+[sub_resource type="Resource" id="Resource_xc8ja"]
+script = ExtResource("3_wdmyo")
+
+[sub_resource type="Resource" id="Resource_tan32"]
+script = ExtResource("3_wdmyo")
+
+[sub_resource type="Resource" id="Resource_l52b0"]
+script = ExtResource("3_wdmyo")
+BaseValue = 0.3
+metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
+
+[sub_resource type="Resource" id="Resource_6jn6y"]
+script = ExtResource("4_m2dme")
+ScalableFloat = SubResource("Resource_l52b0")
+Coefficient = SubResource("Resource_e5nje")
+PreMultiplyAdditiveValue = SubResource("Resource_tan32")
+PostMultiplyAdditiveValue = SubResource("Resource_xc8ja")
+CalculatorCoefficient = SubResource("Resource_60xl1")
+CalculatorPreMultiplyAdditiveValue = SubResource("Resource_kxytj")
+CalculatorPostMultiplyAdditiveValue = SubResource("Resource_2rev5")
+metadata/_custom_type_script = "uid://2gm1hdhi8u08"
+
+[sub_resource type="Resource" id="Resource_ev6w4"]
+script = ExtResource("5_uck3v")
+BaseValue = 1
+
+[sub_resource type="Resource" id="Resource_u8xa8"]
+script = ExtResource("5_uck3v")
+BaseValue = 1
+
+[resource]
+script = ExtResource("6_gt48y")
+Name = "ApplyInvincibility"
+Modifiers = []
+Components = Array[Object]([SubResource("Resource_xltxv")])
+Executions = []
+DurationType = 2
+Duration = SubResource("Resource_6jn6y")
+StackLimit = SubResource("Resource_u8xa8")
+InitialStack = SubResource("Resource_ev6w4")
+Cues = []
+metadata/_custom_type_script = "uid://b83hf13nj37k3"
diff --git a/managers/InventoryManager.cs b/managers/InventoryManager.cs
index 4109db8a..4cd92d30 100644
--- a/managers/InventoryManager.cs
+++ b/managers/InventoryManager.cs
@@ -1,6 +1,8 @@
+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;
@@ -14,11 +16,13 @@ public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, F
public ForgeAbilityBehavior Ability { get; private set; } = ability;
}
-[GlobalClass]
-public partial class InventoryManager : Node
+[GlobalClass, Meta(typeof(IAutoNode))]
+public partial class InventoryManager : Node, IDisposable
{
- #region Signals
+ public override void _Notification(int what) => this.Notify(what);
+ #region Signals
+
[Signal]
public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data);
[Signal]
@@ -26,35 +30,52 @@ public partial class InventoryManager : Node
#endregion
- public Dictionary> WeaponEventsInventory { get; private set; }
- = new() {
- { WeaponSystem.WeaponEvent.FlyingTick, [] },
- { WeaponSystem.WeaponEvent.StartedFlying, [] },
- { WeaponSystem.WeaponEvent.StoppedFlying, [] }
- };
+ private AutoSet _startedFlyingAbilities = new();
+ private AutoSet _flyingTickAbilities = new();
+ private AutoSet _stoppedFlyingAbilities = new();
+ public IAutoSet StartedFlyingAbilities => _startedFlyingAbilities;
+ public IAutoSet FlyingTickAbilities => _flyingTickAbilities;
+ public IAutoSet StoppedFlyingAbilities => _stoppedFlyingAbilities;
+
+ private readonly AutoMap> _weaponEventsInventory = new();
+ public IAutoMap> WeaponEventsInventory => _weaponEventsInventory;
+
+ public void OnReady()
+ {
+ _weaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = _startedFlyingAbilities;
+ _weaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = _flyingTickAbilities;
+ _weaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = _stoppedFlyingAbilities;
+ }
+
public void InitializeFromResource(WeaponInventory inventory)
{
- WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet(inventory.OnWeaponFlyingTickAbilities);
- WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet(inventory.OnWeaponStartedFlyingAbilities);
- WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet(inventory.OnWeaponStoppedFlyingAbilities);
+ _startedFlyingAbilities = new AutoSet(inventory.OnWeaponStartedFlyingAbilities);
+ _flyingTickAbilities = new AutoSet(inventory.OnWeaponFlyingTickAbilities);
+ _stoppedFlyingAbilities = new AutoSet(inventory.OnWeaponStoppedFlyingAbilities);
+ }
+
+ public new void Dispose()
+ {
+ GC.SuppressFinalize(this);
+
+ _startedFlyingAbilities.Dispose();
+ _flyingTickAbilities.Dispose();
+ _stoppedFlyingAbilities.Dispose();
+ _weaponEventsInventory.Dispose();
+
+ base.Dispose();
}
public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- var inventoryForEvent = WeaponEventsInventory[forEvent];
- var addedAbilityToInventory = inventoryForEvent.Add(abilityBehavior);
- if (!addedAbilityToInventory) return;
-
- EmitSignalWeaponEventAbilityAdded(new WeaponEventAbilityData(forEvent, abilityBehavior));
+ var inventoryForEvent = _weaponEventsInventory[forEvent];
+ inventoryForEvent.Add(abilityBehavior);
}
public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- var inventoryForEvent = WeaponEventsInventory[forEvent];
- var removedFromInventory = inventoryForEvent.Remove(abilityBehavior);
- if (!removedFromInventory) return;
-
- EmitSignalWeaponEventAbilityRemoved(new WeaponEventAbilityData(forEvent, abilityBehavior));
+ var inventoryForEvent = _weaponEventsInventory[forEvent];
+ inventoryForEvent.Remove(abilityBehavior);
}
}
diff --git a/menus/scenes/components/AbilitySelection.cs b/menus/scenes/components/AbilitySelection.cs
index 56c9854f..9bad9406 100644
--- a/menus/scenes/components/AbilitySelection.cs
+++ b/menus/scenes/components/AbilitySelection.cs
@@ -90,4 +90,12 @@ public partial class AbilitySelection : Control
return;
}
}
+
+ public void ClearAbilities()
+ {
+ foreach (var child in SelectedAbilities.GetChildren())
+ {
+ SelectedAbilities.RemoveChild(child);
+ }
+ }
}
diff --git a/menus/scenes/overlaid_menus/InventoryUi.cs b/menus/scenes/overlaid_menus/InventoryUi.cs
index b816b7b6..8aa95fb5 100644
--- a/menus/scenes/overlaid_menus/InventoryUi.cs
+++ b/menus/scenes/overlaid_menus/InventoryUi.cs
@@ -1,6 +1,8 @@
+using System;
using System.Collections.Generic;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
+using Chickensoft.Sync.Primitives;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
@@ -9,7 +11,7 @@ using Movementtests.systems;
[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png"), Meta(typeof(IAutoNode))]
-public partial class InventoryUi : Control
+public partial class InventoryUi : Control, IDisposable
{
public override void _Notification(int what) => this.Notify(what);
@@ -27,6 +29,10 @@ public partial class InventoryUi : Control
public required AbilitySelection StoppedFlying { get; set; }
#endregion Nodes
+ public AutoSet.Binding StartedFlyingBinding { get; set; }
+ public AutoSet.Binding FlyingTickBinding { get; set; }
+ public AutoSet.Binding StoppedFlyingBinding { get; set; }
+
public void OnReady()
{
StartedFlying.AbilityAdded += AddAbilityForEvent;
@@ -44,16 +50,34 @@ public partial class InventoryUi : Control
WhileFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
StoppedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
- InventoryManager.WeaponEventAbilityAdded += OnWeaponEventInventoryAdded;
- InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventInventoryRemoved;
+ StartedFlyingBinding = InventoryManager.StartedFlyingAbilities.Bind();
+ StartedFlyingBinding
+ .OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.StartedFlying, behavior))
+ .OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.StartedFlying, behavior))
+ .OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.StartedFlying));
+ FlyingTickBinding = InventoryManager.FlyingTickAbilities.Bind();
+ FlyingTickBinding
+ .OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.FlyingTick, behavior))
+ .OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.FlyingTick, behavior))
+ .OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.FlyingTick));
+ StoppedFlyingBinding = InventoryManager.StoppedFlyingAbilities.Bind();
+ StoppedFlyingBinding
+ .OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
+ .OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
+ .OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.StoppedFlying));
}
- public void OnExitTree()
+ public new void Dispose()
{
- InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventInventoryAdded;
- InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventInventoryRemoved;
+ GC.SuppressFinalize(this);
+
+ StartedFlying.Dispose();
+ WhileFlying.Dispose();
+ StoppedFlying.Dispose();
+
+ base.Dispose();
}
-
+
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
InventoryManager.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
@@ -64,16 +88,22 @@ public partial class InventoryUi : Control
InventoryManager.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
}
- public void OnWeaponEventInventoryAdded(WeaponEventAbilityData data)
+ public void OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- var selection = GetAbilitySelection(data.ForEvent);
- selection.AddSelectedAbility(data.Ability);
+ var selection = GetAbilitySelection(forEvent);
+ selection.AddSelectedAbility(abilityBehavior);
}
- public void OnWeaponEventInventoryRemoved(WeaponEventAbilityData data)
+ public void OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- var selection = GetAbilitySelection(data.ForEvent);
- selection.RemoveSelectedAbility(data.Ability);
+ var selection = GetAbilitySelection(forEvent);
+ selection.RemoveSelectedAbility(abilityBehavior);
+ }
+
+ public void OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent forEvent)
+ {
+ var selection = GetAbilitySelection(forEvent);
+ selection.ClearAbilities();
}
public AbilitySelection GetAbilitySelection(WeaponSystem.WeaponEvent forEvent)
diff --git a/menus/scenes/overlaid_menus/inventory_wrapper.gd b/menus/scenes/overlaid_menus/inventory_wrapper.gd
index 17c1090f..f8e5fa49 100644
--- a/menus/scenes/overlaid_menus/inventory_wrapper.gd
+++ b/menus/scenes/overlaid_menus/inventory_wrapper.gd
@@ -8,5 +8,8 @@ extends OverlaidMenu
func _ready() -> void:
if Engine.is_editor_hint(): return
+func _handle_cancel_input() -> void:
+ hide_menu()
+
func _on_close_button_pressed() -> void:
- close()
+ hide_menu()
diff --git a/scenes/player_controller/components/weapon/WeaponSystem.cs b/scenes/player_controller/components/weapon/WeaponSystem.cs
index 145f7be9..9393de69 100644
--- a/scenes/player_controller/components/weapon/WeaponSystem.cs
+++ b/scenes/player_controller/components/weapon/WeaponSystem.cs
@@ -343,15 +343,20 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
{
foreach (var weaponEvent in Enum.GetValues())
{
- 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 GetGrantedAbilities(WeaponEvent forEvent)
{
var abilitiesMap = new Dictionary>
diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs
index a7a4d3f3..1d35c167 100644
--- a/scenes/player_controller/scripts/PlayerController.cs
+++ b/scenes/player_controller/scripts/PlayerController.cs
@@ -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.Binding StartedFlyingBinding { get; set; }
+ public AutoSet.Binding FlyingTickBinding { get; set; }
+ public AutoSet.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
diff --git a/tools/general_manager.gd b/tools/general_manager.gd
index c342bad8..e565f264 100644
--- a/tools/general_manager.gd
+++ b/tools/general_manager.gd
@@ -21,6 +21,8 @@ extends Node
@onready var inventory_layer: CanvasLayer = $"../InventoryLayer"
@onready var player: PlayerController = $"../Player"
+var inventory: OverlaidMenu = null
+
func _ready() -> void:
toolbox_action.triggered.connect(open_toolbox)
inventory_action.triggered.connect(open_inventory)
@@ -37,9 +39,11 @@ func open_toolbox() -> void:
debug_layer.call_deferred("add_child", toolbox)
func open_inventory() -> void:
- var inventory: Control = open_overlaid_menu(inventory_scene)
- # inventory.player = player
- inventory_layer.call_deferred("add_child", inventory)
+ if inventory == null:
+ inventory = open_overlaid_menu(inventory_scene)
+ inventory_layer.call_deferred("add_child", inventory)
+ return
+ inventory.show_menu()
func on_player_died() -> void:
var lost_menu: LevelLostMenu = open_overlaid_menu(lost_menu_scene)