mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:35:34 +00:00
38 lines
No EOL
943 B
C#
38 lines
No EOL
943 B
C#
using System.Threading.Tasks;
|
|
using Cirno.Scripts.Activables;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Actors;
|
|
|
|
public partial class AlarmTeleporterActorSpawner : ActorSpawner
|
|
{
|
|
private AlarmManager _alarmManager;
|
|
|
|
[Export]
|
|
public Teleporter Teleporter { get; private set; }
|
|
|
|
[Export]
|
|
public float ActivationRange { get; private set; }
|
|
|
|
[Export] public float ActivationDelay { get; private set; } = 2f;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_alarmManager = this.GetAlarmManager();
|
|
_alarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
|
|
}
|
|
|
|
private void AlarmManagerOnAlarmEnabled(Vector2 location)
|
|
{
|
|
if (!(location.DistanceTo(this.GlobalPosition) <= ActivationRange)) return;
|
|
|
|
_ = DelaySpawn();
|
|
}
|
|
|
|
private async Task DelaySpawn()
|
|
{
|
|
await Task.Delay((int)(1000 * ActivationDelay));
|
|
Teleporter?.FireParticles();
|
|
Spawn();
|
|
}
|
|
} |