Trying custom execution periodic data
This commit is contained in:
@@ -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<ModifierEvaluatedData>();
|
||||
|
||||
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<WeaponFlyingPayload>
|
||||
{
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user