AI Entity

AI entity is a basic object which can execute behaviors. Behaviors might be provided by user via setter or by assigned reasoner.

Public Interface

Reasoner [get/set]

This entity’s assigned reasoner.

Behavior [get/set]

This entity’s assigned behavior.

Blackboard [get/set]

This entity’s blackboard.

Shared Blackboards [get/set]

Shared blackboards to which this entity is subscribed.

Has Active Behavior

Returns true if this entity is executing legal behavior.

Add Shared Blackboard

Inserts pair of key and blackboard into container of shared blackboards.

Get Shared Blackboard

Gets shared blackboard identified by given key.

Move Suspended Behavior

Gets reference to previously assigned behavior.

Stage Behavior

Finishes current behavior and starts new one.

Has Staged Behavior

Checks whether this entity has behavior awaiting its execution.

Add Reasoner Change Observer

Adds reasoner change observer that will be notified via calling OnReasonerSet function when new reasoner will be assigned to entity.

Remove Reasoner Change Observer

Removes reasoner change observer so it won’t be notified of reasoner changes anymore.

Reset Next Id

Resets available entity IDs. Useful when the game should be restarted but entities were not destroyed, like ending Play in Editor or soft restarting level.

Tips

Registering entity in manager

Entity should be registered in AI manager to properly work.

  • C++

  • C#

auto entity = std::make_shared<grail::AIEntity>();
manager.RegisterAIEntity(entity, 0); //registered entity with priority 0
manager.UpdatePlayingModels(); //Update entities' playing models - let them think
manager.UpdateEntities(1.0f); //Update entities and their behaviors indicating that previous update was 1 second ago.
var entity = new Grail.AIEntity();
manager.RegisterAIEntity(entity, 0); //registered entity with priority 0
manager.UpdatePlayingModels(); //Update entities' playing models - let them think
manager.UpdateEntities(1.0f); //Update entities and their behaviors indicating that previous update was 1 second ago.
Each entity can be registered in more than one manager. This can help users LOD their AI.

Entity =/= Character

In-game character does not necessarily need to be represented by only one entity. Entities can represent just some of the functions a full character has.

In a twin stick shooter the user can create two entities: one responsible for movement and one for shooting. A single in-game character will consist of those two entities, because they can make decisions independently. If they should make decisions in cooperation, the user can connect them to the same shared blackboard and let them communicate through it.

API Reference