Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::goap::Action Class Reference

#include <Action.h>

+ Inheritance diagram for Divide::goap::Action:

Public Types

using operations = hashMap< I32, bool >
 
using operationsIterator = hashMap< I32, bool >::const_iterator
 

Public Member Functions

virtual ~Action ()=default
 
 Action (const Action &)=default
 
Actionoperator= (const Action &)=default
 
 Action () noexcept
 
 Action (const string &name, I32 cost)
 
bool eligibleFor (const goap::WorldState &ws) const
 
WorldState actOn (const WorldState &ws) const
 
void setPrecondition (const I32 key, const bool value)
 
void setEffect (const I32 key, const bool value)
 
const operationseffects () const noexcept
 
int cost () const noexcept
 
const stringname () const noexcept
 
virtual bool checkImplDependentCondition () const
 

Private Attributes

string name_
 
I32 cost_
 
operations preconditions_
 
operations effects_
 

Detailed Description

Definition at line 15 of file Action.h.

Member Typedef Documentation

◆ operations

Definition at line 17 of file Action.h.

◆ operationsIterator

using Divide::goap::Action::operationsIterator = hashMap<I32, bool>::const_iterator

Definition at line 18 of file Action.h.

Constructor & Destructor Documentation

◆ ~Action()

virtual Divide::goap::Action::~Action ( )
virtualdefault

◆ Action() [1/3]

Divide::goap::Action::Action ( const Action )
default

◆ Action() [2/3]

Action::Action ( )
noexcept

Definition at line 9 of file Action.cpp.

◆ Action() [3/3]

Action::Action ( const string name,
I32  cost 
)

Definition at line 14 of file Action.cpp.

Member Function Documentation

◆ actOn()

WorldState Action::actOn ( const WorldState ws) const

Act on the given worldstate. Will not check for "eligiblity" and will happily act on whatever worldstate you provide it.

Parameters
wsthe worldstate to act on
Returns
a copy worldstate, with effects applied

Definition at line 39 of file Action.cpp.

◆ checkImplDependentCondition()

virtual bool Divide::goap::Action::checkImplDependentCondition ( ) const
inlinevirtual

Reimplemented in Divide::AI::WarSceneAction.

Definition at line 74 of file Action.h.

◆ cost()

int Divide::goap::Action::cost ( ) const
inlinenoexcept

Definition at line 70 of file Action.h.

◆ effects()

const operations & Divide::goap::Action::effects ( ) const
inlinenoexcept

Definition at line 68 of file Action.h.

◆ eligibleFor()

bool Action::eligibleFor ( const goap::WorldState ws) const

Is this action eligible to operate on the given worldstate?

Parameters
wsthe worldstate in question
Returns
true if this worldstate meets the preconditions

Definition at line 21 of file Action.cpp.

◆ name()

const string & Divide::goap::Action::name ( ) const
inlinenoexcept

Definition at line 72 of file Action.h.

◆ operator=()

Action & Divide::goap::Action::operator= ( const Action )
default

◆ setEffect()

void Divide::goap::Action::setEffect ( const I32  key,
const bool  value 
)
inline

Set the given effect of this action, in terms of variable and new value.

Parameters
keythe name of the effect
valuethe value that will result

Definition at line 66 of file Action.h.

◆ setPrecondition()

void Divide::goap::Action::setPrecondition ( const I32  key,
const bool  value 
)
inline

Set the given precondition variable and value.

Parameters
keythe name of the precondition
valuethe value the precondition must hold

Definition at line 59 of file Action.h.

Member Data Documentation

◆ cost_

I32 Divide::goap::Action::cost_
private

Definition at line 26 of file Action.h.

◆ effects_

operations Divide::goap::Action::effects_
private

Definition at line 33 of file Action.h.

◆ name_

string Divide::goap::Action::name_
private

Definition at line 25 of file Action.h.

◆ preconditions_

operations Divide::goap::Action::preconditions_
private

Definition at line 30 of file Action.h.


The documentation for this class was generated from the following files: