using Cirno.Scripts.Enums;
using Godot;

namespace Cirno.Scripts.Components.FSM.Elevator;

public partial class Top : BaseState<ElevatorState, ElevatorProxy>
{
    public override ElevatorState StateId => ElevatorState.Top;
    public override void EnterState()
    {
        MainObject.SetPosition(MainObject.ElevatorPath.Curve.GetPointPosition(0));
        
        MainObject.Activated += ElevatorActivated;
        
        // Disable top body
        MainObject.TopBody.Disabled = true;
    }
    
    private void ElevatorActivated(ActivationType type)
    {
        switch (type)
        {
            case ActivationType.Use:
            case ActivationType.Toggle:
                MoveToBottom();
                break;
            case ActivationType.Enable:
                break;
            case ActivationType.Disable:
                break;
            case ActivationType.Destroy:
                break;
            case ActivationType.Open:
                break;
            case ActivationType.Close:
                break;
        }
    }
    
    private void MoveToBottom()
    {
        StateMachine.SetState(ElevatorState.Descending);
    }

    public override void ExitState()
    {
        MainObject.Activated -= ElevatorActivated;
        // Enable top body
        MainObject.TopBody.Disabled = false;
    }
}