pub struct AgentRegistry { /* private fields */ }Expand description
Registry that manages all registered agents with automatic priority ordering.
Agents are automatically sorted by priority (highest first) and can be iterated in execution order.
Implementations§
Source§impl AgentRegistry
impl AgentRegistry
Sourcepub fn register(&mut self, agent: Arc<Mutex<dyn Agent>>, priority: f32)
pub fn register(&mut self, agent: Arc<Mutex<dyn Agent>>, priority: f32)
Registers an agent with the given priority.
Higher priority values mean the agent is updated first. The agent is active in all engine modes.
Sourcepub fn register_for_mode(
&mut self,
agent: Arc<Mutex<dyn Agent>>,
priority: f32,
modes: Vec<EngineMode>,
)
pub fn register_for_mode( &mut self, agent: Arc<Mutex<dyn Agent>>, priority: f32, modes: Vec<EngineMode>, )
Registers an agent with the given priority, active only in the specified modes.
Higher priority values mean the agent is updated first.
If modes is empty, the agent is active in all modes.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Arc<Mutex<dyn Agent>>>
pub fn iter(&self) -> impl Iterator<Item = &Arc<Mutex<dyn Agent>>>
Returns an iterator over all agents in priority order (highest first).
Sourcepub fn all_ids(&self) -> Vec<AgentId>
pub fn all_ids(&self) -> Vec<AgentId>
Returns the [AgentId]s of every registered agent in priority order.
Used by the scheduler to seed a fresh AgentCompletionMap per frame.
Sourcepub fn initialize_all(&self, context: &mut EngineContext<'_>)
pub fn initialize_all(&self, context: &mut EngineContext<'_>)
Initializes all agents once after registration.
Calls on_initialize() on each agent in priority order, giving them
access to the engine services for caching and lane setup.
Sourcepub fn execute_all(&self, context: &mut EngineContext<'_>)
pub fn execute_all(&self, context: &mut EngineContext<'_>)
Executes all agents in priority order.
Called each frame. Each agent selects the appropriate lanes and dispatches their execution.
Sourcepub fn get_by_id(&self, id: AgentId) -> Option<Arc<Mutex<dyn Agent>>>
pub fn get_by_id(&self, id: AgentId) -> Option<Arc<Mutex<dyn Agent>>>
Returns the agent with the given ID, if registered.
Sourcepub fn collect_for_phase(
&self,
phase: ExecutionPhase,
mode: &EngineMode,
) -> Vec<PhaseAgentEntry> ⓘ
pub fn collect_for_phase( &self, phase: ExecutionPhase, mode: &EngineMode, ) -> Vec<PhaseAgentEntry> ⓘ
Collects agents that are allowed to run in the given phase and mode. Returns a list of (agent, importance, priority, dependencies).
Sourcepub fn execute_agent(
&self,
id: AgentId,
context: &mut EngineContext<'_>,
) -> bool
pub fn execute_agent( &self, id: AgentId, context: &mut EngineContext<'_>, ) -> bool
Executes a specific agent by ID.