Class SceneActionRegistry
Static lookup table that maps PGPSCN action_handler command keys to
game-supplied delegates. Exists to make PGPSCN action dispatch trim-safe:
the legacy scene_method / static_method dispatch in
SceneLoader.ExecuteCommand relied on Type.GetType and
MethodInfo.Invoke, both of which the .NET IL Trimmer cannot follow.
The registry replaces the indirection at the dispatch boundary: PGPSCN
files name a string key, game code registers a delegate for that key at
startup, and the loader does a pure dictionary lookup at runtime.
Contract: games using PGPSCN with action_handler commands must register
every key referenced by their scene files at startup (before game.RunGame()).
Unregistered keys log a diagnostic and the action becomes a no-op.
public static class SceneActionRegistry
- Inheritance
-
SceneActionRegistry
- Inherited Members
Methods
Clear()
Removes every registration. Intended for test setup/teardown only — production code should register once at startup.
public static void Clear()
RegisterAction(string, Action)
Registers a parameterless handler under key. The
passed-in delegate is wrapped as a variadic handler that ignores its
arguments — convenient for buttons whose PGPSCN entry passes no parameters.
public static void RegisterAction(string key, Action handler)
Parameters
RegisterAction(string, Action<IReadOnlyList<object>>)
Registers a variadic handler under key. Pass-through;
the handler receives the PGPSCN parameters array unchanged.
public static void RegisterAction(string key, Action<IReadOnlyList<object>> handler)
Parameters
keystringhandlerAction<IReadOnlyList<object>>
RegisterAction<TArg>(string, Action<TArg>)
Registers a single-typed-arg handler under key. The
wrapper converts the first PGPSCN parameter to TArg:
- Reference types that are already
TArgare direct-cast. - JsonElement values (the actual runtime shape after PGPSCN
System.Text.Jsondeserialization) are unwrapped by JsonValueKind and then converted toTArg. - Other values flow through ChangeType(object, Type).
When the PGPSCN command supplies no parameters, the handler is invoked
with default(TArg) and a one-time diagnostic is logged naming the
key — typed handlers are expected to receive at least one argument.
public static void RegisterAction<TArg>(string key, Action<TArg> handler)
Parameters
Type Parameters
TArg
TryGetHandler(string, out Action<IReadOnlyList<object>>?)
Pure dictionary lookup. Returns true and the registered handler
when key is registered, otherwise false and
null.
public static bool TryGetHandler(string key, out Action<IReadOnlyList<object>>? handler)
Parameters
keystringhandlerAction<IReadOnlyList<object>>