Traveller/scripts/map/layoutStrategy/TestLayoutStrategy.cs
Cold-Mint 4c61f3b50e
Remove unused source files. Fixed an issue where the health tank was empty after resurrection.
移除未使用的源文件。修复复活后生命槽为空的问题。
2024-06-05 22:15:23 +08:00

32 lines
934 B
C#

using System.Threading.Tasks;
using ColdMint.scripts.levelGraphEditor;
using ColdMint.scripts.serialization;
using Godot;
namespace ColdMint.scripts.map.layoutStrategy;
/// <summary>
/// <para>Layout selection strategy to use at test time</para>
/// <para>测试时使用的布局选择策略</para>
/// </summary>
public class TestLayoutStrategy : ILayoutStrategy
{
private const string Path = "res://data/levelGraphs/test.json";
public Task<LevelGraphEditorSaveData?> GetLayout()
{
var exists = FileAccess.FileExists(Path);
if (!exists)
{
return Task.FromResult<LevelGraphEditorSaveData?>(null);
}
var json = FileAccess.GetFileAsString(Path);
if (json == null)
{
return Task.FromResult<LevelGraphEditorSaveData?>(null);
}
return Task.FromResult(JsonSerialization.Deserialize<LevelGraphEditorSaveData>(json));
}
}