Function veloren_rtsim::ai::now

source ·
pub fn now<S, R, F, A: Action<S, R>>(f: F) -> Now<F, A>
where F: Fn(&mut NpcCtx<'_>, &mut S) -> A + Send + Sync + 'static,
Expand description

Start a new action based on the state of the world (ctx) at the moment the action is started.

If you’re in a situation where you suddenly find yourself needing ctx, you probably want to use this.

§Example

// An action that makes an NPC immediately travel to its *current* home
now(|ctx| goto(ctx.npc.home))