public static class AgentDeclarationsWhat a project's assembly says its agents can do, readable by a host that never ran the project's boot path.
Remarks
Why this exists. An IAgentAction is a project's own type, so an AgentActionRegistry could only ever be built by code the project ran — which meant the editor's play mode, a headless determinism harness and a plugin could not construct an AiSystem at all, because they could not construct the registry its constructor takes. Every other project-declared kind already had a declarative route: [GameSystem] into GameSystemRegistry, SceneComponentRegistry.Declare, SerializerRegistry.Register. This is the same shape for agent actions.
⚠ [GameSystem]'s route is a generator emitting a [ModuleInitializer] per declaring assembly, not a reflection scan — which is what survives trimming and what lets the editor read a project's frame without running it. So the way in here is a call from the project's own [ModuleInitializer], which runs when the assembly is loaded and independently of anything calling Game.OnInitialise.
The blackboard layout is declared here too, and has to be. It is the second half of AiSystem's constructor and it had the same problem — built by a BlackboardLayoutBuilder in the game's own boot method and nowhere else. Declaring the keys separately is also what makes the two-phase build below possible: every key is known before any action is constructed.
⚠ Ordered by name, never by declaration order. Which assembly's module initialiser runs first is a property of the run, so a registry built in declaration order would hand out different indices in two runs of the same program. SceneComponentRegistry learned this the expensive way — five dump tests that passed locally and failed on all three CI runners at once.
Fields and properties (2)
public static IReadOnlyList<BlackboardKeyDeclaration> KeysEvery declared blackboard key, ordered by name.
public static IReadOnlyList<AgentActionDeclaration> ActionsEvery declared action, ordered by name.
Methods (7)
public static bool DeclareKey(string name, BlackboardValueType type)Declares a blackboard key on behalf of the calling assembly.
public static bool DeclareKey(string name, BlackboardValueType type, Assembly origin)Declares a blackboard key, naming the assembly it belongs to.
public static bool DeclareAction(string name, Func<BlackboardLayout, IAgentAction> factory, int stateSize = 0)Declares an action on behalf of the calling assembly.
public static bool DeclareAction(string name, Func<BlackboardLayout, IAgentAction> factory, int stateSize, Assembly origin)Declares an action, naming the assembly it belongs to.
public static BlackboardLayout BuildLayout()Builds the layout every declared key is in.
public static AgentActionRegistry BuildRegistry(BlackboardLayout layout)Builds a registry holding every declared action.
public static int Evict(Assembly assembly)Forgets everything an assembly declared.
Used by (2)
- AgentDeclarationsTestsVixen.Ai.Tests
- ProjectAssembliesVixen.Editor.App