WIP: integrating forge systems into the game, now trying periodic abilities
This commit is contained in:
@@ -18,10 +18,14 @@ public partial class ForgeManager : Node
|
||||
|
||||
// Abilities
|
||||
"abilities.weapon.land",
|
||||
"abilities.weapon.flying",
|
||||
"abilities.weapon.left",
|
||||
|
||||
// Events
|
||||
"events.combat.damage",
|
||||
"events.combat.hit",
|
||||
"events.weapon.left",
|
||||
"events.weapon.flyingTick",
|
||||
"events.weapon.land",
|
||||
|
||||
// Cooldowns
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class RAbilityBase(float cost, float cooldown) : Resource, IAbili
|
||||
{
|
||||
}
|
||||
|
||||
public virtual AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
public virtual AbilityData Ability(TagsManager tagsManager, TagContainer? tags, Node3D owner)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
@@ -7,27 +8,28 @@ using Gamesmiths.Forge.Effects.Magnitudes;
|
||||
using Gamesmiths.Forge.Effects.Modifiers;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.forge.abilities;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_projectile.png")]
|
||||
public partial class RExplodingSwordThrow(PackedScene? explosion, float cost, float cooldown) : RAbilityBase(cost, cooldown)
|
||||
public partial class RExplodingSword(PackedScene? explosion, float cost, float cooldown) : RAbilityBase(cost, cooldown)
|
||||
{
|
||||
[Export] public PackedScene? Explosion { get; set; } = explosion;
|
||||
|
||||
public RExplodingSwordThrow() : this(null, 20.0f, 0.0f)
|
||||
public RExplodingSword() : this(null, 20.0f, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
public override AbilityData Ability(TagsManager tagsManager, Node3D owner)
|
||||
public override AbilityData Ability(TagsManager tagsManager, TagContainer? tags, Node3D owner)
|
||||
{
|
||||
return new AbilityData(
|
||||
name: "Exploding Sword Throw",
|
||||
costEffect: CostEffect(tagsManager),
|
||||
cooldownEffects: [CooldownEffect(tagsManager)],
|
||||
abilityTags: Tag.RequestTag(tagsManager, "abilities.weapon.land").GetSingleTagContainer(),
|
||||
abilityTags: tags,
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior(owner, Explosion));
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior<WeaponLeftPayload>(owner, Explosion));
|
||||
}
|
||||
|
||||
public override EffectData CostEffect(TagsManager tagsManager)
|
||||
@@ -77,21 +79,28 @@ public partial class RExplodingSwordThrow(PackedScene? explosion, float cost, fl
|
||||
}
|
||||
}
|
||||
|
||||
public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) : IAbilityBehavior
|
||||
public class ExplodingSwordThrowBehavior<TPayload>(Node3D owner, PackedScene? explosion) : IAbilityBehavior<TPayload>
|
||||
{
|
||||
private Node3D _owner = owner;
|
||||
private PackedScene? _explosion = explosion;
|
||||
public void OnStarted(AbilityBehaviorContext context)
|
||||
public void OnStarted(AbilityBehaviorContext context, TPayload payload)
|
||||
{
|
||||
GD.Print(payload);
|
||||
if (_explosion?.Instantiate() is not Explosion explosion)
|
||||
{
|
||||
context.InstanceHandle.End();
|
||||
return;
|
||||
}
|
||||
if (!_owner.IsInsideTree())
|
||||
{
|
||||
context.InstanceHandle.End();
|
||||
return;
|
||||
}
|
||||
|
||||
explosion.Radius = 6f;
|
||||
|
||||
explosion.Radius = 10f;
|
||||
_owner.GetTree().GetRoot().AddChild(explosion);
|
||||
explosion.GlobalPosition = _owner.GlobalPosition;
|
||||
_owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explosion);
|
||||
explosion.CallDeferred(Node3D.MethodName.SetGlobalPosition, _owner.GlobalPosition);
|
||||
|
||||
context.AbilityHandle.CommitAbility();
|
||||
context.InstanceHandle.End();
|
||||
@@ -99,6 +108,17 @@ public class ExplodingSwordThrowBehavior(Node3D owner, PackedScene? explosion) :
|
||||
|
||||
public void OnEnded(AbilityBehaviorContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class TestBehavior<TPayload>(
|
||||
Action<AbilityBehaviorContext, TPayload> callback) : IAbilityBehavior<TPayload>
|
||||
{
|
||||
public void OnStarted(AbilityBehaviorContext context, TPayload data)
|
||||
{
|
||||
callback(context, data);
|
||||
context.InstanceHandle.End();
|
||||
}
|
||||
|
||||
public void OnEnded(AbilityBehaviorContext context){}
|
||||
}
|
||||
67
forge/calculators/FlyingWeaponExecution.cs
Normal file
67
forge/calculators/FlyingWeaponExecution.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
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 Godot;
|
||||
|
||||
namespace Movementtests.tools.calculators;
|
||||
|
||||
public class FlyingWeaponExecution : 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))
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
1
forge/calculators/FlyingWeaponExecution.cs.uid
Normal file
1
forge/calculators/FlyingWeaponExecution.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://br7ut4lbau66w
|
||||
Reference in New Issue
Block a user