mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 16: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
|
|
@ -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