mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
55 lines
No EOL
1.5 KiB
C#
55 lines
No EOL
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using Cirno.Scripts.Components.FSM;
|
|
using Cirno.Scripts.Enums;
|
|
using Cirno.Scripts.Resources;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Activables;
|
|
|
|
public partial class LevelTeleporter : Teleporter
|
|
{
|
|
[Export] public string LevelPath { get; set; }
|
|
[Export] public MapResource Map { get; private set; }
|
|
|
|
[Export] public bool SaveInventory { get; private set; }
|
|
|
|
protected override async Task Teleport(IStateMachine<PlayerState, CharacterBody2D> player)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(LevelPath) && Map is null) return;
|
|
//player.RequestMovementDisable(true);
|
|
player.SetState(PlayerState.Cutscene);
|
|
|
|
await TweenPlayer(player.MainObject);
|
|
|
|
_particles.Emitting = true;
|
|
|
|
//await player.Teleport();
|
|
player.SetState(PlayerState.Teleporting);
|
|
await Task.Delay((int)(0.6f * 1000));
|
|
|
|
await Task.Delay((int)(TeleportAnimationLength * 1000));
|
|
|
|
if (SaveInventory)
|
|
{
|
|
// Save inventory
|
|
GlobalState.Instance.SessionSettings.Items = InventoryManager.Instance.Save();
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(LevelPath))
|
|
{
|
|
if (GlobalState.Instance.SessionSettings.GameMode is GameMode.Roguelite)
|
|
{
|
|
GlobalState.Instance.SessionSettings.LevelNumber += 1;
|
|
}
|
|
|
|
GlobalState.Instance.GotoScene(LevelPath);
|
|
}
|
|
else
|
|
{
|
|
GlobalState.Instance.GotoScene(Map);
|
|
}
|
|
|
|
}
|
|
} |