cirnogodot/Scripts/Actors/ActorSpawner.cs
2025-02-23 19:19:12 +01:00

31 lines
No EOL
680 B
C#

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;
public Actor SpawnedActor { get; private set; }
public virtual void Spawn()
{
SpawnedActor = this.CreateSibling<Actor>(ActorPrefab);
}
public void Activate(ActivationType activationType = ActivationType.Toggle)
{
if (!WaitForActorDeath)
{
Spawn();
}
else if (SpawnedActor == null)
{
Spawn();
}
}
}