SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ai::ICharacter Class Reference

Class that should be extended by the AI controlled entity class. More...

#include <ICharacter.h>

Inheritance diagram for ai::ICharacter:
[legend]
Collaboration diagram for ai::ICharacter:
[legend]

Public Member Functions

 ICharacter (CharacterId id)
 
bool operator== (const ICharacter &character) const
 
bool operator!= (const ICharacter &character) const
 
CharacterId getId () const
 
virtual void setPosition (const glm::vec3 &position)
 
const glm::vec3 & getPosition () const
 
virtual void setOrientation (float orientation)
 
float getOrientation () const
 
virtual void setSpeed (float speed)
 Sets the speed for the character in m/s. More...
 
float getSpeed () const
 
virtual void setAttribute (const std::string &key, const std::string &value)
 Set an attribute that can be used for debugging. More...
 
const CharacterAttributes & getAttributes () const
 Get the debugger attributes.
 
virtual void update (int64_t dt, bool debuggingActive)
 override this method to let your own ICharacter implementation tick with the Zone::update More...
 
std::shared_ptr< ICharacterptr ()
 

Protected Attributes

const CharacterId _id
 
glm::vec3 _position
 
std::atomic< float > _orientation
 
std::atomic< float > _speed
 
CharacterAttributes _attributes
 

Detailed Description

Class that should be extended by the AI controlled entity class.

It uses a CharacterId to identify the character in the game. The AI class has a reference to its controlled ICharacter instance.

Note
Update the values of the ICharacter class only in in the ICharacter::update() method or from within the Zone callbacks. Otherwise you will run into race conditions if you run with multiple threads.

You often need access to your world your character is living in. You need access to this data to resolve the CharacterId's in the IFilter implementations, to interact with other entities that are not SimpleAI controlled and so on. You can use the provided character_cast function in your TreeNode, IFilter or ICondition implementations.

Member Function Documentation

float ai::ICharacter::getOrientation ( ) const
inline
Returns
the radians around the y (up) axis
See Also
setOrientation()
float ai::ICharacter::getSpeed ( ) const
inline
Returns
The speed for the character in m/s
See Also
setSpeed()
std::shared_ptr<ICharacter> ai::ICharacter::ptr ( )
inline

If the object is currently maintained by a shared_ptr, you can get a shared_ptr from a raw pointer instance that shares the state with the already existing shared_ptrs around.

void ai::ICharacter::setAttribute ( const std::string &  key,
const std::string &  value 
)
inlinevirtual

Set an attribute that can be used for debugging.

See Also
AI::isDebuggingActive()
void ai::ICharacter::setOrientation ( float  orientation)
inlinevirtual
Note
This is virtual because you might want to override this in your implementation to make sure that the new orientation is also forwarded to your AI controlled entity.
See Also
getOrientation()
void ai::ICharacter::setPosition ( const glm::vec3 &  position)
inlinevirtual
Note
This is virtual because you might want to override this in your implementation to make sure that the new position is also forwarded to your AI controlled entity.
void ai::ICharacter::setSpeed ( float  speed)
inlinevirtual

Sets the speed for the character in m/s.

See Also
getSpeed()
virtual void ai::ICharacter::update ( int64_t  dt,
bool  debuggingActive 
)
inlinevirtual

override this method to let your own ICharacter implementation tick with the Zone::update

Parameters
[in]dtthe time delta in millis since the last update was executed
[in]debuggingActivetrue if the debugging for this entity is activated. This can be used to determine whether it's useful to do setAttribute() calls.

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