mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-15 13:33:46 +00:00
Elevators move players
This commit is contained in:
parent
8b378abef3
commit
2e0ad40f33
8 changed files with 156 additions and 93 deletions
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue