Peoplemon  0.1.0
Peoplemon 3 game source documentation
Public Member Functions | List of all members
core::system::AI Class Reference

Manages NPC's and trainers and their behaviors. More...

#include <AI.hpp>

+ Inheritance diagram for core::system::AI:

Public Member Functions

 AI (Systems &owner)
 Construct a new AI system. More...
 
virtual ~AI ()=default
 Destroys the system. More...
 
bool addBehavior (bl::ecs::Entity entity, const file::Behavior &behavior)
 Helper function for adding the given behavior to the given entity. More...
 
bool makeStanding (bl::ecs::Entity entity, bl::tmap::Direction dir)
 Makes the given entity stand in place. Replaces any existing behavior on the entity. More...
 
bool makeSpinning (bl::ecs::Entity entity, file::Behavior::Spinning::Direction dir)
 Makes the given entity spin in place. Replaces any existing behavior. More...
 
bool makeFollowPath (bl::ecs::Entity entity, const file::Behavior::Path &path)
 Make the entity follow a fixed path. Replaces existing behavior. More...
 
bool makeWander (bl::ecs::Entity entity, unsigned int radius)
 Makes the given entity wander around within the given radius. Replaces any existing behavior the entity may have. More...
 
bool moveToPosition (bl::ecs::Entity entity, const bl::tmap::Position &dest)
 Uses a pathfinder to navigate the entity to the given position and end up facing the given direction. The existing behavior is locked and left in the locked state when the path is completed. More...
 
void removeAi (bl::ecs::Entity ent)
 Removes any ai behavior from the given entity. Does not affect path finding. More...
 

Detailed Description

Manages NPC's and trainers and their behaviors.

Definition at line 25 of file AI.hpp.

Constructor & Destructor Documentation

◆ AI()

core::system::AI::AI ( Systems owner)

Construct a new AI system.

Parameters
ownerThe primary systems object

Definition at line 26 of file AI.cpp.

◆ ~AI()

virtual core::system::AI::~AI ( )
virtualdefault

Destroys the system.

Member Function Documentation

◆ addBehavior()

bool core::system::AI::addBehavior ( bl::ecs::Entity  entity,
const file::Behavior behavior 
)

Helper function for adding the given behavior to the given entity.

Parameters
entityThe entity to add the behavior to
behaviorThe behavior to add
Returns
True if the behavior was able to be added, false otherwise

Definition at line 100 of file AI.cpp.

◆ makeFollowPath()

bool core::system::AI::makeFollowPath ( bl::ecs::Entity  entity,
const file::Behavior::Path path 
)

Make the entity follow a fixed path. Replaces existing behavior.

Parameters
entityThe entity to go on the path
pathThe path to follow
Returns
True if the behavior was added, false otherwise

Definition at line 136 of file AI.cpp.

◆ makeSpinning()

bool core::system::AI::makeSpinning ( bl::ecs::Entity  entity,
file::Behavior::Spinning::Direction  dir 
)

Makes the given entity spin in place. Replaces any existing behavior.

Parameters
entityThe entity to spin
dirThe direction to spin in
Returns
True if the behavior was able to be added, false otherwise

Definition at line 126 of file AI.cpp.

◆ makeStanding()

bool core::system::AI::makeStanding ( bl::ecs::Entity  entity,
bl::tmap::Direction  dir 
)

Makes the given entity stand in place. Replaces any existing behavior on the entity.

Parameters
entityThe entity to stand in place
dirThe direction to face
Returns
True if the behavior was able to be added, false otherwise

Definition at line 115 of file AI.cpp.

◆ makeWander()

bool core::system::AI::makeWander ( bl::ecs::Entity  entity,
unsigned int  radius 
)

Makes the given entity wander around within the given radius. Replaces any existing behavior the entity may have.

Parameters
entityThe entity to wander around
radiusThe radius to stay within, in tiles
Returns
True if the behavior was able to be added, false otherwise

Definition at line 146 of file AI.cpp.

◆ moveToPosition()

bool core::system::AI::moveToPosition ( bl::ecs::Entity  entity,
const bl::tmap::Position &  dest 
)

Uses a pathfinder to navigate the entity to the given position and end up facing the given direction. The existing behavior is locked and left in the locked state when the path is completed.

Parameters
entityThe entity to navigate
destThe position to navigate to
Returns
True if the controller was able to be added and the path is valid, false otherwise

Definition at line 164 of file AI.cpp.

◆ removeAi()

void core::system::AI::removeAi ( bl::ecs::Entity  ent)

Removes any ai behavior from the given entity. Does not affect path finding.

Parameters
entThe entity to remove behavior from

Definition at line 178 of file AI.cpp.


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