use crate::agent::Agent;
use crate::types::AgentId;
pub enum DeferredAction<A> {
RemoveAgent(AgentId),
InsertAgent(A),
}
pub struct StepContext<'a, S, A, Props, R, Sch>
where
A: Agent,
{
pub(crate) space: &'a mut S,
pub(crate) properties: &'a mut Props,
pub(crate) rng: &'a mut R,
pub(crate) scheduler: &'a mut Sch,
pub(crate) deferred: &'a mut Vec<DeferredAction<A>>,
pub(crate) _agent: std::marker::PhantomData<A>,
}
impl<'a, S, A, Props, R, Sch> StepContext<'a, S, A, Props, R, Sch>
where
A: Agent,
{
pub fn space(&self) -> &S {
self.space
}
pub fn space_mut(&mut self) -> &mut S {
self.space
}
pub fn properties(&self) -> &Props {
self.properties
}
pub fn properties_mut(&mut self) -> &mut Props {
self.properties
}
pub fn rng(&mut self) -> &mut R {
self.rng
}
pub fn scheduler(&mut self) -> &mut Sch {
self.scheduler
}
pub fn defer_remove_agent(&mut self, id: AgentId) {
self.deferred.push(DeferredAction::RemoveAgent(id));
}
pub fn defer_insert_agent(&mut self, agent: A) {
self.deferred.push(DeferredAction::InsertAgent(agent));
}
}