using Cirno.Scripts.Enums;
using Godot;

namespace Cirno.Scripts.Components.FSM.Enemy;

public partial class Dead : EnemyStateBase
{
    public override EnemyState StateId => EnemyState.Dead;

    [Export]
    public EnemyStorageModule StorageModule { get; private set; }
    
    [Export]
    public EnemyDropsProvider DropsProvider { get; private set; }

    // public override void Init(IStateMachine<EnemyState, CharacterBody2D> machine)
    // {
    //     base.Init(machine);
    //
    //
    // }

    public override void EnterState()
    {
        base.EnterState();
        
        // Play death script
        if (StorageModule.Root.DefeatScript is IActivable activatable)
        {
            activatable.Activate(StorageModule.Root.ActivationType);
        }
        
        DropsProvider.DropLoot();
        
        GameManager.Instance.AddMotivation(StorageModule.EnemyData.MotivationReward);
        
        StorageModule.Root.TriggerDeath();
        
        StorageModule.Root.QueueFree();
    }
}