Sync daemon authority migration
This commit is contained in:
parent
030b4b5d74
commit
39a0dc8737
295 changed files with 25121 additions and 7360 deletions
|
|
@ -45,10 +45,128 @@ namespace GameCult.Aetheria.State.Unity
|
|||
return AetheriaRuntimeCatalogStore.ReadEntitySnapshots(stateFilePath);
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonFrame(string stateFilePath, out AetheriaRuntimeDaemonFrameDocument frame)
|
||||
{
|
||||
return AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out frame);
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonSoaView(string stateFilePath, out AetheriaRuntimeDaemonSoaViewDocument view)
|
||||
{
|
||||
return AetheriaRuntimeDaemonSoaViewStore.TryReadView(stateFilePath, out view);
|
||||
}
|
||||
|
||||
public static bool TryReadObservedDaemonState(
|
||||
string stateFilePath,
|
||||
out AetheriaRuntimeObservedDaemonState observed)
|
||||
{
|
||||
if (!AetheriaRuntimeDaemonFrameStore.TryReadFrame(stateFilePath, out var frame))
|
||||
{
|
||||
observed = new AetheriaRuntimeObservedDaemonState(
|
||||
new AetheriaRuntimeDaemonFrameDocument { IsAuthoritative = false, StateSource = "missing" },
|
||||
null,
|
||||
AetheriaRuntimeDaemonFrameStore.GetFramePath(stateFilePath),
|
||||
AetheriaRuntimeDaemonSoaViewStore.GetViewPath(stateFilePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
AetheriaRuntimeDaemonSoaViewStore.TryReadView(stateFilePath, out var soaView);
|
||||
observed = new AetheriaRuntimeObservedDaemonState(
|
||||
frame,
|
||||
string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal) ? soaView : null,
|
||||
AetheriaRuntimeDaemonFrameStore.GetFramePath(stateFilePath),
|
||||
AetheriaRuntimeDaemonSoaViewStore.GetViewPath(stateFilePath));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static EveSurfaceDocument? ReadEveSurface(string stateFilePath, string surfaceId)
|
||||
{
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, StringComparison.Ordinal) &&
|
||||
TryReadDaemonGameSurface(stateFilePath, out var gameSurface))
|
||||
{
|
||||
return gameSurface;
|
||||
}
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId, StringComparison.Ordinal) &&
|
||||
TryReadDaemonGameTuiSurface(stateFilePath, out var gameTuiSurface))
|
||||
{
|
||||
return gameTuiSurface;
|
||||
}
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId, StringComparison.Ordinal) &&
|
||||
TryReadDaemonEditorSurface(stateFilePath, out var editorSurface))
|
||||
{
|
||||
return editorSurface;
|
||||
}
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId, StringComparison.Ordinal) &&
|
||||
TryReadDaemonEditorTuiSurface(stateFilePath, out var editorTuiSurface))
|
||||
{
|
||||
return editorTuiSurface;
|
||||
}
|
||||
|
||||
return AetheriaRuntimeCatalogStore.ReadEveSurfaces(stateFilePath)
|
||||
.FirstOrDefault(candidate => string.Equals(candidate.Surface.Id, surfaceId, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonGameSurface(
|
||||
string stateFilePath,
|
||||
out EveSurfaceDocument document)
|
||||
{
|
||||
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameSurface(stateFilePath, out var surface))
|
||||
{
|
||||
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
document = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonGameTuiSurface(
|
||||
string stateFilePath,
|
||||
out EveSurfaceDocument document)
|
||||
{
|
||||
if (!AetheriaRuntimeDaemonPublicationStore.TryReadGameTuiSurface(stateFilePath, out var surface))
|
||||
{
|
||||
document = EmptySurface(AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
document = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonEditorSurface(
|
||||
string stateFilePath,
|
||||
out EveSurfaceDocument document)
|
||||
{
|
||||
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorSurface(stateFilePath, out var surface))
|
||||
{
|
||||
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
document = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryReadDaemonEditorTuiSurface(
|
||||
string stateFilePath,
|
||||
out EveSurfaceDocument document)
|
||||
{
|
||||
if (!AetheriaRuntimeDaemonPublicationStore.TryReadEditorTuiSurface(stateFilePath, out var surface))
|
||||
{
|
||||
document = EmptySurface(AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId);
|
||||
return false;
|
||||
}
|
||||
|
||||
document = AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static EveSurfaceDocument EmptySurface(string surfaceId)
|
||||
{
|
||||
return AetheriaRuntimeEveSurfaceAdapter.EmptySurface(surfaceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue