Elevators move players

This commit is contained in:
Marco 2025-03-06 11:34:45 +01:00
commit 2e0ad40f33
8 changed files with 156 additions and 93 deletions

View file

@ -8,40 +8,11 @@ using GTweensGodot.Extensions;
namespace Cirno.Scripts.Components.FSM.Elevator;
public partial class Descending : BaseState<ElevatorState, ElevatorProxy>
public partial class Descending : ElevatorMovementState
{
public override ElevatorState StateId => ElevatorState.Descending;
private GTween _tween;
public override void EnterState()
{
_tween?.Kill();
MainObject.SetPosition(MainObject.Top);
Descend();
}
public override void ExitState()
{
_tween?.Kill();
}
private void Descend()
{
// Grab player if in range
//Ascend
_ = DescendingAnimation();
}
private async Task DescendingAnimation()
{
_tween = GTweenSequenceBuilder.New()
.Append(MainObject.TweenPosition(MainObject.Bottom, MainObject.MovementTime))
.Build();
await _tween.PlayAsync(CancellationToken.None);
StateMachine.SetState(ElevatorState.Bottom);
}
protected override Vector2 StartingPosition => MainObject.Top;
protected override Vector2 EndingPosition => MainObject.Bottom;
protected override ElevatorState EndState => ElevatorState.Bottom;
}