Struct veloren_common::comp::agent::Behavior
source · pub struct Behavior {
capabilities: BehaviorCapability,
state: BehaviorState,
pub trading_behavior: TradingBehavior,
}
Expand description
§Behavior Component
This component allow an Entity to register one or more behavior tags. These tags act as flags of what an Entity can do, or what it is doing. Behaviors Tags can be added and removed as the Entity lives, to update its state when needed
Fields§
§capabilities: BehaviorCapability
§state: BehaviorState
§trading_behavior: TradingBehavior
Implementations§
source§impl Behavior
impl Behavior
sourcepub fn maybe_with_capabilities(
self,
maybe_capabilities: Option<BehaviorCapability>,
) -> Self
pub fn maybe_with_capabilities( self, maybe_capabilities: Option<BehaviorCapability>, ) -> Self
Builder function Set capabilities if Option is Some
sourcepub fn with_trade_site(self, trade_site: Option<SiteId>) -> Self
pub fn with_trade_site(self, trade_site: Option<SiteId>) -> Self
Builder function Set trade_site if Option is Some
sourcepub fn allow(&mut self, capabilities: BehaviorCapability)
pub fn allow(&mut self, capabilities: BehaviorCapability)
Set capabilities to the Behavior
sourcepub fn deny(&mut self, capabilities: BehaviorCapability)
pub fn deny(&mut self, capabilities: BehaviorCapability)
Unset capabilities to the Behavior
sourcepub fn can(&self, capabilities: BehaviorCapability) -> bool
pub fn can(&self, capabilities: BehaviorCapability) -> bool
Check if the Behavior is able to do something
sourcepub fn can_trade(&self, alignment: Option<Alignment>, counterparty: Uid) -> bool
pub fn can_trade(&self, alignment: Option<Alignment>, counterparty: Uid) -> bool
Check if the Behavior is able to trade
sourcepub fn set(&mut self, state: BehaviorState)
pub fn set(&mut self, state: BehaviorState)
Set a state to the Behavior
sourcepub fn unset(&mut self, state: BehaviorState)
pub fn unset(&mut self, state: BehaviorState)
Unset a state to the Behavior
sourcepub fn is(&self, state: BehaviorState) -> bool
pub fn is(&self, state: BehaviorState) -> bool
Check if the Behavior has a specific state
sourcepub fn trade_site(&self) -> Option<SiteId>
pub fn trade_site(&self) -> Option<SiteId>
Get the trade site at which this behavior evaluates prices, if it does
Trait Implementations§
source§impl From<BehaviorCapability> for Behavior
impl From<BehaviorCapability> for Behavior
source§fn from(capabilities: BehaviorCapability) -> Self
fn from(capabilities: BehaviorCapability) -> Self
Converts to this type from the input type.
impl Copy for Behavior
Auto Trait Implementations§
impl Freeze for Behavior
impl RefUnwindSafe for Behavior
impl Send for Behavior
impl Sync for Behavior
impl Unpin for Behavior
impl UnwindSafe for Behavior
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default
and panics on an error case.