mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 07:45:54 +00:00
Migrated player state machine
This commit is contained in:
parent
bb3cdefaa2
commit
9c3f22760b
19 changed files with 108 additions and 69 deletions
|
|
@ -11,18 +11,18 @@ public partial class LevelTeleporter : Teleporter
|
|||
[Export]
|
||||
public string LevelPath {get; private set;}
|
||||
|
||||
protected override async Task Teleport(PlayerStateMachine player)
|
||||
protected override async Task Teleport(IStateMachine<PlayerState, CharacterBody2D> player)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(LevelPath)) return;
|
||||
//player.RequestMovementDisable(true);
|
||||
player.SetState((int)PlayerState.Cutscene);
|
||||
player.SetState(PlayerState.Cutscene);
|
||||
|
||||
await TweenPlayer(player);
|
||||
await TweenPlayer(player.MainObject);
|
||||
|
||||
_particles.Emitting = true;
|
||||
|
||||
//await player.Teleport();
|
||||
player.SetState((int)PlayerState.UnTeleporting);
|
||||
player.SetState(PlayerState.UnTeleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public partial class PlayerMover : ChainActivable
|
|||
private async Task MovePlayer()
|
||||
{
|
||||
//_gameManager.Player.RequestMovementDisable(true);
|
||||
_gameManager.Player.SetState((int)PlayerState.Cutscene);
|
||||
_gameManager.Player.SetState(PlayerState.Cutscene);
|
||||
|
||||
Tween tween = GetTree().CreateTween();
|
||||
tween.SetEase(EaseType);
|
||||
|
|
@ -48,7 +48,7 @@ public partial class PlayerMover : ChainActivable
|
|||
await ToSignal(tween, "finished");
|
||||
|
||||
//_gameManager.Player.RequestMovementDisable(false);
|
||||
_gameManager.Player.SetState((int)PlayerState.Cutscene);
|
||||
_gameManager.Player.SetState(PlayerState.Cutscene);
|
||||
|
||||
ActivateTargets();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,10 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
_particleTimer = 0;
|
||||
}
|
||||
|
||||
private void _on_body_entered(CharacterBody2D area)
|
||||
private void _on_area_entered(Area2D area)
|
||||
{
|
||||
if (area is not PlayerStateMachine player) return;
|
||||
if (!IsEnabled) return;
|
||||
if (area is not InteractionController interactionController) return;
|
||||
|
||||
if (!IsPrimed)
|
||||
{
|
||||
|
|
@ -130,16 +131,16 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
|
||||
|
||||
// Call Teleport here
|
||||
_ = Teleport(player);
|
||||
_ = Teleport(interactionController.StateMachine);
|
||||
}
|
||||
|
||||
protected virtual async Task Teleport(PlayerStateMachine player)
|
||||
protected virtual async Task Teleport(IStateMachine<PlayerState, CharacterBody2D> player)
|
||||
{
|
||||
if (Target is null) return;
|
||||
//player.RequestMovementDisable(true);
|
||||
player.SetState((int)PlayerState.Cutscene);
|
||||
player.SetState(PlayerState.Cutscene);
|
||||
|
||||
await TweenPlayer(player);
|
||||
await TweenPlayer(player.MainObject);
|
||||
|
||||
PlayTeleportStartSound();
|
||||
|
||||
|
|
@ -147,21 +148,21 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
FireParticles();
|
||||
|
||||
//await player.Teleport();
|
||||
player.SetState((int)PlayerState.Teleporting);
|
||||
player.SetState(PlayerState.Teleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
||||
|
||||
Target.PrepareForReceiving();
|
||||
player.GlobalPosition = Target.GlobalPosition + TeleportOffset;
|
||||
player.MainObject.GlobalPosition = Target.GlobalPosition + TeleportOffset;
|
||||
Target.PlayTeleportEndSound();
|
||||
//await player.UnTeleport();
|
||||
|
||||
player.SetState((int)PlayerState.UnTeleporting);
|
||||
player.SetState(PlayerState.UnTeleporting);
|
||||
await Task.Delay((int)(0.6f * 1000));
|
||||
|
||||
//player.RequestMovementDisable(false);
|
||||
player.SetState((int)PlayerState.Active);
|
||||
player.SetState(PlayerState.Active);
|
||||
}
|
||||
|
||||
public void PlayTeleportStartSound()
|
||||
|
|
@ -174,7 +175,7 @@ private AudioStreamPlayer2D _teleportEndSound;
|
|||
_teleportEndSound?.Play();
|
||||
}
|
||||
|
||||
protected async Task TweenPlayer(PlayerStateMachine player)
|
||||
protected async Task TweenPlayer(CharacterBody2D player)
|
||||
{
|
||||
await player.TweenGlobalPosition(GlobalPosition + new Vector2(0, -4f), TeleportAnimationLength).PlayAsync(CancellationToken.None);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue