From ef454e9502ca76afbbbbafb6289ac8b31b3e88bc Mon Sep 17 00:00:00 2001 From: Minimata Date: Sat, 28 Mar 2026 18:20:47 +0100 Subject: [PATCH] Trying custom execution periodic data --- forge/ForgeManager.cs | 1 + forge/calculators/FlyingWeaponExecution.cs | 62 ++++--------------- scenes/enemies/Enemy.cs | 3 +- .../components/weapon/WeaponSystem.cs | 2 +- .../scripts/PlayerController.cs | 22 ++++++- 5 files changed, 36 insertions(+), 54 deletions(-) diff --git a/forge/ForgeManager.cs b/forge/ForgeManager.cs index 4f110673..85f207d5 100644 --- a/forge/ForgeManager.cs +++ b/forge/ForgeManager.cs @@ -11,6 +11,7 @@ public partial class ForgeManager : Node [ // entities "character.player", + "character.enemy", "weapon", // Statuses diff --git a/forge/calculators/FlyingWeaponExecution.cs b/forge/calculators/FlyingWeaponExecution.cs index 7226350f..8a595c5e 100644 --- a/forge/calculators/FlyingWeaponExecution.cs +++ b/forge/calculators/FlyingWeaponExecution.cs @@ -5,63 +5,25 @@ 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 : CustomExecution +public class FlyingWeaponExecution(WeaponSystem weaponSystem) : CustomExecution { - private readonly Node3D _comboSystem; - - public AttributeCaptureDefinition TargetHealth { get; } - public AttributeCaptureDefinition AttackerStrength { get; } - - public FlyingWeaponExecution() - { - - TargetHealth = new AttributeCaptureDefinition( - "CombatAttributeSet.CurrentHealth", - AttributeCaptureSource.Target, - Snapshot: false); - - AttackerStrength = new AttributeCaptureDefinition( - "StatAttributeSet.Strength", - AttributeCaptureSource.Source, - Snapshot: true); - - AttributesToCapture.Add(TargetHealth); - AttributesToCapture.Add(AttackerStrength); - - CustomCueParameters.Add("cues.combat.combo_count", 0); - CustomCueParameters.Add("cues.combat.combo_damage", 0f); - } - public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData) { - var results = new List(); - - int strength = CaptureAttributeMagnitude(AttackerStrength, effect, target, effectEvaluatedData); - int comboCount = 0; - - // Calculate combo damage - float baseDamage = strength * 0.8f; - float comboDamage = baseDamage * (1 + comboCount * 0.2f); - - // Apply health damage - if (TargetHealth.TryGetAttribute(target, out EntityAttribute? healthAttribute)) + GD.Print("Custom execution executed"); + weaponSystem.Events.Raise(new EventData { - results.Add(new ModifierEvaluatedData( - healthAttribute, - ModifierOperation.FlatBonus, - -comboDamage, // Negative for damage - channel: 0 - )); - } - - // Add combo to cue parameters - CustomCueParameters["cues.combat.combo_count"] = comboCount; - CustomCueParameters["cues.combat.combo_damage"] = comboDamage; - - return results.ToArray(); + EventTags = weaponSystem.WeaponFlyingTickTag.GetSingleTagContainer()!, + Source = weaponSystem, + EventMagnitude = 12f, + Payload = new WeaponFlyingPayload(Message: "flying") + }); + + return []; } } \ No newline at end of file diff --git a/scenes/enemies/Enemy.cs b/scenes/enemies/Enemy.cs index 9c8e9f5c..5aba01f8 100644 --- a/scenes/enemies/Enemy.cs +++ b/scenes/enemies/Enemy.cs @@ -90,8 +90,7 @@ public partial class Enemy : CharacterBody3D, var baseTags = new TagContainer( forgeManager.TagsManager, [ - Tag.RequestTag(forgeManager.TagsManager, "character.player"), - Tag.RequestTag(forgeManager.TagsManager, "class.warrior") + Tag.RequestTag(forgeManager.TagsManager, "character.enemy") ]); Attributes = new EntityAttributes(new EnemyAttributeSet()); diff --git a/scenes/player_controller/components/weapon/WeaponSystem.cs b/scenes/player_controller/components/weapon/WeaponSystem.cs index 04a3ba24..99829587 100644 --- a/scenes/player_controller/components/weapon/WeaponSystem.cs +++ b/scenes/player_controller/components/weapon/WeaponSystem.cs @@ -106,7 +106,7 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity FlyingState.StateEntered += FlyingStarted; FlyingState.StateExited += FlyingEnded; - WeaponFlyingTick.Timeout += RaiseWeaponFlyingTickEvent; + // WeaponFlyingTick.Timeout += RaiseWeaponFlyingTickEvent; } public void FlyingStarted() diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 3a3a10cf..abfbeb86 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Gamesmiths.Forge.Abilities; using Gamesmiths.Forge.Core; using Gamesmiths.Forge.Effects; +using Gamesmiths.Forge.Effects.Calculator; using Gamesmiths.Forge.Effects.Components; using Gamesmiths.Forge.Effects.Duration; using Gamesmiths.Forge.Effects.Magnitudes; @@ -22,6 +23,7 @@ using Movementtests.player_controller.Scripts; using Movementtests.scenes.player_controller.scripts; using Movementtests.tools; using Movementtests.forge.abilities; +using Movementtests.tools.calculators; using Movementtests.tools.effects; using RustyOptions; @@ -771,7 +773,18 @@ public partial class PlayerController : CharacterBody3D, ); EffectsManager.ApplyEffect(new Effect(flyingGrantEffect, new EffectOwnership(this, this))); - + + flyingWeaponEffect = new EffectData( + "Flying Weapon", + new DurationData(DurationType.Infinite), + customExecutions: + [ + new FlyingWeaponExecution(WeaponSystem) + ], + periodicData: new PeriodicData(new ScalableFloat(1f), false, PeriodInhibitionRemovedPolicy.ResetPeriod) + ); + flyingWeaponEffectHandle = EffectsManager.ApplyEffect(new Effect(flyingWeaponEffect, new EffectOwnership(this, this))); + flyingWeaponEffectHandle?.SetInhibit(true); } // Forge events var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponLeftTag, OnWeaponLeft); @@ -779,8 +792,13 @@ public partial class PlayerController : CharacterBody3D, var weaponLandedToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponLandTag, OnWeaponLanded); } + private EffectData flyingWeaponEffect; + private ActiveEffectHandle? flyingWeaponEffectHandle; + public void OnWeaponLeft(EventData data) { + //flyingWeaponEffectHandle?.SetInhibit(false); + var target = data.Target; var tagsManager = ForgeManager.GetTagsManager(this); @@ -791,6 +809,8 @@ public partial class PlayerController : CharacterBody3D, public void OnWeaponLanded(EventData data) { + flyingWeaponEffectHandle?.SetInhibit(true); + var source = data.Source; var target = data.Target; var magnitude = data.EventMagnitude;