cirnogodot/Scripts/Activables/LevelTeleporter.cs

32 lines
876 B
C#
Raw Normal View History

2025-02-21 22:48:12 +01:00
using System;
using System.Collections;
using System.Threading.Tasks;
2025-03-02 11:58:30 +01:00
using Cirno.Scripts.Components.FSM;
2025-02-21 22:48:12 +01:00
using Godot;
namespace Cirno.Scripts.Activables;
public partial class LevelTeleporter : Teleporter
{
[Export]
2025-02-21 23:52:44 +01:00
public string LevelPath {get; private set;}
2025-02-21 22:48:12 +01:00
2025-03-05 10:55:14 +01:00
protected override async Task Teleport(IStateMachine<PlayerState, CharacterBody2D> player)
2025-02-21 22:48:12 +01:00
{
2025-02-21 23:52:44 +01:00
if (string.IsNullOrWhiteSpace(LevelPath)) return;
2025-03-02 11:58:30 +01:00
//player.RequestMovementDisable(true);
2025-03-05 10:55:14 +01:00
player.SetState(PlayerState.Cutscene);
2025-02-21 22:48:12 +01:00
2025-03-05 10:55:14 +01:00
await TweenPlayer(player.MainObject);
2025-02-21 22:48:12 +01:00
_particles.Emitting = true;
2025-03-02 11:58:30 +01:00
//await player.Teleport();
2025-03-05 10:55:14 +01:00
player.SetState(PlayerState.UnTeleporting);
2025-03-02 11:58:30 +01:00
await Task.Delay((int)(0.6f * 1000));
2025-02-22 14:45:46 +01:00
2025-02-21 22:48:12 +01:00
await Task.Delay((int)(TeleportAnimationLength * 1000));
2025-02-21 23:52:44 +01:00
GlobalState.Instance.GotoScene(LevelPath);
2025-02-21 22:48:12 +01:00
}
}