Mount Eve operations surface at runtime
This commit is contained in:
parent
b130df9557
commit
38ff448d4c
6 changed files with 129 additions and 3 deletions
|
|
@ -10,6 +10,15 @@ CultCache state into Unity UI Toolkit.
|
|||
- it queues renderer-emitted commands as typed `.cc.eve.pending` command
|
||||
envelopes for Aetheria's provider-owned command bridge.
|
||||
|
||||
`AetheriaEveRuntimeBootstrap` mounts the first runtime surface after scene load.
|
||||
By default it creates a `UIDocument` host for `aetheria.operations`, so the
|
||||
provider-owned operations surface is present at runtime without a hand-wired
|
||||
scene object. Set `AETHERIA_EVE_SURFACE_ID` to mount a different surface, set
|
||||
`AETHERIA_EVE_STATE_PATH` to point at a non-default `.cc` state file, or disable
|
||||
the automatic mount with `AETHERIA_DISABLE_EVE_RUNTIME_BOOTSTRAP=true` or
|
||||
`--aetheria-disable-eve-runtime-bootstrap`. Batchmode disables the bootstrap so
|
||||
compile and smoke gates do not accidentally create renderer state.
|
||||
|
||||
Commands are surfaced as `gamecult.eve.command.v1` requests. The presenter does
|
||||
not accept or apply them locally; provider acceptance still belongs to the
|
||||
CultMesh command bridge. Renderer-local command effects would be the wrong
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace GameCult.Aetheria.EveRuntime
|
||||
{
|
||||
public static class AetheriaEveRuntimeBootstrap
|
||||
{
|
||||
public const string DefaultSurfaceId = "aetheria.operations";
|
||||
public const string DisableEnvironmentVariable = "AETHERIA_DISABLE_EVE_RUNTIME_BOOTSTRAP";
|
||||
public const string SurfaceEnvironmentVariable = "AETHERIA_EVE_SURFACE_ID";
|
||||
public const string StatePathEnvironmentVariable = "AETHERIA_EVE_STATE_PATH";
|
||||
public const string DisableCommandLineSwitch = "--aetheria-disable-eve-runtime-bootstrap";
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
||||
private static void MountDefaultSurface()
|
||||
{
|
||||
if (IsDisabled() || UnityEngine.Object.FindObjectOfType<AetheriaEveSurfacePresenter>() != null)
|
||||
return;
|
||||
|
||||
var host = new GameObject("Aetheria Eve Runtime Surface");
|
||||
UnityEngine.Object.DontDestroyOnLoad(host);
|
||||
|
||||
host.AddComponent<UIDocument>();
|
||||
var presenter = host.AddComponent<AetheriaEveSurfacePresenter>();
|
||||
presenter.SurfaceId = SurfaceId();
|
||||
presenter.StateFilePathOverride = StatePathOverride();
|
||||
}
|
||||
|
||||
private static bool IsDisabled()
|
||||
{
|
||||
if (Application.isBatchMode)
|
||||
return true;
|
||||
|
||||
var environment = Environment.GetEnvironmentVariable(DisableEnvironmentVariable);
|
||||
if (string.Equals(environment, "1", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(environment, "true", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Environment.GetCommandLineArgs()
|
||||
.Any(argument => string.Equals(argument, DisableCommandLineSwitch, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private static string SurfaceId()
|
||||
{
|
||||
var configured = Environment.GetEnvironmentVariable(SurfaceEnvironmentVariable);
|
||||
return string.IsNullOrWhiteSpace(configured) ? DefaultSurfaceId : configured;
|
||||
}
|
||||
|
||||
private static string StatePathOverride()
|
||||
{
|
||||
return Environment.GetEnvironmentVariable(StatePathEnvironmentVariable) ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue