mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 20:45:53 +00:00
Death animations and spawner
This commit is contained in:
parent
4fd31d7988
commit
16b7d936c9
13 changed files with 286 additions and 11 deletions
31
Scripts/Actors/ActorSpawner.cs
Normal file
31
Scripts/Actors/ActorSpawner.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Scripts/Actors/AlarmTeleporterActorSpawner.cs
Normal file
28
Scripts/Actors/AlarmTeleporterActorSpawner.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_alarmManager = this.GetAlarmManager();
|
||||
_alarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
|
||||
}
|
||||
|
||||
private void AlarmManagerOnAlarmEnabled(Vector2 location)
|
||||
{
|
||||
if (!(location.DistanceTo(this.GlobalPosition) <= ActivationRange)) return;
|
||||
Teleporter?.FireParticles();
|
||||
Spawn();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue