Map Level resources system

This commit is contained in:
Marco 2025-04-02 17:42:55 +02:00
commit 6e997bd01b
21 changed files with 199 additions and 26 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Threading.Tasks;
using Cirno.Scripts.Components.FSM;
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.Activables;
@ -9,12 +10,13 @@ namespace Cirno.Scripts.Activables;
public partial class LevelTeleporter : Teleporter
{
[Export] public string LevelPath { get; private 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)) return;
if (string.IsNullOrWhiteSpace(LevelPath) && Map is null) return;
//player.RequestMovementDisable(true);
player.SetState(PlayerState.Cutscene);
@ -34,6 +36,14 @@ public partial class LevelTeleporter : Teleporter
GlobalState.Instance.SessionSettings.Items = InventoryManager.Instance.Save();
}
GlobalState.Instance.GotoScene(LevelPath);
if (!string.IsNullOrWhiteSpace(LevelPath))
{
GlobalState.Instance.GotoScene(LevelPath);
}
else
{
GlobalState.Instance.GotoScene(Map);
}
}
}