mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
59 lines
No EOL
1.5 KiB
C#
59 lines
No EOL
1.5 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; }
|
|
|
|
[Export] public CollisionShape2D TopBody { 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;
|
|
}
|
|
|
|
public void Toggle()
|
|
{
|
|
this.Activate();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |