new CompositeGoal(owner)
Constructs a new composite goal.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
owner |
GameEntity | null | The owner of this composite goal. |
Extends
Members
-
nullable owner :GameEntity
-
The owner of this goal.
- Overrides:
- Default Value:
- null
-
status :Status
-
The status of this goal.
- Overrides:
- Default Value:
- INACTIVE
-
subgoals :Array.<Goal>
-
A list of subgoals.
Methods
-
activate()
-
Executed when this goal is activated.
- Overrides:
-
activateIfInactive() → {Goal}
-
Ensures the goal is activated if it is inactive.
- Overrides:
-
active() → {Boolean}
-
Returns true if the status of this goal is ACTIVE.
Returns:
Boolean -Whether the goal is active or not.
- Overrides:
-
addSubgoal(goal) → {Goal}
-
Adds a goal as a subgoal to this instance.
Parameters:
Name Type Description goal
Goal The subgoal to add.
-
clearSubgoals() → {Goal}
-
Removes all subgoals and ensures Goal#terminate is called for each subgoal.
-
completed() → {Boolean}
-
Returns true if the status of this goal is COMPLETED.
Returns:
Boolean -Whether the goal is completed or not.
- Overrides:
-
currentSubgoal() → {Goal}
-
Returns the current subgoal. If no subgoals are defined, null is returned.
-
execute()
-
Executed in each simulation step.
- Overrides:
-
executeSubgoals() → {Status}
-
Executes the current subgoal of this composite goal.
Returns:
Status -The status of this composite subgoal.
-
failed() → {Boolean}
-
Returns true if the status of this goal is FAILED.
Returns:
Boolean -Whether the goal is failed or not.
- Overrides:
-
fromJSON(json) → {Goal}
-
Restores this instance from the given JSON object.
Parameters:
Name Type Description json
Object The JSON object.
- Overrides:
-
handleMessage() → {Boolean}
-
Returns true if the given message was processed by the current subgoal.
Returns:
Boolean -Whether the message was processed or not.
- Overrides:
-
hasSubgoals() → {Boolean}
-
Returns true if this composite goal has subgoals.
Returns:
Boolean -Whether the composite goal has subgoals or not.
-
inactive() → {Boolean}
-
Returns true if the status of this goal is INACTIVE.
Returns:
Boolean -Whether the goal is inactive or not.
- Overrides:
-
removeSubgoal(goal) → {Goal}
-
Removes a subgoal from this instance.
Parameters:
Name Type Description goal
Goal The subgoal to remove.
-
replanIfFailed() → {Goal}
-
Ensures the goal is replanned if it has failed.
- Overrides:
-
resolveReferences(entities) → {CompositeGoal}
-
Restores UUIDs with references to GameEntity objects.
Parameters:
Name Type Description entities
Map.<String, GameEntity> Maps game entities to UUIDs.
- Overrides:
-
terminate()
-
Executed when this goal is satisfied.
- Overrides:
-
toJSON() → {Object}
-
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.
- Overrides: