mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 17:45:54 +00:00
Moving FSM Elevator
This commit is contained in:
parent
eef9bc71c1
commit
8b378abef3
22 changed files with 349 additions and 16 deletions
47
Scripts/Components/FSM/Elevator/Descending.cs
Normal file
47
Scripts/Components/FSM/Elevator/Descending.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Godot;
|
||||
using GTweens.Builders;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Elevator;
|
||||
|
||||
public partial class Descending : BaseState<ElevatorState, ElevatorProxy>
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue