Skip to main content

BehaviorCx

Struct BehaviorCx 

pub struct BehaviorCx<'a> { /* private fields */ }
Expand description

What a Behavior runs with: its mob and the tick’s read view — the same mob-tick view crate::GoalContext is (the ticking mob itself, the player the tick sees, the snapshot of the others), with the brain’s own memories typed on top. Writes go through the engine’s own setters.

Implementations§

§

impl<'a> BehaviorCx<'a>

pub fn mob(&self) -> MobRef

The mob this behavior runs on, a fresh handle each call.

pub fn host(&self) -> &dyn Host

The read view of the mob’s tick, as crate::GoalContext::host.

pub fn walk_target(&self) -> Option<BrainWalkTarget>

WALK_TARGET, where the brain walks to.

pub fn look_target(&self) -> Option<[f64; 3]>

LOOK_TARGET, the position the brain looks at.

pub fn attack_target(&self) -> Option<LivingRef>

ATTACK_TARGET, the living entity the brain attacks, as the tick’s view resolves it.

pub fn set_brain_target(&mut self, target: Option<LivingRef>) -> bool

set_brain_target on the mob’s own handle: writes the brain’s ATTACK_TARGET memory through the engine’s setter, with its refusals (a species whose brain keeps no attack target refuses, as the write handle does). None clears it.

pub fn set_walk_target(&mut self, at: [i32; 3], speed: f64, close: i32)

SetWalkTarget: writes the brain’s WALK_TARGET memory through the engine’s own path, where the brain’s walk sink takes it from.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for BehaviorCx<'a>

§

impl<'a> !Send for BehaviorCx<'a>

§

impl<'a> !Sync for BehaviorCx<'a>

§

impl<'a> !UnwindSafe for BehaviorCx<'a>

§

impl<'a> Freeze for BehaviorCx<'a>

§

impl<'a> Unpin for BehaviorCx<'a>

§

impl<'a> UnsafeUnpin for BehaviorCx<'a>

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
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.