From 7a787a36d6aa7f6e86413099bfa884a4b60ef3ef Mon Sep 17 00:00:00 2001 From: Minimata Date: Sat, 4 Apr 2026 12:06:48 +0200 Subject: [PATCH] Moved the exploding sword forge object from the code only hardcoded stuff to the resource based stuff --- .../ForgeEffectApplicationBehavior.cs | 42 +++++ .../ForgeEffectApplicationBehavior.cs.uid | 1 + .../abilities/ForgeExplodingSwordBehavior.cs | 59 +++++++ .../ForgeExplodingSwordBehavior.cs.uid | 1 + forge/abilities/RExplodingSword.cs | 95 ------------ forge/abilities/RExplodingSword.cs.uid | 1 - forge/calculators/FlyingWeaponExecution.cs | 30 ---- .../ForgeRaiseEventTagExecution.cs | 48 ++++++ ...uid => ForgeRaiseEventTagExecution.cs.uid} | 0 .../player_controller/PlayerController.tscn | 2 - .../components/weapon/WeaponSystem.cs | 144 ++++++------------ .../components/weapon/weapon.tscn | 5 + .../resources/forge/exploding_sword.tres | 8 + .../forge/exploding_sword_throw.tres | 10 -- .../forge/exploding_sword_weapon_flight.tres | 26 ++++ .../forge/exploding_sword_weapon_land.tres | 26 ++++ .../forge/exploding_sword_weapon_left.tres | 26 ++++ .../forge/inhibit_mana_regen_temporarily.tres | 4 +- .../forge/raise_flying_tick_event.tres | 12 ++ .../forge/weapon_flying_tick_ability.tres | 55 +++++++ .../resources/player_mana_regen.tres | 9 -- .../scripts/PlayerController.cs | 33 +--- 22 files changed, 365 insertions(+), 272 deletions(-) create mode 100644 forge/abilities/ForgeEffectApplicationBehavior.cs create mode 100644 forge/abilities/ForgeEffectApplicationBehavior.cs.uid create mode 100644 forge/abilities/ForgeExplodingSwordBehavior.cs create mode 100644 forge/abilities/ForgeExplodingSwordBehavior.cs.uid delete mode 100644 forge/abilities/RExplodingSword.cs delete mode 100644 forge/abilities/RExplodingSword.cs.uid delete mode 100644 forge/calculators/FlyingWeaponExecution.cs create mode 100644 forge/calculators/ForgeRaiseEventTagExecution.cs rename forge/calculators/{FlyingWeaponExecution.cs.uid => ForgeRaiseEventTagExecution.cs.uid} (100%) create mode 100644 scenes/player_controller/resources/forge/exploding_sword.tres delete mode 100644 scenes/player_controller/resources/forge/exploding_sword_throw.tres create mode 100644 scenes/player_controller/resources/forge/exploding_sword_weapon_flight.tres create mode 100644 scenes/player_controller/resources/forge/exploding_sword_weapon_land.tres create mode 100644 scenes/player_controller/resources/forge/exploding_sword_weapon_left.tres create mode 100644 scenes/player_controller/resources/forge/raise_flying_tick_event.tres create mode 100644 scenes/player_controller/resources/forge/weapon_flying_tick_ability.tres delete mode 100644 scenes/player_controller/resources/player_mana_regen.tres diff --git a/forge/abilities/ForgeEffectApplicationBehavior.cs b/forge/abilities/ForgeEffectApplicationBehavior.cs new file mode 100644 index 00000000..09c44b82 --- /dev/null +++ b/forge/abilities/ForgeEffectApplicationBehavior.cs @@ -0,0 +1,42 @@ +using Gamesmiths.Forge.Abilities; +using Gamesmiths.Forge.Core; +using Gamesmiths.Forge.Effects; +using Gamesmiths.Forge.Godot.Resources; +using Gamesmiths.Forge.Godot.Resources.Abilities; +using Godot; + +namespace Movementtests.forge.abilities; + + +public class EffectApplicationBehavior(EffectData effectData) : IAbilityBehavior +{ + private ActiveEffectHandle? _effectHandle; + public void OnStarted(AbilityBehaviorContext context) + { + GD.Print("This is applying the periodic effect to the flying weapon"); + _effectHandle = context.Owner.EffectsManager.ApplyEffect(new Effect(effectData, new EffectOwnership(context.Owner, context.Owner))); + context.AbilityHandle.CommitAbility(); + } + + public void OnEnded(AbilityBehaviorContext context) + { + GD.Print("This is removing the periodic effect from the flying weapon"); + if (_effectHandle is not null) + context.Owner.EffectsManager.RemoveEffect(_effectHandle); + context.InstanceHandle.End(); + } +} + +[Tool] +[GlobalClass] +public partial class ForgeEffectApplicationBehavior : ForgeAbilityBehavior +{ + [Export] public ForgeEffectData? EffectData { get; set; } + + public override IAbilityBehavior GetBehavior() + { + if (EffectData == null) + throw new System.ArgumentException("EffectData is null"); + return new EffectApplicationBehavior(EffectData.GetEffectData()); + } +} \ No newline at end of file diff --git a/forge/abilities/ForgeEffectApplicationBehavior.cs.uid b/forge/abilities/ForgeEffectApplicationBehavior.cs.uid new file mode 100644 index 00000000..705d61a8 --- /dev/null +++ b/forge/abilities/ForgeEffectApplicationBehavior.cs.uid @@ -0,0 +1 @@ +uid://cl5hudinl1rex diff --git a/forge/abilities/ForgeExplodingSwordBehavior.cs b/forge/abilities/ForgeExplodingSwordBehavior.cs new file mode 100644 index 00000000..e9fa4e25 --- /dev/null +++ b/forge/abilities/ForgeExplodingSwordBehavior.cs @@ -0,0 +1,59 @@ +using Gamesmiths.Forge.Abilities; +using Gamesmiths.Forge.Core; +using Gamesmiths.Forge.Godot.Nodes; +using Gamesmiths.Forge.Godot.Resources.Abilities; +using Godot; + +namespace Movementtests.forge.abilities; + +public class ExplodingSwordBehavior(PackedScene explosion) : IAbilityBehavior +{ + public void OnStarted(AbilityBehaviorContext context) + { + if (context.Owner is not Node3D owner) + { + context.InstanceHandle.End(); + return; + } + + if (explosion.Instantiate() is not Explosion explosion1) + { + GD.Print("Cannot instantiate"); + context.InstanceHandle.End(); + return; + } + if (!owner.IsInsideTree()) + { + GD.Print("Not inside tree"); + context.InstanceHandle.End(); + return; + } + + GD.Print("EXPLOSION"); + + explosion1.Radius = 6f; + + owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explosion1); + explosion1.CallDeferred(Node3D.MethodName.SetGlobalPosition, owner.GlobalPosition); + + context.AbilityHandle.CommitAbility(); + context.InstanceHandle.End(); + } + + public void OnEnded(AbilityBehaviorContext context) + { + } +} + +[Tool] +[GlobalClass] +public partial class ForgeExplodingSwordBehavior : ForgeAbilityBehavior +{ + [Export] public PackedScene? Explosion { get; set; } + public override IAbilityBehavior GetBehavior() + { + if (Explosion == null) + throw new System.ArgumentException("Explosion is null"); + return new ExplodingSwordBehavior(Explosion); + } +} \ No newline at end of file diff --git a/forge/abilities/ForgeExplodingSwordBehavior.cs.uid b/forge/abilities/ForgeExplodingSwordBehavior.cs.uid new file mode 100644 index 00000000..90346fe0 --- /dev/null +++ b/forge/abilities/ForgeExplodingSwordBehavior.cs.uid @@ -0,0 +1 @@ +uid://bnee6amtc2bhj diff --git a/forge/abilities/RExplodingSword.cs b/forge/abilities/RExplodingSword.cs deleted file mode 100644 index a0f776d9..00000000 --- a/forge/abilities/RExplodingSword.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using Gamesmiths.Forge.Abilities; -using Gamesmiths.Forge.Core; -using Gamesmiths.Forge.Cues; -using Gamesmiths.Forge.Effects; -using Gamesmiths.Forge.Effects.Components; -using Gamesmiths.Forge.Effects.Duration; -using Gamesmiths.Forge.Effects.Magnitudes; -using Gamesmiths.Forge.Effects.Modifiers; -using Gamesmiths.Forge.Tags; -using Godot; -using Movementtests.interfaces; -using Movementtests.systems; - -namespace Movementtests.forge.abilities; - -public record struct ExplodingSwordCreation(Node3D Owner); - -[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_projectile.png")] -public partial class RExplodingSword(PackedScene? explosion) : Resource, IAbilityBase -{ - [Export] public PackedScene? Explosion { get; set; } = explosion; - - public RExplodingSword() : this(null) {} - - public AbilityData Ability(ExplodingSwordCreation creationData, TagContainer? tags) - { - return new AbilityData( - name: "Exploding Sword Throw", - abilityTags: tags, - instancingPolicy: AbilityInstancingPolicy.PerEntity, - behaviorFactory: () => new ExplodingSwordThrowBehavior(creationData.Owner, Explosion)); - } - - public IAbilityBehavior Behavior(ExplodingSwordCreation creationData) - { - return new ExplodingSwordThrowBehavior(creationData.Owner, Explosion); - } -} - -public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) : IAbilityBehavior -{ - private Node3D _owner = owner; - private PackedScene? _explosion = explosion; - public void OnStarted(AbilityBehaviorContext context, TPayload payload) - { - if (_explosion?.Instantiate() is not Explosion explosion) - { - GD.Print("Cannot instantiate"); - context.InstanceHandle.End(); - return; - } - if (!_owner.IsInsideTree()) - { - GD.Print("Not inside tree"); - context.InstanceHandle.End(); - return; - } - - GD.Print("EXPLOSION"); - - explosion.Radius = 6f; - - _owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explosion); - explosion.CallDeferred(Node3D.MethodName.SetGlobalPosition, _owner.GlobalPosition); - - context.AbilityHandle.CommitAbility(); - context.InstanceHandle.End(); - } - - public void OnEnded(AbilityBehaviorContext context) - { - } -} - - - -public class FlyingSwordBehavior(IForgeEntity owner, EffectData effectData) : IAbilityBehavior -{ - private ActiveEffectHandle? _effectHandle; - public void OnStarted(AbilityBehaviorContext context) - { - GD.Print("This is applying the periodic effect to the flying weapon"); - _effectHandle = owner.EffectsManager.ApplyEffect(new Effect(effectData, new EffectOwnership(owner, owner))); - context.AbilityHandle.CommitAbility(); - } - - public void OnEnded(AbilityBehaviorContext context) - { - GD.Print("This is removing the periodic effect from the flying weapon"); - if (_effectHandle is not null) - owner.EffectsManager.RemoveEffect(_effectHandle); - context.InstanceHandle.End(); - } -} diff --git a/forge/abilities/RExplodingSword.cs.uid b/forge/abilities/RExplodingSword.cs.uid deleted file mode 100644 index 58097a30..00000000 --- a/forge/abilities/RExplodingSword.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://rux15j7q78e8 diff --git a/forge/calculators/FlyingWeaponExecution.cs b/forge/calculators/FlyingWeaponExecution.cs deleted file mode 100644 index 21f7e808..00000000 --- a/forge/calculators/FlyingWeaponExecution.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using Gamesmiths.Forge.Attributes; -using Gamesmiths.Forge.Core; -using Gamesmiths.Forge.Effects; -using Gamesmiths.Forge.Effects.Calculator; -using Gamesmiths.Forge.Effects.Magnitudes; -using Gamesmiths.Forge.Effects.Modifiers; -using Gamesmiths.Forge.Events; -using Godot; -using Movementtests.systems; - -namespace Movementtests.tools.calculators; - - -public class FlyingWeaponExecution(WeaponSystem weaponSystem) : CustomExecution -{ - public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData) - { - GD.Print("Custom execution executed"); - weaponSystem.Events.Raise(new EventData - { - EventTags = weaponSystem.WeaponFlyingTickEventTag.GetSingleTagContainer()!, - Source = weaponSystem, - EventMagnitude = 12f, - Payload = new WeaponEventPayload(Message: "flying") - }); - - return []; - } -} \ No newline at end of file diff --git a/forge/calculators/ForgeRaiseEventTagExecution.cs b/forge/calculators/ForgeRaiseEventTagExecution.cs new file mode 100644 index 00000000..274e9965 --- /dev/null +++ b/forge/calculators/ForgeRaiseEventTagExecution.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using Gamesmiths.Forge.Attributes; +using Gamesmiths.Forge.Core; +using Gamesmiths.Forge.Effects; +using Gamesmiths.Forge.Effects.Calculator; +using Gamesmiths.Forge.Effects.Magnitudes; +using Gamesmiths.Forge.Effects.Modifiers; +using Gamesmiths.Forge.Events; +using Gamesmiths.Forge.Godot.Resources; +using Gamesmiths.Forge.Godot.Resources.Calculators; +using Gamesmiths.Forge.Tags; +using Godot; +using Movementtests.systems; + +namespace Movementtests.tools.calculators; + + +public class FlyingWeaponExecution(TagContainer eventTags) : CustomExecution +{ + public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData) + { + GD.Print("Custom execution executed"); + var owner = effect.Ownership.Owner; + if (owner == null) return []; + + owner.Events.Raise(new EventData + { + EventTags = eventTags, + Source = owner, + EventMagnitude = 12f + }); + + return []; + } +} + + +[GlobalClass] +public partial class ForgeRaiseEventTagExecution : ForgeCustomExecution +{ + [Export] ForgeTagContainer EventTags { get; set; } = new(); + + public override CustomExecution GetExecutionClass() + { + return new FlyingWeaponExecution(EventTags.GetTagContainer()); + } +} \ No newline at end of file diff --git a/forge/calculators/FlyingWeaponExecution.cs.uid b/forge/calculators/ForgeRaiseEventTagExecution.cs.uid similarity index 100% rename from forge/calculators/FlyingWeaponExecution.cs.uid rename to forge/calculators/ForgeRaiseEventTagExecution.cs.uid diff --git a/scenes/player_controller/PlayerController.tscn b/scenes/player_controller/PlayerController.tscn index 2708b52a..abdad6bd 100644 --- a/scenes/player_controller/PlayerController.tscn +++ b/scenes/player_controller/PlayerController.tscn @@ -6,7 +6,6 @@ [ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://scenes/components/knockback/RKnockback.cs" id="3_cb2lu"] [ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://inputs/base_mode/base_mode.tres" id="3_cresl"] [ext_resource type="PackedScene" uid="uid://c4ikbhojckpnc" path="res://scenes/components/health/CHealth.tscn" id="3_q7bng"] -[ext_resource type="Resource" uid="uid://cdxbwirfiaipi" path="res://scenes/player_controller/resources/forge/exploding_sword_throw.tres" id="4_11013"] [ext_resource type="Script" uid="uid://baiapod3csndf" path="res://scenes/components/health/RHealth.cs" id="4_abfq8"] [ext_resource type="Resource" uid="uid://bjyd801wvverk" path="res://scenes/player_controller/resources/player_health.tres" id="4_m8gvy"] [ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://inputs/base_mode/rotate_y.tres" id="4_rxwoh"] @@ -151,7 +150,6 @@ collision_mask = 272 script = ExtResource("1_poq2x") EmpoweredActionUsed = SubResource("Resource_5gbhg") EmpoweredActionAbility = ExtResource("10_2rkt1") -AbilityLoadout = [ExtResource("4_11013")] DefaultPermanentEffects = [ExtResource("5_2rkt1")] EmpoweredActionEffects = [ExtResource("6_u8yay")] AimAssistStrength = 0.3 diff --git a/scenes/player_controller/components/weapon/WeaponSystem.cs b/scenes/player_controller/components/weapon/WeaponSystem.cs index a388686a..4cbda2b5 100644 --- a/scenes/player_controller/components/weapon/WeaponSystem.cs +++ b/scenes/player_controller/components/weapon/WeaponSystem.cs @@ -13,6 +13,7 @@ using Gamesmiths.Forge.Events; using Gamesmiths.Forge.Godot.Core; using Gamesmiths.Forge.Godot.Nodes; using Gamesmiths.Forge.Godot.Resources; +using Gamesmiths.Forge.Godot.Resources.Abilities; using Gamesmiths.Forge.Tags; using Godot; using GodotStateCharts; @@ -26,20 +27,6 @@ using Movementtests.tools.calculators; namespace Movementtests.systems; -public record struct WeaponEventPayload(String Message); - - -public class ClosureBehavior( - Action callback) : IAbilityBehavior -{ - public void OnStarted(AbilityBehaviorContext context, TPayload data) - { - callback(context, data); - context.InstanceHandle.End(); - } - - public void OnEnded(AbilityBehaviorContext context){} -} [GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_sword.png")] public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity @@ -50,9 +37,10 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity [Signal] public delegate void WeaponRetrievedEventHandler(); - [Export] public ForgeTagContainer BaseTags { get; set; } = new(); + [Export] public ForgeAbilityData[] WeaponAbilities { get; set; } = Array.Empty(); + [Export] public ForgeAbilityData FlyingTickAbility { get; set; } = new(); [Export] public RDamage RDamage { get; set; } @@ -107,6 +95,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity public Tag WeaponFlyingAbilityTag; + private AbilityHandle? _weaponFlyingAbility; + public void Init() { _weaponState = StateChart.Of(GetNode("StateChart")); @@ -171,7 +161,27 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity Abilities = new(this); Events = new(); - CreateFlyingAbility(); + // TODO: Waiting on bug resolve + // _weaponFlyingAbility = Abilities.GrantAbilityPermanently(FlyingTickAbility.GetAbilityData(), 1, LevelComparison.None, this); + + foreach (var ability in WeaponAbilities) + { + var leftGrantAbilityConfig = new GrantAbilityConfig( + ability.GetAbilityData(), + ScalableLevel: new ScalableInt(1), + RemovalPolicy: AbilityDeactivationPolicy.CancelImmediately, + InhibitionPolicy: AbilityDeactivationPolicy.CancelImmediately, + TryActivateOnGrant: false, + TryActivateOnEnable: false, + LevelOverridePolicy: LevelComparison.Higher); + + var leftGrantComponent = new GrantAbilityEffectComponent([leftGrantAbilityConfig]); + var leftGrantEffect = new EffectData( + "Grant Weapon Ability", + new DurationData(DurationType.Infinite), + effectComponents: [leftGrantComponent]); + EffectsManager.ApplyEffect(new Effect(leftGrantEffect, new EffectOwnership(this, this))); + } BodyEntered += OnThrownWeaponReachesGround; @@ -180,136 +190,76 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity _handToFlying.Taken += () => { - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponHandToFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "handToFlying") + Source = this }); - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponStartedFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "startedFlying") + Source = this }); }; _flyingToHand.Taken += () => { - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponFlyingToHandEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "flyingToHand") + Source = this }); - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponStoppedFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "stoppedFlying") + Source = this }); }; _plantedToHand.Taken += () => { - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponPlantedToHandEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "plantedToHand") + Source = this }); }; _plantedToFlying.Taken += () => { - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponPlantedToFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "plantedToFlying") + Source = this }); - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponStartedFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "startedFlying") + Source = this }); }; _toPlanted.Taken += () => { - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponPlantedEventTag.GetSingleTagContainer()!, Source = this, - Target = _plantedEntity, - Payload = new WeaponEventPayload(Message: "planted") + Target = _plantedEntity }); - Events.Raise(new EventData + Events.Raise(new EventData { EventTags = WeaponStoppedFlyingEventTag.GetSingleTagContainer()!, - Source = this, - Payload = new WeaponEventPayload(Message: "stoppedFlying") + Source = this }); }; - Events.Subscribe(WeaponStoppedFlyingEventTag, data => + Events.Subscribe(WeaponStoppedFlyingEventTag, data => { - _weaponFlyingAbility.Cancel(); + // TODO: Waiting on bug resolve + // _weaponFlyingAbility.Cancel(); }); } - private ActiveEffectHandle? _flyingWeaponEffectHandle; - - public void CreateFlyingAbility() - { - var flyingWeaponEffectData = new EffectData( - "Flying Weapon Effect Data", - new DurationData(DurationType.Infinite), - customExecutions: - [ - new FlyingWeaponExecution(this) - ], - periodicData: new PeriodicData(new ScalableFloat(0.2f), false, PeriodInhibitionRemovedPolicy.ResetPeriod) - ); - - var weaponHandToFlyingAbilityData = new AbilityData( - name: "WeaponHandToFlyingSword", - abilityTags: WeaponFlyingAbilityTag.GetSingleTagContainer(), - instancingPolicy: AbilityInstancingPolicy.PerEntity, - abilityTriggerData: AbilityTriggerData.ForEvent(WeaponStartedFlyingEventTag), - behaviorFactory: () => new FlyingSwordBehavior(this, flyingWeaponEffectData)); - _weaponFlyingAbility = Abilities.GrantAbilityPermanently(weaponHandToFlyingAbilityData, 1, LevelComparison.None, this); - } - - private AbilityHandle _weaponFlyingAbility; - - public void GrantNewAbilityForWeaponFly(RExplodingSword ability) - { - var weaponFlyingAbilityData = new AbilityData( - name: "WeaponFlyingSwordAbility", - abilityTags: WeaponFlyingAbilityTag.GetSingleTagContainer(), - instancingPolicy: AbilityInstancingPolicy.PerEntity, - abilityTriggerData: AbilityTriggerData.ForEvent(WeaponFlyingTickEventTag), - behaviorFactory: () => ability.Behavior(new ExplodingSwordCreation(this))); - - var weaponFlyGrantAbilityConfig = new GrantAbilityConfig( - weaponFlyingAbilityData, - ScalableLevel: new ScalableInt(1), - RemovalPolicy: AbilityDeactivationPolicy.CancelImmediately, - InhibitionPolicy: AbilityDeactivationPolicy.CancelImmediately, - TryActivateOnGrant: false, - TryActivateOnEnable: false, - LevelOverridePolicy: LevelComparison.Higher); - - var weaponFlyGrantComponent = new GrantAbilityEffectComponent([weaponFlyGrantAbilityConfig]); - var weaponFlyGrantEffect = new EffectData( - "Grant Weapon Fly Ability", - new DurationData(DurationType.Infinite), - effectComponents: [weaponFlyGrantComponent]); - EffectsManager.ApplyEffect(new Effect(weaponFlyGrantEffect, new EffectOwnership(this, this))); - - GD.Print("New weapon flight ability granted"); - } public void WeaponLeft() { diff --git a/scenes/player_controller/components/weapon/weapon.tscn b/scenes/player_controller/components/weapon/weapon.tscn index d9a175b4..8b63e764 100644 --- a/scenes/player_controller/components/weapon/weapon.tscn +++ b/scenes/player_controller/components/weapon/weapon.tscn @@ -2,9 +2,12 @@ [ext_resource type="Script" uid="uid://iii3wfto4t5b" path="res://scenes/player_controller/components/weapon/WeaponSystem.cs" id="1_csqwk"] [ext_resource type="Script" uid="uid://jitubgv6judn" path="res://scenes/components/damage/RDamage.cs" id="2_m0v1h"] +[ext_resource type="Resource" uid="uid://cu0685gspk2fk" path="res://scenes/player_controller/resources/forge/exploding_sword_weapon_land.tres" id="2_pgbtr"] [ext_resource type="Script" uid="uid://cxihb42t2mfqi" path="res://addons/forge/nodes/ForgeAttributeSet.cs" id="3_3xjpi"] [ext_resource type="Script" uid="uid://couw105c3bde4" path="res://addons/godot_state_charts/state_chart.gd" id="3_5owyf"] +[ext_resource type="Resource" uid="uid://busdbvfi3jiic" path="res://scenes/player_controller/resources/forge/exploding_sword_weapon_left.tres" id="3_7bruw"] [ext_resource type="ArrayMesh" uid="uid://cho5fixitrbds" path="res://assets/meshes/swords/resources/sword23.tres" id="3_svc06"] +[ext_resource type="Resource" uid="uid://btnnpqann3ktp" path="res://scenes/player_controller/resources/forge/weapon_flying_tick_ability.tres" id="4_7bruw"] [ext_resource type="Script" uid="uid://ccovd5i0wr3kk" path="res://addons/forge/editor/attributes/AttributeValues.cs" id="4_q6xv7"] [ext_resource type="Script" uid="uid://jk2jm1g6q853" path="res://addons/godot_state_charts/compound_state.gd" id="4_svc06"] [ext_resource type="Script" uid="uid://cytafq8i1y8qm" path="res://addons/godot_state_charts/atomic_state.gd" id="5_m0v1h"] @@ -56,6 +59,8 @@ continuous_cd = true contact_monitor = true max_contacts_reported = 1 script = ExtResource("1_csqwk") +WeaponAbilities = [ExtResource("2_pgbtr"), ExtResource("3_7bruw")] +FlyingTickAbility = ExtResource("4_7bruw") RDamage = SubResource("Resource_jpdh0") [node name="WeaponAttributeSet" type="Node" parent="." unique_id=14845649] diff --git a/scenes/player_controller/resources/forge/exploding_sword.tres b/scenes/player_controller/resources/forge/exploding_sword.tres new file mode 100644 index 00000000..0ec6d9df --- /dev/null +++ b/scenes/player_controller/resources/forge/exploding_sword.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="ForgeExplodingSwordBehavior" format=3 uid="uid://ifeavnlps7hy"] + +[ext_resource type="PackedScene" uid="uid://duju3atqgltkg" path="res://scenes/explosion/explosion.tscn" id="1_mnals"] +[ext_resource type="Script" uid="uid://bnee6amtc2bhj" path="res://forge/abilities/ForgeExplodingSwordBehavior.cs" id="1_ot53g"] + +[resource] +script = ExtResource("1_ot53g") +Explosion = ExtResource("1_mnals") diff --git a/scenes/player_controller/resources/forge/exploding_sword_throw.tres b/scenes/player_controller/resources/forge/exploding_sword_throw.tres deleted file mode 100644 index 9632548b..00000000 --- a/scenes/player_controller/resources/forge/exploding_sword_throw.tres +++ /dev/null @@ -1,10 +0,0 @@ -[gd_resource type="Resource" script_class="RExplodingSword" format=3 uid="uid://cdxbwirfiaipi"] - -[ext_resource type="PackedScene" uid="uid://duju3atqgltkg" path="res://scenes/explosion/explosion.tscn" id="1_aru71"] -[ext_resource type="Script" path="res://forge/abilities/RExplodingSword.cs" id="2_syk3q"] - -[resource] -script = ExtResource("2_syk3q") -Explosion = ExtResource("1_aru71") -Cost = 10.0 -metadata/_custom_type_script = "uid://rux15j7q78e8" diff --git a/scenes/player_controller/resources/forge/exploding_sword_weapon_flight.tres b/scenes/player_controller/resources/forge/exploding_sword_weapon_flight.tres new file mode 100644 index 00000000..3ae9b953 --- /dev/null +++ b/scenes/player_controller/resources/forge/exploding_sword_weapon_flight.tres @@ -0,0 +1,26 @@ +[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://bl0mng4kl1xy8"] + +[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://scenes/player_controller/resources/forge/exploding_sword.tres" id="1_postf"] +[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="2_km5rh"] +[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="3_spdwn"] +[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="4_cm86c"] + +[sub_resource type="Resource" id="Resource_ixeut"] +script = ExtResource("2_km5rh") +ContainerTags = Array[String](["abilities.weapon.land"]) +metadata/_custom_type_script = "uid://cw525n4mjqgw0" + +[sub_resource type="Resource" id="Resource_6c3kr"] +script = ExtResource("3_spdwn") +Tag = "events.weapon.flyingtick" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[resource] +script = ExtResource("4_cm86c") +Name = "Exploding Sword on Weapon Flight" +CooldownEffects = [] +AbilityBehavior = ExtResource("1_postf") +TriggerSource = 1 +TriggerTag = SubResource("Resource_6c3kr") +AbilityTags = SubResource("Resource_ixeut") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" diff --git a/scenes/player_controller/resources/forge/exploding_sword_weapon_land.tres b/scenes/player_controller/resources/forge/exploding_sword_weapon_land.tres new file mode 100644 index 00000000..6d05f094 --- /dev/null +++ b/scenes/player_controller/resources/forge/exploding_sword_weapon_land.tres @@ -0,0 +1,26 @@ +[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://cu0685gspk2fk"] + +[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://scenes/player_controller/resources/forge/exploding_sword.tres" id="1_l4v7e"] +[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="2_6c3kr"] +[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="2_l4v7e"] +[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="3_ixeut"] + +[sub_resource type="Resource" id="Resource_ixeut"] +script = ExtResource("2_6c3kr") +ContainerTags = Array[String](["abilities.weapon.land"]) +metadata/_custom_type_script = "uid://cw525n4mjqgw0" + +[sub_resource type="Resource" id="Resource_6c3kr"] +script = ExtResource("2_l4v7e") +Tag = "events.weapon.stoppedflying" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[resource] +script = ExtResource("3_ixeut") +Name = "Exploding Sword on Weapon Land" +CooldownEffects = [] +AbilityBehavior = ExtResource("1_l4v7e") +TriggerSource = 1 +TriggerTag = SubResource("Resource_6c3kr") +AbilityTags = SubResource("Resource_ixeut") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" diff --git a/scenes/player_controller/resources/forge/exploding_sword_weapon_left.tres b/scenes/player_controller/resources/forge/exploding_sword_weapon_left.tres new file mode 100644 index 00000000..892f838a --- /dev/null +++ b/scenes/player_controller/resources/forge/exploding_sword_weapon_left.tres @@ -0,0 +1,26 @@ +[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://busdbvfi3jiic"] + +[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="1_85dnt"] +[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://scenes/player_controller/resources/forge/exploding_sword.tres" id="1_m0rkb"] +[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="2_u5iw7"] +[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="3_u5iw7"] + +[sub_resource type="Resource" id="Resource_cjh4j"] +script = ExtResource("2_u5iw7") +ContainerTags = Array[String](["abilities.weapon.left"]) +metadata/_custom_type_script = "uid://cw525n4mjqgw0" + +[sub_resource type="Resource" id="Resource_mtsda"] +script = ExtResource("3_u5iw7") +Tag = "events.weapon.startedflying" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[resource] +script = ExtResource("1_85dnt") +Name = "Exploding Sword on Weapon Left" +CooldownEffects = [] +AbilityBehavior = ExtResource("1_m0rkb") +TriggerSource = 1 +TriggerTag = SubResource("Resource_mtsda") +AbilityTags = SubResource("Resource_cjh4j") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" diff --git a/scenes/player_controller/resources/forge/inhibit_mana_regen_temporarily.tres b/scenes/player_controller/resources/forge/inhibit_mana_regen_temporarily.tres index 28c6323d..7af5f2cd 100644 --- a/scenes/player_controller/resources/forge/inhibit_mana_regen_temporarily.tres +++ b/scenes/player_controller/resources/forge/inhibit_mana_regen_temporarily.tres @@ -66,10 +66,10 @@ script = ExtResource("2_scapu") Name = "Inhibit Player Mana Regen Temp" Modifiers = [] Components = Array[Object]([SubResource("Resource_bi1d8")]) -Executions = null +Executions = [] DurationType = 2 Duration = SubResource("Resource_exi3e") StackLimit = SubResource("Resource_ijayu") InitialStack = SubResource("Resource_1go02") -Cues = null +Cues = [] metadata/_custom_type_script = "uid://b83hf13nj37k3" diff --git a/scenes/player_controller/resources/forge/raise_flying_tick_event.tres b/scenes/player_controller/resources/forge/raise_flying_tick_event.tres new file mode 100644 index 00000000..15c43f29 --- /dev/null +++ b/scenes/player_controller/resources/forge/raise_flying_tick_event.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="ForgeRaiseEventTagExecution" format=3 uid="uid://oe2suroa1klj"] + +[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_iqjlm"] +[ext_resource type="Script" path="res://forge/calculators/ForgeRaiseEventTagExecution.cs" id="2_am2ak"] + +[sub_resource type="Resource" id="Resource_sxbq4"] +script = ExtResource("1_iqjlm") +ContainerTags = Array[String](["events.weapon.flyingtick"]) + +[resource] +script = ExtResource("2_am2ak") +metadata/_custom_type_script = "uid://br7ut4lbau66w" diff --git a/scenes/player_controller/resources/forge/weapon_flying_tick_ability.tres b/scenes/player_controller/resources/forge/weapon_flying_tick_ability.tres new file mode 100644 index 00000000..7600ff35 --- /dev/null +++ b/scenes/player_controller/resources/forge/weapon_flying_tick_ability.tres @@ -0,0 +1,55 @@ +[gd_resource type="Resource" script_class="ForgeAbilityData" format=3 uid="uid://btnnpqann3ktp"] + +[ext_resource type="Resource" uid="uid://oe2suroa1klj" path="res://scenes/player_controller/resources/forge/raise_flying_tick_event.tres" id="1_pdt6v"] +[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="1_vh0wp"] +[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="2_xkoyb"] +[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="3_j2gem"] +[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="4_e2sm2"] +[ext_resource type="Script" uid="uid://cl5hudinl1rex" path="res://forge/abilities/ForgeEffectApplicationBehavior.cs" id="5_trglf"] +[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="6_napws"] + +[sub_resource type="Resource" id="Resource_dgkld"] +script = ExtResource("2_xkoyb") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_1ften"] +script = ExtResource("3_j2gem") +BaseValue = 0.2 +metadata/_custom_type_script = "uid://cn3b4ya15fg7e" + +[sub_resource type="Resource" id="Resource_l278c"] +script = ExtResource("2_xkoyb") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_esyoj"] +script = ExtResource("4_e2sm2") +Modifiers = null +Components = null +Executions = Array[Object]([ExtResource("1_pdt6v")]) +DurationType = 1 +HasPeriodicApplication = true +Period = SubResource("Resource_1ften") +ExecuteOnApplication = true +StackLimit = SubResource("Resource_l278c") +InitialStack = SubResource("Resource_dgkld") +Cues = null +metadata/_custom_type_script = "uid://b83hf13nj37k3" + +[sub_resource type="Resource" id="Resource_0xegy"] +script = ExtResource("5_trglf") +EffectData = SubResource("Resource_esyoj") +metadata/_custom_type_script = "uid://cl5hudinl1rex" + +[sub_resource type="Resource" id="Resource_4aw8y"] +script = ExtResource("6_napws") +Tag = "events.weapon.startedflying" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[resource] +script = ExtResource("1_vh0wp") +Name = "Weapon Flying Tick" +CooldownEffects = null +AbilityBehavior = SubResource("Resource_0xegy") +TriggerSource = 1 +TriggerTag = SubResource("Resource_4aw8y") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" diff --git a/scenes/player_controller/resources/player_mana_regen.tres b/scenes/player_controller/resources/player_mana_regen.tres deleted file mode 100644 index 81c1a290..00000000 --- a/scenes/player_controller/resources/player_mana_regen.tres +++ /dev/null @@ -1,9 +0,0 @@ -[gd_resource type="Resource" script_class="RManaRegen" format=3 uid="uid://dtmhtlix2amme"] - -[ext_resource type="Script" uid="uid://di04jvuqp0h7m" path="res://forge/effects/RManaRegen.cs" id="1_ecb1p"] - -[resource] -script = ExtResource("1_ecb1p") -ManaRegenRate = 20.0 -Frequency = 0.05 -metadata/_custom_type_script = "uid://di04jvuqp0h7m" diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index c15f7452..8f209f83 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -122,7 +122,7 @@ public partial class PlayerController : CharacterBody3D, [Export] public ForgeAbilityData EmpoweredActionAbility = null!; [Export] public ForgeAbilityData[] DefaultPermanentAbilities = []; [ExportSubgroup("WeaponThrow")] - [Export] public RExplodingSword[] AbilityLoadout = []; + [Export] public ForgeAbilityData[] AbilityLoadout = []; [ExportGroup("Effects")] [ExportSubgroup("Common and defaults")] @@ -747,9 +747,8 @@ public partial class PlayerController : CharacterBody3D, foreach (var weaponLandAbility in AbilityLoadout) { - var weaponLeftTag = Tag.RequestTag(tagsManager,"abilities.weapon.left").GetSingleTagContainer(); var leftGrantAbilityConfig = new GrantAbilityConfig( - weaponLandAbility.Ability(new ExplodingSwordCreation(WeaponSystem), weaponLeftTag), + weaponLandAbility.GetAbilityData(), ScalableLevel: new ScalableInt(1), RemovalPolicy: AbilityDeactivationPolicy.CancelImmediately, InhibitionPolicy: AbilityDeactivationPolicy.CancelImmediately, @@ -763,32 +762,14 @@ public partial class PlayerController : CharacterBody3D, new DurationData(DurationType.Infinite), effectComponents: [leftGrantComponent]); EffectsManager.ApplyEffect(new Effect(leftGrantEffect, new EffectOwnership(this, this))); - - var weaponLandedTag = Tag.RequestTag(tagsManager, "abilities.weapon.land").GetSingleTagContainer(); - var landGrantAbilityConfig = new GrantAbilityConfig( - weaponLandAbility.Ability(new ExplodingSwordCreation(WeaponSystem), weaponLandedTag), - ScalableLevel: new ScalableInt(1), - RemovalPolicy: AbilityDeactivationPolicy.CancelImmediately, - InhibitionPolicy: AbilityDeactivationPolicy.CancelImmediately, - TryActivateOnGrant: false, - TryActivateOnEnable: false, - LevelOverridePolicy: LevelComparison.Higher); - - var landGrantComponent = new GrantAbilityEffectComponent([landGrantAbilityConfig]); - var landGrantEffect = new EffectData( - "Grant Weapon Land Ability", - new DurationData(DurationType.Infinite), - effectComponents: [landGrantComponent]); - EffectsManager.ApplyEffect(new Effect(landGrantEffect, new EffectOwnership(this, this))); - - GetTree().CreateTimer(5).Timeout += () => WeaponSystem.GrantNewAbilityForWeaponFly(weaponLandAbility); } + // GetTree().CreateTimer(5).Timeout += () => WeaponSystem.GrantNewAbilityForWeaponFly(weaponLandAbility); // Forge events - var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStartedFlyingEventTag, OnWeaponLeft); - var weaponLandedToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStoppedFlyingEventTag, OnWeaponLanded); + var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStartedFlyingEventTag, OnWeaponLeft); + var weaponLandedToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStoppedFlyingEventTag, OnWeaponLanded); } - public void OnWeaponLeft(EventData data) + public void OnWeaponLeft(EventData data) { var target = data.Target; @@ -798,7 +779,7 @@ public partial class PlayerController : CharacterBody3D, Abilities.TryActivateAbilitiesByTag(weaponLeftTag, target, out var landedFailures); } - public void OnWeaponLanded(EventData data) + public void OnWeaponLanded(EventData data) { var source = data.Source; var target = data.Target;