AgentRegistry

Struct AgentRegistry 

Source
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

Source

pub fn new() -> Self

Creates a new empty registry.

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of registered agents.

Source

pub fn is_empty(&self) -> bool

Returns true if no agents are registered.

Source

pub fn iter(&self) -> impl Iterator<Item = &Arc<Mutex<dyn Agent>>>

Returns an iterator over all agents in priority order (highest first).

Source

pub fn update_all(&self, context: &mut EngineContext<'_>)

Updates all agents in priority order.

Source

pub fn execute_all(&self)

Executes all agents in priority order.

Called after update_all each frame. Each agent performs its primary work (e.g., the RenderAgent renders, the PhysicsAgent simulates).

Source

pub fn get_by_id(&self, id: AgentId) -> Option<Arc<Mutex<dyn Agent>>>

Returns the agent with the given ID, if registered.

Trait Implementations§

Source§

impl Default for AgentRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

Returns a reference to the inner value as &dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.