mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:45:33 +00:00
59 lines
No EOL
1.8 KiB
C#
59 lines
No EOL
1.8 KiB
C#
using System.Threading.Tasks;
|
|
using Cirno.Scripts.Components.FSM;
|
|
using Cirno.Scripts.Components.FSM._3DPlayer;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Activables._3D;
|
|
|
|
[Tool]
|
|
public partial class LevelTeleporter3D : Teleporter3D
|
|
{
|
|
[Export] public bool SaveInventory { get; set; }
|
|
[Export] public StringName MapId { get; set; }
|
|
|
|
public override void _func_godot_apply_properties(Dictionary<string, Variant> props)
|
|
{
|
|
// TargetGroup = props["target"].AsString();
|
|
//
|
|
// TargetName = props["targetname"].AsString();
|
|
IsEnabled = props["enabled"].AsBool();
|
|
MapId = props["mapid"].AsString();
|
|
Invisible = props["invisible"].AsBool();
|
|
}
|
|
|
|
protected override async Task Teleport(IsoPlayerStateMachine player)
|
|
{
|
|
player.SetState(PlayerState.Cutscene);
|
|
await TweenPlayer(player.MainObject);
|
|
|
|
PlayTeleportStartSound();
|
|
FireParticles();
|
|
|
|
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();
|
|
}
|
|
else
|
|
{
|
|
GlobalState.Instance.SessionSettings.EquippedWeaponId = string.Empty;
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(MapId))
|
|
{
|
|
GlobalState.Instance.GotoScene(GlobalState.Instance.MapsDatabase.FindMap(MapId));
|
|
}
|
|
else
|
|
{
|
|
var nextMap = GlobalState.Instance.MapsDatabase.FindNextMap(GlobalState.Instance.SessionSettings.MapId);
|
|
GlobalState.Instance.GotoScene(nextMap);
|
|
}
|
|
}
|
|
} |