cirnogodot/Scripts/Components/FSM/Elevator/ElevatorProxy.cs

54 lines
No EOL
1.4 KiB
C#

using System;
using System.Collections.Generic;
using Cirno.Scripts.Enums;
using Godot;
namespace Cirno.Scripts.Components.FSM.Elevator;
public partial class ElevatorProxy : Area2D, IActivable
{
[Export]
public ElevatorState StartingState { get; protected set; } = ElevatorState.Bottom;
[Export]
public float MovementTime { get; protected set; } = 1.0f;
[Export]
public Path2D ElevatorPath { get; protected set; }
[Signal] public delegate void ActivatedEventHandler(ActivationType type);
public Vector2 Top => ElevatorPath.Curve.GetPointPosition(0);
public Vector2 Bottom => ElevatorPath.Curve.GetPointPosition(1);
public IStateMachine<ElevatorState,ElevatorProxy> StateMachine { get; set; }
// public void SetPosition(Vector2 position)
// {
//
// }
public InteractionController CachedPlayer { get; private set; }
public bool Activate(ActivationType activationType = ActivationType.Toggle)
{
EmitSignal(SignalName.Activated, (int)activationType);
return true;
}
private void _on_area_entered(Area2D area)
{
if (area is InteractionController player)
{
CachedPlayer = player;
}
}
private void _on_area_exited(Area2D area)
{
if (area is InteractionController player)
{
CachedPlayer = null;
}
}
}