Skip to main content

NpcState

Enum NpcState 

Source
pub enum NpcState {
    Bored,
    Happy,
    Mad,
    Normal,
    Sad,
    Tired,
    Custom(String),
}
Expand description

Represents the demeanor of an ‘Npc’, which may affect default dialogue and behavior.

NPC states affect which dialogue lines are given in response to a TalkTo command. They can also be used as trigger conditions, and state can be changed by triggers. Room overlays can also change according to NPC presence / state. Custom states allow for other “moods” and can be used to pin selections of dialogue to particular game states. Ex: player does something -> puzzle advanced to puzzle#2 -> trigger sets custom NPC state “player_at_puzzle_step_2” which has specific dialogue.

Variants§

§

Bored

§

Happy

§

Mad

§

Normal

§

Sad

§

Tired

§

Custom(String)

Implementations§

Source§

impl NpcState

Source

pub fn is_bored(&self) -> bool

Source

pub fn is_not_bored(&self) -> bool

Source

pub fn and_bored(self, and: Self) -> Self

Source

pub fn or_bored(self, or: Self) -> Self

Source

pub fn is_happy(&self) -> bool

Source

pub fn is_not_happy(&self) -> bool

Source

pub fn and_happy(self, and: Self) -> Self

Source

pub fn or_happy(self, or: Self) -> Self

Source

pub fn is_mad(&self) -> bool

Source

pub fn is_not_mad(&self) -> bool

Source

pub fn and_mad(self, and: Self) -> Self

Source

pub fn or_mad(self, or: Self) -> Self

Source

pub fn is_normal(&self) -> bool

Source

pub fn is_not_normal(&self) -> bool

Source

pub fn and_normal(self, and: Self) -> Self

Source

pub fn or_normal(self, or: Self) -> Self

Source

pub fn is_sad(&self) -> bool

Source

pub fn is_not_sad(&self) -> bool

Source

pub fn and_sad(self, and: Self) -> Self

Source

pub fn or_sad(self, or: Self) -> Self

Source

pub fn is_tired(&self) -> bool

Source

pub fn is_not_tired(&self) -> bool

Source

pub fn and_tired(self, and: Self) -> Self

Source

pub fn or_tired(self, or: Self) -> Self

Source

pub fn custom(self) -> Option<String>

Source

pub fn custom_ref(&self) -> Option<&String>

Source

pub fn custom_mut(&mut self) -> Option<&mut String>

Source

pub fn custom_or<E>(self, or: E) -> Result<String, E>

Source

pub fn custom_or_else<E, F: FnOnce() -> E>( self, or_else: F, ) -> Result<String, E>

Source

pub fn custom_ref_or<E>(&self, or: E) -> Result<&String, E>

Source

pub fn custom_mut_or<E>(&mut self, or: E) -> Result<&mut String, E>

Source

pub fn custom_ref_or_else<E, F: FnOnce() -> E>( &self, or_else: F, ) -> Result<&String, E>

Source

pub fn custom_mut_or_else<E, F: FnOnce() -> E>( &mut self, or_else: F, ) -> Result<&mut String, E>

Source

pub fn and_then_custom<F: FnOnce(String) -> String>(self, and_then: F) -> Self

Source

pub fn expect_custom(self, msg: &str) -> String

Source

pub fn ok_custom(self) -> Option<String>

👎Deprecated since 0.2.0:

Please use the derived NpcState::custom method instead. This method will be removed in 1.0.0 or next pre-stable minor bump.

Source

pub fn ok_or_custom<E>(self, or: E) -> Result<String, E>

👎Deprecated since 0.2.0:

Please use the derived NpcState::custom_or method instead. This method will be removed in 1.0.0 or next pre-stable minor bump.

Source

pub fn ok_or_else_custom<E, F: FnOnce() -> E>( self, or_else: F, ) -> Result<String, E>

👎Deprecated since 0.2.0:

Please use the derived NpcState::custom_or_else method instead. This method will be removed in 1.0.0 or next pre-stable minor bump.

Source

pub fn or_else_custom<F: FnOnce() -> String>(self, or_else: F) -> Self

Source

pub fn unwrap_custom(self) -> String

Source

pub fn unwrap_or_custom(self, or: String) -> String

Source

pub fn unwrap_or_else_custom<F: FnOnce() -> String>(self, or_else: F) -> String

Source

pub fn is_custom(&self) -> bool

Source

pub fn is_not_custom(&self) -> bool

Source

pub fn and_custom(self, and: Self) -> Self

Source

pub fn or_custom(self, or: Self) -> Self

Source§

impl NpcState

Source

pub fn from_key(key: &str) -> Self

Parse a dialogue map key into an NpcState.

Source

pub fn as_key(&self) -> String

Serialize the state into a dialogue map key.

Trait Implementations§

Source§

impl Clone for NpcState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NpcState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for NpcState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for NpcState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for NpcState

Source§

impl Hash for NpcState

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NpcState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for NpcState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for NpcState

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
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V