yow it's working or wat
This commit is contained in:
@@ -8,74 +8,32 @@ 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, float cost, float cooldown) : RAbilityBase(cost, cooldown)
|
||||
public partial class RExplodingSword(PackedScene? explosion) : Resource, IAbilityBase<ExplodingSwordCreation, WeaponEventPayload>
|
||||
{
|
||||
[Export] public PackedScene? Explosion { get; set; } = explosion;
|
||||
|
||||
public RExplodingSword() : this(null, 20.0f, 0.0f)
|
||||
{
|
||||
}
|
||||
public RExplodingSword() : this(null) {}
|
||||
|
||||
public override AbilityData Ability(TagsManager tagsManager, TagContainer? tags, Node3D owner)
|
||||
public AbilityData Ability(ExplodingSwordCreation creationData, TagContainer? tags)
|
||||
{
|
||||
return new AbilityData(
|
||||
name: "Exploding Sword Throw",
|
||||
costEffect: CostEffect(tagsManager),
|
||||
cooldownEffects: [CooldownEffect(tagsManager)],
|
||||
abilityTags: tags,
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior<WeaponLeftPayload>(owner, Explosion));
|
||||
behaviorFactory: () => new ExplodingSwordThrowBehavior<WeaponEventPayload>(creationData.Owner, Explosion));
|
||||
}
|
||||
|
||||
public override EffectData CostEffect(TagsManager tagsManager)
|
||||
{
|
||||
return new(
|
||||
"Exploding Sword Throw Mana Cost",
|
||||
new DurationData(DurationType.Instant),
|
||||
new[]
|
||||
{
|
||||
new Modifier(
|
||||
"PlayerAttributeSet.Mana",
|
||||
ModifierOperation.FlatBonus,
|
||||
new ModifierMagnitude(
|
||||
MagnitudeCalculationType.ScalableFloat,
|
||||
new ScalableFloat(-Cost)
|
||||
)
|
||||
)
|
||||
},
|
||||
cues: new []
|
||||
{
|
||||
new CueData(
|
||||
CueTags: Tag.RequestTag(tagsManager, "cues.resources.mana").GetSingleTagContainer(),
|
||||
MinValue: 0,
|
||||
MaxValue: 100,
|
||||
MagnitudeType: CueMagnitudeType.AttributeValueChange,
|
||||
MagnitudeAttribute: "PlayerAttributeSet.Mana"
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public override EffectData CooldownEffect(TagsManager tagsManager)
|
||||
public IAbilityBehavior<WeaponEventPayload> Behavior(ExplodingSwordCreation creationData)
|
||||
{
|
||||
return new(
|
||||
"Exploding Sword Throw Cooldown",
|
||||
new DurationData(
|
||||
DurationType.HasDuration,
|
||||
new ModifierMagnitude(
|
||||
MagnitudeCalculationType.ScalableFloat,
|
||||
new ScalableFloat(Cooldown))),
|
||||
effectComponents: new[]
|
||||
{
|
||||
new ModifierTagsEffectComponent(
|
||||
tagsManager.RequestTagContainer(new[] { "cooldown.empoweredSwordThrow" })
|
||||
)
|
||||
});
|
||||
return new ExplodingSwordThrowBehavior<WeaponEventPayload>(creationData.Owner, Explosion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,18 +43,21 @@ public class ExplodingSwordThrowBehavior<TPayload>(Node3D owner, PackedScene? ex
|
||||
private PackedScene? _explosion = explosion;
|
||||
public void OnStarted(AbilityBehaviorContext context, TPayload payload)
|
||||
{
|
||||
GD.Print(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);
|
||||
@@ -109,16 +70,4 @@ public class ExplodingSwordThrowBehavior<TPayload>(Node3D owner, PackedScene? ex
|
||||
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){}
|
||||
}
|
||||
Reference in New Issue
Block a user