Simulation bridge

This commit is contained in:
2026-05-13 01:56:50 +02:00
parent 251cfa5016
commit b939246ba4
16 changed files with 10000 additions and 198 deletions

View File

@@ -0,0 +1,34 @@
using ReactorMaintenance.Simulation;
using FileAccess = Godot.FileAccess;
namespace ReactorMaintenance.Godot.Data;
public static class LevelStateLoader
{
public static LevelState Load(string path)
{
if (string.IsNullOrWhiteSpace(path))
throw new ArgumentException("Level path must not be null or empty.", nameof(path));
if (!FileAccess.FileExists(path))
throw new FileNotFoundException($"Level file not found: {path}");
var json = FileAccess.GetFileAsString(path);
if (string.IsNullOrWhiteSpace(json))
throw new InvalidOperationException($"Level file is empty: {path}");
try
{
return LevelSerializer.Deserialize(json);
}
catch (InvalidOperationException)
{
throw;
}
catch (Exception ex)
{
throw new InvalidOperationException(
$"Failed to deserialize level from {path}: {ex.Message}", ex);
}
}
}