wave behavior and fixed explosion
This commit is contained in:
@@ -42,6 +42,12 @@ public partial class Enemy : CharacterBody3D,
|
||||
[Dependency]
|
||||
public TokenManager TokenManager => this.DependOn<TokenManager>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Signals
|
||||
|
||||
[Signal] public delegate void OnKilledEventHandler(ulong instanceId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Inspector
|
||||
@@ -188,12 +194,7 @@ public partial class Enemy : CharacterBody3D,
|
||||
|
||||
public void ProcessGameplay(double delta)
|
||||
{
|
||||
if (IsStunned())
|
||||
{
|
||||
GD.Print("Cannot attack, stunned!");
|
||||
return;
|
||||
}
|
||||
// if (_hitAbilityHandle == null) return;
|
||||
if (IsStunned()) return;
|
||||
|
||||
var bodies = DamageBox.GetOverlappingBodies();
|
||||
foreach (var body in bodies)
|
||||
@@ -253,6 +254,8 @@ public partial class Enemy : CharacterBody3D,
|
||||
{
|
||||
killable.Kill();
|
||||
}
|
||||
|
||||
EmitSignalOnKilled(GetInstanceId());
|
||||
CallDeferred(Node.MethodName.QueueFree);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ public partial class Explosion : Area3D, IProvide<CuesManager>
|
||||
foreach (var body in bodies)
|
||||
{
|
||||
if (body is not IForgeEntity target) continue;
|
||||
foreach (var ability in ForgeEntityNode.Abilities.GrantedAbilities.Where(ability => ability.CanActivate(out _, target)))
|
||||
foreach (var ability in ForgeEntityNode.Abilities.GrantedAbilities.Where(ability =>
|
||||
ability.CanActivate(out _, target)))
|
||||
ability.Activate(out _, target, Damage);
|
||||
}
|
||||
QueueFree();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://duju3atqgltkg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnlu64l7oxvv3" path="res://scenes/explosion/Explosion.cs" id="1_82hkh"]
|
||||
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="3_1ve7p"]
|
||||
[ext_resource type="Script" uid="uid://rpcbb54q4atx" path="res://forge/ForgeEntityNode.cs" id="3_wikc1"]
|
||||
[ext_resource type="Script" uid="uid://dps0oef50noil" path="res://addons/forge/nodes/ForgeEffect.cs" id="4_f5lqq"]
|
||||
[ext_resource type="Resource" uid="uid://nns16d5uhtl8" path="res://forge/resources/ability_datas/explosion_hit.tres" id="5_nphml"]
|
||||
@@ -21,6 +22,11 @@ transparency = 1
|
||||
cull_mode = 2
|
||||
albedo_color = Color(0.9607843, 0.27058825, 0, 0.7176471)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_nqbbv"]
|
||||
script = ExtResource("3_1ve7p")
|
||||
ContainerTags = []
|
||||
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5c2oj"]
|
||||
script = ExtResource("5_nqbbv")
|
||||
BaseValue = 1
|
||||
@@ -71,6 +77,7 @@ surface_material_override/0 = SubResource("StandardMaterial3D_hys74")
|
||||
|
||||
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=806020391]
|
||||
script = ExtResource("3_wikc1")
|
||||
BaseTags = SubResource("Resource_nqbbv")
|
||||
metadata/_custom_type_script = "uid://rpcbb54q4atx"
|
||||
|
||||
[node name="ForgeEffect" type="Node" parent="ForgeEntityNode" unique_id=2068515708]
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Movementtests.managers;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_duplicate.png")]
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_duplicate.png"), Meta(typeof(IAutoNode))]
|
||||
public partial class Spawner : Node3D
|
||||
{
|
||||
[Export(PropertyHint.NodeType)]
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public WaveManager WaveManager => this.DependOn<WaveManager>();
|
||||
|
||||
[Export(PropertyHint.NodeType)]
|
||||
public PackedScene? EnemyToSpawn { get; set; }
|
||||
|
||||
[Export] public Godot.Collections.Array<EnemyDescription.EnemyType> SupportedEnemyTypes { get; set; } = [];
|
||||
|
||||
[Export]
|
||||
public RMovement? MovementInputs { get; set; }
|
||||
@@ -18,37 +27,56 @@ public partial class Spawner : Node3D
|
||||
[Export]
|
||||
public bool IsActiveOnStart { get; set; } = true;
|
||||
|
||||
private Timer _timer;
|
||||
[Node("Timer")] private Timer SpawnTimer { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
public void OnReady()
|
||||
{
|
||||
_timer = GetNode<Timer>("Timer");
|
||||
_timer.WaitTime = SpawnInterval;
|
||||
_timer.Timeout += Spawn;
|
||||
SpawnTimer.WaitTime = SpawnInterval;
|
||||
SpawnTimer.Timeout += Spawn;
|
||||
if (IsActiveOnStart) StartSpawning();
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
WaveManager.RegisterSpawner(this);
|
||||
}
|
||||
|
||||
public void Spawn()
|
||||
{
|
||||
if (EnemyToSpawn == null || !EnemyToSpawn.CanInstantiate()) return;
|
||||
|
||||
if (EnemyToSpawn.Instantiate() is not Enemy spawnedInstance) return;
|
||||
spawnedInstance.RequestReady();
|
||||
|
||||
spawnedInstance.Target = Target;
|
||||
spawnedInstance.RMovement = MovementInputs;
|
||||
if (MovementInputs != null)
|
||||
spawnedInstance.RMovement = MovementInputs;
|
||||
spawnedInstance.Init();
|
||||
|
||||
GetTree().GetCurrentScene().AddChild(spawnedInstance);
|
||||
spawnedInstance.GlobalPosition = GlobalPosition;
|
||||
}
|
||||
|
||||
public Enemy? SpawnEnemy(EnemyDescription description)
|
||||
{
|
||||
if (description.Scene.Instantiate() is not Enemy spawnedInstance) return null;
|
||||
|
||||
spawnedInstance.Target = Target;
|
||||
if (description.MovementOverride is not null)
|
||||
spawnedInstance.RMovement = description.MovementOverride;
|
||||
spawnedInstance.Init();
|
||||
|
||||
GetTree().GetCurrentScene().AddChild(spawnedInstance);
|
||||
spawnedInstance.GlobalPosition = GlobalPosition;
|
||||
return spawnedInstance;
|
||||
}
|
||||
|
||||
public void StartSpawning()
|
||||
{
|
||||
_timer.Start();
|
||||
SpawnTimer.Start();
|
||||
}
|
||||
|
||||
public void StopSpawning()
|
||||
{
|
||||
_timer.Stop();
|
||||
SpawnTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user