mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:35:34 +00:00
38 lines
No EOL
771 B
C#
38 lines
No EOL
771 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 Node2D SpawnedActor { get; private set; }
|
|
|
|
public virtual void Spawn()
|
|
{
|
|
SpawnedActor = this.CreateSibling<Node2D>(ActorPrefab);
|
|
}
|
|
|
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
if (!WaitForActorDeath)
|
|
{
|
|
Spawn();
|
|
}
|
|
else if (SpawnedActor == null)
|
|
{
|
|
Spawn();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Toggle()
|
|
{
|
|
this.Activate();
|
|
}
|
|
} |