basic projectiles
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 26s
Create tag and build when new code gets to main / Export (push) Successful in 5m9s

This commit is contained in:
2026-05-07 14:53:30 +02:00
parent 01a2e7582b
commit 150e007b22
13 changed files with 504 additions and 32 deletions

View File

@@ -0,0 +1,42 @@
using Gamesmiths.Forge.Abilities;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Godot.Resources;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
using Movementtests.interfaces;
namespace Movementtests.forge.abilities;
public class SpawnProjectileBehavior(PackedScene projectileScene) : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
if (context.Target is not Node3D target || context.Source is not Node3D source) return;
var sourceLocation = source.GlobalPosition;
if (projectileScene.Instantiate() is not Projectile projectile) return;
source.GetTree().GetCurrentScene().AddChild(projectile);
projectile.GlobalPosition = source is ITargetable targetable ? targetable.GetTargetGlobalPosition() : sourceLocation;
projectile.Target = target;
if (projectile is ISpawnable spawnable) spawnable.Init();
context.AbilityHandle.CommitAbility();
context.InstanceHandle.End();
}
public void OnEnded(AbilityBehaviorContext context)
{
}
}
[Tool]
[GlobalClass]
public partial class ForgeSpawnProjectileBehavior : ForgeAbilityBehavior
{
[Export] public required PackedScene Projectile { get; set; }
public override IAbilityBehavior GetBehavior() => new SpawnProjectileBehavior(Projectile);
}

View File

@@ -0,0 +1 @@
uid://dxtjifb8hv8k4