2025-03-21 10:30:44 +01:00
|
|
|
|
using Cirno.Scripts.Enums;
|
2025-03-21 15:33:37 +01:00
|
|
|
|
using Godot;
|
2025-03-21 10:30:44 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Enemy;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class Dead : EnemyStateBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public override EnemyState StateId => EnemyState.Dead;
|
2025-03-21 15:33:37 +01:00
|
|
|
|
|
2026-02-26 23:13:57 +01:00
|
|
|
|
private EnemyStorageModule StorageModule { get; set; }
|
2025-03-21 16:03:44 +01:00
|
|
|
|
|
2026-02-26 23:13:57 +01:00
|
|
|
|
private EnemyDropsProvider DropsProvider { get; set; }
|
2025-03-21 15:33:37 +01:00
|
|
|
|
|
2026-02-26 23:13:57 +01:00
|
|
|
|
public override void Init(IStateMachine<EnemyState, CharacterBody2D> machine)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Init(machine);
|
|
|
|
|
|
StorageModule ??= StateMachine.GetModule<EnemyStorageModule>();
|
|
|
|
|
|
DropsProvider ??= StateMachine.GetModule<EnemyDropsProvider>();
|
|
|
|
|
|
}
|
2025-03-21 15:33:37 +01:00
|
|
|
|
|
|
|
|
|
|
public override void EnterState()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.EnterState();
|
|
|
|
|
|
|
|
|
|
|
|
// Play death script
|
|
|
|
|
|
if (StorageModule.Root.DefeatScript is IActivable activatable)
|
|
|
|
|
|
{
|
|
|
|
|
|
activatable.Activate(StorageModule.Root.ActivationType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 16:03:44 +01:00
|
|
|
|
DropsProvider.DropLoot();
|
2025-03-21 15:33:37 +01:00
|
|
|
|
|
2025-03-31 18:28:33 +02:00
|
|
|
|
GameManager.Instance.AddMotivation(StorageModule.EnemyData.MotivationReward);
|
|
|
|
|
|
|
2025-04-17 17:42:24 +02:00
|
|
|
|
StorageModule.Root.TriggerDeath();
|
|
|
|
|
|
|
2025-03-21 16:03:44 +01:00
|
|
|
|
StorageModule.Root.QueueFree();
|
2025-03-21 15:33:37 +01:00
|
|
|
|
}
|
2025-03-21 10:30:44 +01:00
|
|
|
|
}
|