basic projectiles
This commit is contained in:
42
forge/abilities/ForgeSpawnProjectileBehavior.cs
Normal file
42
forge/abilities/ForgeSpawnProjectileBehavior.cs
Normal 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);
|
||||
}
|
||||
1
forge/abilities/ForgeSpawnProjectileBehavior.cs.uid
Normal file
1
forge/abilities/ForgeSpawnProjectileBehavior.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dxtjifb8hv8k4
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_l686n")
|
||||
RegisteredTags = Array[String](["character.player", "character.enemy", "weapon", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited", "cues.resources.health", "cooldown.enemy.hit", "events.combat.death", "cooldown.hit", "events.player.hit", "cues.enemy.health", "immunity.damage", "status", "traits.damageable", "traits.knockbackable", "events.combat.knockback_dealt", "events.combat.knockback_received", "events.weapon.plantedtick", "events.weapon.unplanted", "abilities.weapon.planted", "events.enemy.try_hit", "events.enemy.launch_projectile"])
|
||||
RegisteredTags = Array[String](["character.player", "character.enemy", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited", "cues.resources.health", "cooldown.enemy.hit", "events.combat.death", "cooldown.hit", "events.player.hit", "cues.enemy.health", "immunity.damage", "status", "traits.damageable", "traits.knockbackable", "events.combat.knockback_dealt", "events.combat.knockback_received", "events.weapon.plantedtick", "events.weapon.unplanted", "abilities.weapon.planted", "events.enemy.try_hit", "events.enemy.launch_projectile", "objects.projectile", "objects.weapon", "events.enemy.request_projectile"])
|
||||
|
||||
@@ -30,8 +30,8 @@ BaseValue = 1
|
||||
[sub_resource type="Resource" id="Resource_hgeae"]
|
||||
script = ExtResource("4_4348y")
|
||||
Name = "Raise Planted Tick Periodically"
|
||||
Modifiers = null
|
||||
Components = null
|
||||
Modifiers = []
|
||||
Components = []
|
||||
Executions = Array[Object]([SubResource("Resource_l3tir")])
|
||||
DurationType = 1
|
||||
HasPeriodicApplication = true
|
||||
@@ -39,7 +39,7 @@ Period = SubResource("Resource_cykp3")
|
||||
ExecuteOnApplication = true
|
||||
StackLimit = SubResource("Resource_rvogu")
|
||||
InitialStack = SubResource("Resource_yc0gp")
|
||||
Cues = null
|
||||
Cues = []
|
||||
metadata/_custom_type_script = "uid://b83hf13nj37k3"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jiqxq"]
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
[resource]
|
||||
script = ExtResource("2_f5qgs")
|
||||
EffectData = ExtResource("1_hlq5f")
|
||||
Name = "Planted tick application"
|
||||
Name = "Flying tick application"
|
||||
metadata/_custom_type_script = "uid://cl5hudinl1rex"
|
||||
|
||||
@@ -20,7 +20,7 @@ BaseValue = 1
|
||||
|
||||
[resource]
|
||||
script = ExtResource("4_7ma6b")
|
||||
Name = "Call Planted Tick Event Periodically"
|
||||
Name = "Call Flying Tick Event Periodically"
|
||||
Modifiers = []
|
||||
Components = []
|
||||
Executions = Array[Object]([ExtResource("1_cd13a")])
|
||||
|
||||
Reference in New Issue
Block a user