pub struct Action {
pub name: String,
pub cost: f32,
pub preconditions: WorldState,
pub effects: WorldState,
}Expand description
An action for GOAP planning
Fields§
§name: StringAction name
cost: f32Cost of the action
preconditions: WorldStatePreconditions that must be true
effects: WorldStateEffects applied after action
Implementations§
Source§impl Action
impl Action
Sourcepub fn with_precondition(self, key: impl Into<String>, value: bool) -> Self
pub fn with_precondition(self, key: impl Into<String>, value: bool) -> Self
Adds a precondition
Sourcepub fn with_effect(self, key: impl Into<String>, value: bool) -> Self
pub fn with_effect(self, key: impl Into<String>, value: bool) -> Self
Adds an effect
Sourcepub fn can_run(&self, state: &WorldState) -> bool
pub fn can_run(&self, state: &WorldState) -> bool
Checks if this action can run in the given state
Sourcepub fn apply(&self, state: &WorldState) -> WorldState
pub fn apply(&self, state: &WorldState) -> WorldState
Applies effects to a state
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Action
impl<'de> Deserialize<'de> for Action
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Action
Auto Trait Implementations§
impl Freeze for Action
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnwindSafe for Action
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