Interface IGoapAction
Implement this interface in every GOAP action (is required
so that the GOAP Planner can use it in its decision process
Namespace: Mars.Components.Services.Planning
Assembly: Mars.Components.dll
Syntax
public interface IGoapAction
Properties
| Improve this Doc View SourceCost
Cost of executing the action (used for
deciding which action chain will be
returned by the GOAP planner)
Declaration
float Cost { get; }
Property Value
Type | Description |
---|---|
System.Single |
Effects
List of effects this action has. This is the basic
for deciding whether an action is gonna be used
or not
Declaration
IDictionary<IGoapStateKey, GoapStateProperty> Effects { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<IGoapStateKey, GoapStateProperty> |
Preconditions
List of preconditions that have to be met in order
to execute this action
Declaration
IDictionary<IGoapStateKey, GoapStateProperty> Preconditions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<IGoapStateKey, GoapStateProperty> |
Methods
| Improve this Doc View SourceAddOrUpdateEffect(GoapStateProperty)
Adds an effect to this action or updates an existing effect with the same key.
Declaration
void AddOrUpdateEffect(GoapStateProperty effect)
Parameters
Type | Name | Description |
---|---|---|
GoapStateProperty | effect | Defines a specific aspect of the world. |
AddOrUpdatePrecondition(GoapStateProperty)
Adds a precondition to this action or updates an existing precondition with the same key.
Declaration
void AddOrUpdatePrecondition(GoapStateProperty precondition)
Parameters
Type | Name | Description |
---|---|---|
GoapStateProperty | precondition | Defines a specific aspect of the world. |
Execute()
Triggers the action code and updates the agentStates states with action effects if action was executed
successfully.
Declaration
bool Execute()
Returns
Type | Description |
---|---|
System.Boolean | True, if the execution was successful, false otherwise |
RemoveEffect(GoapStateProperty)
Removes an effect with given key if it exists.
Declaration
void RemoveEffect(GoapStateProperty effect)
Parameters
Type | Name | Description |
---|---|---|
GoapStateProperty | effect | The effect that should be removed. |
RemovePrecondition(GoapStateProperty)
Removes a precondition with given key if it exists.
Declaration
void RemovePrecondition(GoapStateProperty precondition)
Parameters
Type | Name | Description |
---|---|---|
GoapStateProperty | precondition | The precondition that should be removed. |
UpdateCost()
Is triggered to update the costs before every new search process. May be overwritten by subclasses to change the
costs depending on any situation.
Declaration
void UpdateCost()