Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bed1384dc7 |
@@ -130,6 +130,7 @@
|
|||||||
<Folder Include="tests\" />
|
<Folder Include="tests\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Chickensoft.Sync" Version="2.3.0" />
|
||||||
<PackageReference Include="RustyOptions" Version="0.10.1" />
|
<PackageReference Include="RustyOptions" Version="0.10.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -32,12 +32,21 @@ func _exit_tree() -> void:
|
|||||||
|
|
||||||
func close() -> void:
|
func close() -> void:
|
||||||
menu_closing.emit()
|
menu_closing.emit()
|
||||||
|
hide()
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func hide_menu() -> void:
|
||||||
_scene_tree.paused = _initial_pause_state
|
_scene_tree.paused = _initial_pause_state
|
||||||
Input.set_mouse_mode(_initial_mouse_mode)
|
Input.set_mouse_mode(_initial_mouse_mode)
|
||||||
if is_instance_valid(_initial_focus_control) and _initial_focus_control.is_inside_tree():
|
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.focus_mode = _initial_focus_mode
|
||||||
_initial_focus_control.grab_focus()
|
_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:
|
func _handle_cancel_input() -> void:
|
||||||
close()
|
close()
|
||||||
@@ -45,7 +54,7 @@ func _handle_cancel_input() -> void:
|
|||||||
func _on_close_button_pressed() -> void:
|
func _on_close_button_pressed() -> void:
|
||||||
close()
|
close()
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func show_menu() -> void:
|
||||||
_scene_tree = get_tree()
|
_scene_tree = get_tree()
|
||||||
_initial_pause_state = _scene_tree.paused
|
_initial_pause_state = _scene_tree.paused
|
||||||
_initial_mouse_mode = Input.get_mouse_mode()
|
_initial_mouse_mode = Input.get_mouse_mode()
|
||||||
@@ -61,5 +70,11 @@ func _enter_tree() -> void:
|
|||||||
for previous_context in previous_mapping_contexts:
|
for previous_context in previous_mapping_contexts:
|
||||||
GUIDE.disable_mapping_context(previous_context)
|
GUIDE.disable_mapping_context(previous_context)
|
||||||
GUIDE.enable_mapping_context(menu_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)
|
back_action.triggered.connect(_handle_cancel_input)
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class ExplodingSwordBehavior(PackedScene explosion, float radius) : IAbil
|
|||||||
{
|
{
|
||||||
if (context.Owner is not Node3D owner)
|
if (context.Owner is not Node3D owner)
|
||||||
{
|
{
|
||||||
|
GD.Print("Owner isn't a Node3D");
|
||||||
context.InstanceHandle.End();
|
context.InstanceHandle.End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,6 @@ public class ExplodingSwordBehavior(PackedScene explosion, float radius) : IAbil
|
|||||||
}
|
}
|
||||||
explo.Radius = radius;
|
explo.Radius = radius;
|
||||||
|
|
||||||
GD.Print("explosion");
|
|
||||||
owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explo);
|
owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explo);
|
||||||
explo.CallDeferred(Node3D.MethodName.SetGlobalPosition, owner.GlobalPosition);
|
explo.CallDeferred(Node3D.MethodName.SetGlobalPosition, owner.GlobalPosition);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
using Gamesmiths.Forge.Abilities;
|
using Gamesmiths.Forge.Abilities;
|
||||||
|
using Gamesmiths.Forge.Effects;
|
||||||
|
using Gamesmiths.Forge.Godot.Resources;
|
||||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Movementtests.forge.abilities;
|
namespace Movementtests.forge.abilities;
|
||||||
|
|
||||||
public class InstantEndBehavior : IAbilityBehavior
|
public class InstantEndBehavior(ForgeEffectData? effectData) : IAbilityBehavior
|
||||||
{
|
{
|
||||||
public void OnStarted(AbilityBehaviorContext context)
|
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.AbilityHandle.CommitAbility();
|
||||||
context.InstanceHandle.End();
|
context.InstanceHandle.End();
|
||||||
}
|
}
|
||||||
@@ -19,5 +26,6 @@ public class InstantEndBehavior : IAbilityBehavior
|
|||||||
[GlobalClass]
|
[GlobalClass]
|
||||||
public partial class ForgeInstantEndBehavior : ForgeAbilityBehavior
|
public partial class ForgeInstantEndBehavior : ForgeAbilityBehavior
|
||||||
{
|
{
|
||||||
public override IAbilityBehavior GetBehavior() => new InstantEndBehavior();
|
[Export] public ForgeEffectData? OptionalEffectData { get; set; }
|
||||||
|
public override IAbilityBehavior GetBehavior() => new InstantEndBehavior(OptionalEffectData);
|
||||||
}
|
}
|
||||||
@@ -1,84 +1,21 @@
|
|||||||
[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://dccuj66egxfwh"]
|
[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://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://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://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://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://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://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://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://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"]
|
[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"]
|
[sub_resource type="Resource" id="Resource_xltxv"]
|
||||||
script = ExtResource("3_k72m0")
|
script = ExtResource("2_ent4t")
|
||||||
TagsToAdd = ExtResource("8_ent4t")
|
OptionalEffectData = ExtResource("1_ent4t")
|
||||||
metadata/_custom_type_script = "uid://dngf30hxy5go4"
|
metadata/_custom_type_script = "uid://c7s5v7ii4nujg"
|
||||||
|
|
||||||
[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"
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_h116a"]
|
[sub_resource type="Resource" id="Resource_h116a"]
|
||||||
script = ExtResource("2_prg0a")
|
script = ExtResource("2_prg0a")
|
||||||
@@ -245,5 +182,5 @@ script = ExtResource("10_2sq4o")
|
|||||||
Name = "Empowered Action"
|
Name = "Empowered Action"
|
||||||
CooldownEffects = [SubResource("Resource_egh2b")]
|
CooldownEffects = [SubResource("Resource_egh2b")]
|
||||||
CostEffect = SubResource("Resource_mtef8")
|
CostEffect = SubResource("Resource_mtef8")
|
||||||
AbilityBehavior = SubResource("Resource_xh53a")
|
AbilityBehavior = SubResource("Resource_xltxv")
|
||||||
metadata/_custom_type_script = "uid://dhxfbxh54pyxp"
|
metadata/_custom_type_script = "uid://dhxfbxh54pyxp"
|
||||||
|
|||||||
70
forge/resources/effect_datas/temp_invincibility.tres
Normal file
70
forge/resources/effect_datas/temp_invincibility.tres
Normal file
@@ -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"
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
|
using Chickensoft.Sync.Primitives;
|
||||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Movementtests.systems;
|
using Movementtests.systems;
|
||||||
@@ -14,11 +16,13 @@ public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, F
|
|||||||
public ForgeAbilityBehavior Ability { get; private set; } = ability;
|
public ForgeAbilityBehavior Ability { get; private set; } = ability;
|
||||||
}
|
}
|
||||||
|
|
||||||
[GlobalClass]
|
[GlobalClass, Meta(typeof(IAutoNode))]
|
||||||
public partial class InventoryManager : Node
|
public partial class InventoryManager : Node, IDisposable
|
||||||
{
|
{
|
||||||
#region Signals
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
#region Signals
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data);
|
public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data);
|
||||||
[Signal]
|
[Signal]
|
||||||
@@ -26,35 +30,52 @@ public partial class InventoryManager : Node
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Dictionary<WeaponSystem.WeaponEvent, HashSet<ForgeAbilityBehavior>> WeaponEventsInventory { get; private set; }
|
private AutoSet<ForgeAbilityBehavior> _startedFlyingAbilities = new();
|
||||||
= new() {
|
private AutoSet<ForgeAbilityBehavior> _flyingTickAbilities = new();
|
||||||
{ WeaponSystem.WeaponEvent.FlyingTick, [] },
|
private AutoSet<ForgeAbilityBehavior> _stoppedFlyingAbilities = new();
|
||||||
{ WeaponSystem.WeaponEvent.StartedFlying, [] },
|
|
||||||
{ WeaponSystem.WeaponEvent.StoppedFlying, [] }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public IAutoSet<ForgeAbilityBehavior> StartedFlyingAbilities => _startedFlyingAbilities;
|
||||||
|
public IAutoSet<ForgeAbilityBehavior> FlyingTickAbilities => _flyingTickAbilities;
|
||||||
|
public IAutoSet<ForgeAbilityBehavior> StoppedFlyingAbilities => _stoppedFlyingAbilities;
|
||||||
|
|
||||||
|
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.FlyingTick] = _flyingTickAbilities;
|
||||||
|
_weaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = _stoppedFlyingAbilities;
|
||||||
|
}
|
||||||
|
|
||||||
public void InitializeFromResource(WeaponInventory inventory)
|
public void InitializeFromResource(WeaponInventory inventory)
|
||||||
{
|
{
|
||||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponFlyingTickAbilities);
|
_startedFlyingAbilities = new AutoSet<ForgeAbilityBehavior>(inventory.OnWeaponStartedFlyingAbilities);
|
||||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponStartedFlyingAbilities);
|
_flyingTickAbilities = new AutoSet<ForgeAbilityBehavior>(inventory.OnWeaponFlyingTickAbilities);
|
||||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet<ForgeAbilityBehavior>(inventory.OnWeaponStoppedFlyingAbilities);
|
_stoppedFlyingAbilities = new AutoSet<ForgeAbilityBehavior>(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)
|
public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||||
{
|
{
|
||||||
var inventoryForEvent = WeaponEventsInventory[forEvent];
|
var inventoryForEvent = _weaponEventsInventory[forEvent];
|
||||||
var addedAbilityToInventory = inventoryForEvent.Add(abilityBehavior);
|
inventoryForEvent.Add(abilityBehavior);
|
||||||
if (!addedAbilityToInventory) return;
|
|
||||||
|
|
||||||
EmitSignalWeaponEventAbilityAdded(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||||
{
|
{
|
||||||
var inventoryForEvent = WeaponEventsInventory[forEvent];
|
var inventoryForEvent = _weaponEventsInventory[forEvent];
|
||||||
var removedFromInventory = inventoryForEvent.Remove(abilityBehavior);
|
inventoryForEvent.Remove(abilityBehavior);
|
||||||
if (!removedFromInventory) return;
|
|
||||||
|
|
||||||
EmitSignalWeaponEventAbilityRemoved(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,4 +90,12 @@ public partial class AbilitySelection : Control
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearAbilities()
|
||||||
|
{
|
||||||
|
foreach (var child in SelectedAbilities.GetChildren())
|
||||||
|
{
|
||||||
|
SelectedAbilities.RemoveChild(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
|
using Chickensoft.Sync.Primitives;
|
||||||
using Gamesmiths.Forge.Effects;
|
using Gamesmiths.Forge.Effects;
|
||||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||||
using Godot;
|
using Godot;
|
||||||
@@ -9,7 +11,7 @@ using Movementtests.systems;
|
|||||||
|
|
||||||
|
|
||||||
[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png"), Meta(typeof(IAutoNode))]
|
[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);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
@@ -27,6 +29,10 @@ public partial class InventoryUi : Control
|
|||||||
public required AbilitySelection StoppedFlying { get; set; }
|
public required AbilitySelection StoppedFlying { get; set; }
|
||||||
#endregion Nodes
|
#endregion Nodes
|
||||||
|
|
||||||
|
public AutoSet<ForgeAbilityBehavior>.Binding StartedFlyingBinding { get; set; }
|
||||||
|
public AutoSet<ForgeAbilityBehavior>.Binding FlyingTickBinding { get; set; }
|
||||||
|
public AutoSet<ForgeAbilityBehavior>.Binding StoppedFlyingBinding { get; set; }
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
StartedFlying.AbilityAdded += AddAbilityForEvent;
|
StartedFlying.AbilityAdded += AddAbilityForEvent;
|
||||||
@@ -44,16 +50,34 @@ public partial class InventoryUi : Control
|
|||||||
WhileFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
|
WhileFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
|
||||||
StoppedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
|
StoppedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
|
||||||
|
|
||||||
InventoryManager.WeaponEventAbilityAdded += OnWeaponEventInventoryAdded;
|
StartedFlyingBinding = InventoryManager.StartedFlyingAbilities.Bind();
|
||||||
InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventInventoryRemoved;
|
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;
|
GC.SuppressFinalize(this);
|
||||||
InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventInventoryRemoved;
|
|
||||||
|
StartedFlying.Dispose();
|
||||||
|
WhileFlying.Dispose();
|
||||||
|
StoppedFlying.Dispose();
|
||||||
|
|
||||||
|
base.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||||
{
|
{
|
||||||
InventoryManager.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
|
InventoryManager.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
|
||||||
@@ -64,16 +88,22 @@ public partial class InventoryUi : Control
|
|||||||
InventoryManager.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
|
InventoryManager.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWeaponEventInventoryAdded(WeaponEventAbilityData data)
|
public void OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||||
{
|
{
|
||||||
var selection = GetAbilitySelection(data.ForEvent);
|
var selection = GetAbilitySelection(forEvent);
|
||||||
selection.AddSelectedAbility(data.Ability);
|
selection.AddSelectedAbility(abilityBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWeaponEventInventoryRemoved(WeaponEventAbilityData data)
|
public void OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||||
{
|
{
|
||||||
var selection = GetAbilitySelection(data.ForEvent);
|
var selection = GetAbilitySelection(forEvent);
|
||||||
selection.RemoveSelectedAbility(data.Ability);
|
selection.RemoveSelectedAbility(abilityBehavior);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent forEvent)
|
||||||
|
{
|
||||||
|
var selection = GetAbilitySelection(forEvent);
|
||||||
|
selection.ClearAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbilitySelection GetAbilitySelection(WeaponSystem.WeaponEvent forEvent)
|
public AbilitySelection GetAbilitySelection(WeaponSystem.WeaponEvent forEvent)
|
||||||
|
|||||||
@@ -8,5 +8,8 @@ extends OverlaidMenu
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if Engine.is_editor_hint(): return
|
if Engine.is_editor_hint(): return
|
||||||
|
|
||||||
|
func _handle_cancel_input() -> void:
|
||||||
|
hide_menu()
|
||||||
|
|
||||||
func _on_close_button_pressed() -> void:
|
func _on_close_button_pressed() -> void:
|
||||||
close()
|
hide_menu()
|
||||||
|
|||||||
@@ -343,15 +343,20 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
|||||||
{
|
{
|
||||||
foreach (var weaponEvent in Enum.GetValues<WeaponEvent>())
|
foreach (var weaponEvent in Enum.GetValues<WeaponEvent>())
|
||||||
{
|
{
|
||||||
var abilities = GetGrantedAbilities(weaponEvent);
|
RemoveAbilitiesForEvent(weaponEvent);
|
||||||
foreach (var ability in abilities.Values)
|
|
||||||
{
|
|
||||||
EffectsManager.RemoveEffect(ability);
|
|
||||||
}
|
|
||||||
abilities.Clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
public Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> GetGrantedAbilities(WeaponEvent forEvent)
|
||||||
{
|
{
|
||||||
var abilitiesMap = new Dictionary<WeaponEvent, Dictionary<ForgeAbilityBehavior, ActiveEffectHandle>>
|
var abilitiesMap = new Dictionary<WeaponEvent, Dictionary<ForgeAbilityBehavior, ActiveEffectHandle>>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
|
using Chickensoft.Sync.Primitives;
|
||||||
using Gamesmiths.Forge.Abilities;
|
using Gamesmiths.Forge.Abilities;
|
||||||
using Gamesmiths.Forge.Attributes;
|
using Gamesmiths.Forge.Attributes;
|
||||||
using Gamesmiths.Forge.Core;
|
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))]
|
[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);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
@@ -743,14 +744,45 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inventory changes signal binding
|
// Inventory changes signal binding
|
||||||
InventoryManager.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
StartedFlyingBinding = InventoryManager.StartedFlyingAbilities.Bind();
|
||||||
InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
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()
|
public void OnExitTree()
|
||||||
{
|
{
|
||||||
InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventAbilityAdded;
|
// InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventAbilityAdded;
|
||||||
InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventAbilityRemoved;
|
// InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventAbilityRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ extends Node
|
|||||||
@onready var inventory_layer: CanvasLayer = $"../InventoryLayer"
|
@onready var inventory_layer: CanvasLayer = $"../InventoryLayer"
|
||||||
@onready var player: PlayerController = $"../Player"
|
@onready var player: PlayerController = $"../Player"
|
||||||
|
|
||||||
|
var inventory: OverlaidMenu = null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
toolbox_action.triggered.connect(open_toolbox)
|
toolbox_action.triggered.connect(open_toolbox)
|
||||||
inventory_action.triggered.connect(open_inventory)
|
inventory_action.triggered.connect(open_inventory)
|
||||||
@@ -37,9 +39,11 @@ func open_toolbox() -> void:
|
|||||||
debug_layer.call_deferred("add_child", toolbox)
|
debug_layer.call_deferred("add_child", toolbox)
|
||||||
|
|
||||||
func open_inventory() -> void:
|
func open_inventory() -> void:
|
||||||
var inventory: Control = open_overlaid_menu(inventory_scene)
|
if inventory == null:
|
||||||
# inventory.player = player
|
inventory = open_overlaid_menu(inventory_scene)
|
||||||
inventory_layer.call_deferred("add_child", inventory)
|
inventory_layer.call_deferred("add_child", inventory)
|
||||||
|
return
|
||||||
|
inventory.show_menu()
|
||||||
|
|
||||||
func on_player_died() -> void:
|
func on_player_died() -> void:
|
||||||
var lost_menu: LevelLostMenu = open_overlaid_menu(lost_menu_scene)
|
var lost_menu: LevelLostMenu = open_overlaid_menu(lost_menu_scene)
|
||||||
|
|||||||
Reference in New Issue
Block a user