cirnogodot/Scripts/Actors/ActorSpawner.cs

33 lines
704 B
C#
Raw Normal View History

2025-02-23 19:19:12 +01:00
using Godot;
using Godot.Collections;
namespace Cirno.Scripts.Actors;
public partial class ActorSpawner : Node2D, IActivable
{
[Export]
public PackedScene ActorPrefab { get; set; }
[Export] public bool WaitForActorDeath { get; private set; } = true;
2025-03-24 10:26:13 +01:00
public Node2D SpawnedActor { get; private set; }
2025-02-23 19:19:12 +01:00
public virtual void Spawn()
{
2025-03-24 10:26:13 +01:00
SpawnedActor = this.CreateSibling<Node2D>(ActorPrefab);
2025-02-23 19:19:12 +01:00
}
2025-03-09 21:58:25 +01:00
public bool Activate(ActivationType activationType = ActivationType.Toggle)
2025-02-23 19:19:12 +01:00
{
if (!WaitForActorDeath)
{
Spawn();
}
else if (SpawnedActor == null)
{
Spawn();
}
2025-03-09 21:58:25 +01:00
return true;
2025-02-23 19:19:12 +01:00
}
}