RigsofRods
Soft-body Physics Simulation
Public Member Functions | Private Member Functions | Private Attributes
RoR::VehicleAI Class Reference

#include <VehicleAI.h>

+ Inheritance diagram for RoR::VehicleAI:
+ Collaboration diagram for RoR::VehicleAI:

Public Member Functions

 VehicleAI (ActorPtr b)
 
virtual ~VehicleAI () override
 
void setActive (bool value)
 Activates/Deactivates the AI. More...
 
bool isActive ()
 Returns the status of the AI. More...
 
void addWaypoint (std::string const &id, Ogre::Vector3 const &point)
 Adds one waypoint. More...
 
void addWaypoints (AngelScript::CScriptDictionary &d)
 Adds a dictionary with waypoints. More...
 
void addEvent (std::string const &id, int ev)
 Adds a event. More...
 
void setValueAtWaypoint (std::string const &id, int value_id, float value)
 Sets a value at a waypoint. More...
 
Ogre::Vector3 getTranslation (int offset, unsigned int wp)
 Gets offset translation based on vehicle rotation and waypoints. More...
 
void update (float dt, int doUpdate)
 Updates the AI. More...
 
- Public Member Functions inherited from RefCountingObject< VehicleAI >
 RefCountingObject ()
 
virtual ~RefCountingObject ()
 
void AddRef ()
 
void Release ()
 

Private Member Functions

void updateWaypoint ()
 Updates the AI waypoint. More...
 

Private Attributes

bool is_waiting =false
 
float wait_time =0.f
 (seconds) The amount of time the AI has to wait. More...
 
float maxspeed = 50
 (KM/H) The max speed the AI is allowed to drive. More...
 
ActorPtr beam
 The verhicle the AI is driving. More...
 
bool is_enabled = false
 True if the AI is driving. More...
 
Ogre::Vector3 current_waypoint = Ogre::Vector3::ZERO
 The coordinates of the waypoint that the AI is driving to. More...
 
Ogre::Vector3 prev_waypoint = Ogre::Vector3::ZERO
 
Ogre::Vector3 next_waypoint = Ogre::Vector3::ZERO
 The coordinates of the previous waypoint. More...
 
int current_waypoint_id = 0
 The coordinates of the next waypoint. More...
 
std::map< int, Ogre::Vector3 > waypoints
 Map with all waypoints. More...
 
std::map< std::string, int > waypoint_ids
 Map with all waypoint IDs. More...
 
std::map< int, std::string > waypoint_names
 Map with all waypoint names. More...
 
std::map< int, int > waypoint_events
 Map with all waypoint events. More...
 
std::map< Ogre::String, float > waypoint_speed
 Map with all waypoint speeds. More...
 
std::map< int, float > waypoint_power
 Map with all waypoint engine power. More...
 
std::map< int, float > waypoint_wait_time
 Map with all waypoint wait times. More...
 
int free_waypoints = 0
 The amount of waypoints. More...
 
float acc_power = 0.8
 The engine power. More...
 
float init_y = 0
 
bool last_waypoint = false
 
bool hold = false
 

Additional Inherited Members

- Static Public Member Functions inherited from RefCountingObject< VehicleAI >
static void RegisterRefCountingObject (AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *name)
 
- Data Fields inherited from RefCountingObject< VehicleAI >
int m_refcount
 
std::mutex m_refcount_mtx
 

Detailed Description

Definition at line 61 of file VehicleAI.h.

Constructor & Destructor Documentation

◆ VehicleAI()

VehicleAI::VehicleAI ( ActorPtr  b)

Definition at line 41 of file VehicleAI.cpp.

◆ ~VehicleAI()

VehicleAI::~VehicleAI ( )
overridevirtual

Definition at line 48 of file VehicleAI.cpp.

Member Function Documentation

◆ addEvent()

void VehicleAI::addEvent ( std::string const &  id,
int  ev 
)

Adds a event.

Parameters
idThe waypoint ID.
evThe ID of the event.
See also
Ai_events

Definition at line 127 of file VehicleAI.cpp.

◆ addWaypoint()

void VehicleAI::addWaypoint ( std::string const &  id,
Ogre::Vector3 const &  point 
)

Adds one waypoint.

Parameters
[in]idThe waypoint ID.
[in]pointThe coordinates of the waypoint.

Definition at line 63 of file VehicleAI.cpp.

+ Here is the caller graph for this function:

◆ addWaypoints()

void VehicleAI::addWaypoints ( AngelScript::CScriptDictionary &  d)

Adds a dictionary with waypoints.

Parameters
dDictionary with waypoints (string ID -> vector3 pos)

Definition at line 74 of file VehicleAI.cpp.

+ Here is the call graph for this function:

◆ getTranslation()

Ogre::Vector3 VehicleAI::getTranslation ( int  offset,
unsigned int  wp 
)

Gets offset translation based on vehicle rotation and waypoints.

Parameters
offsetThe offset.
wpThe waypoint.

Definition at line 85 of file VehicleAI.cpp.

+ Here is the call graph for this function:

◆ isActive()

bool VehicleAI::isActive ( )

Returns the status of the AI.

Returns
True if the AI is driving

Definition at line 58 of file VehicleAI.cpp.

+ Here is the caller graph for this function:

◆ setActive()

void VehicleAI::setActive ( bool  value)

Activates/Deactivates the AI.

Parameters
[in]valueActivate or deactivation the AI

Definition at line 52 of file VehicleAI.cpp.

+ Here is the call graph for this function:

◆ setValueAtWaypoint()

void VehicleAI::setValueAtWaypoint ( std::string const &  id,
int  value_id,
float  value 
)

Sets a value at a waypoint.

Parameters
idThe waypoint ID.
value_idThe ID of the value that will be set.
valueThe value itself.
See also
Ai_values

Definition at line 134 of file VehicleAI.cpp.

◆ update()

void VehicleAI::update ( float  dt,
int  doUpdate 
)

Updates the AI.

Definition at line 216 of file VehicleAI.cpp.

+ Here is the call graph for this function:

◆ updateWaypoint()

void VehicleAI::updateWaypoint ( )
private

Updates the AI waypoint.

Definition at line 153 of file VehicleAI.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ acc_power

float RoR::VehicleAI::acc_power = 0.8
private

The engine power.

Definition at line 155 of file VehicleAI.h.

◆ beam

ActorPtr RoR::VehicleAI::beam
private

The verhicle the AI is driving.

Definition at line 141 of file VehicleAI.h.

◆ current_waypoint

Ogre::Vector3 RoR::VehicleAI::current_waypoint = Ogre::Vector3::ZERO
private

The coordinates of the waypoint that the AI is driving to.

Definition at line 143 of file VehicleAI.h.

◆ current_waypoint_id

int RoR::VehicleAI::current_waypoint_id = 0
private

The coordinates of the next waypoint.

The curent waypoint ID.

Definition at line 146 of file VehicleAI.h.

◆ free_waypoints

int RoR::VehicleAI::free_waypoints = 0
private

The amount of waypoints.

Definition at line 154 of file VehicleAI.h.

◆ hold

bool RoR::VehicleAI::hold = false
private

Definition at line 158 of file VehicleAI.h.

◆ init_y

float RoR::VehicleAI::init_y = 0
private

Definition at line 156 of file VehicleAI.h.

◆ is_enabled

bool RoR::VehicleAI::is_enabled = false
private

True if the AI is driving.

Definition at line 142 of file VehicleAI.h.

◆ is_waiting

bool RoR::VehicleAI::is_waiting =false
private

Definition at line 137 of file VehicleAI.h.

◆ last_waypoint

bool RoR::VehicleAI::last_waypoint = false
private

Definition at line 157 of file VehicleAI.h.

◆ maxspeed

float RoR::VehicleAI::maxspeed = 50
private

(KM/H) The max speed the AI is allowed to drive.

Definition at line 140 of file VehicleAI.h.

◆ next_waypoint

Ogre::Vector3 RoR::VehicleAI::next_waypoint = Ogre::Vector3::ZERO
private

The coordinates of the previous waypoint.

Definition at line 145 of file VehicleAI.h.

◆ prev_waypoint

Ogre::Vector3 RoR::VehicleAI::prev_waypoint = Ogre::Vector3::ZERO
private

Definition at line 144 of file VehicleAI.h.

◆ wait_time

float RoR::VehicleAI::wait_time =0.f
private

(seconds) The amount of time the AI has to wait.

Definition at line 138 of file VehicleAI.h.

◆ waypoint_events

std::map<int, int> RoR::VehicleAI::waypoint_events
private

Map with all waypoint events.

Definition at line 150 of file VehicleAI.h.

◆ waypoint_ids

std::map<std::string, int> RoR::VehicleAI::waypoint_ids
private

Map with all waypoint IDs.

Definition at line 148 of file VehicleAI.h.

◆ waypoint_names

std::map<int, std::string> RoR::VehicleAI::waypoint_names
private

Map with all waypoint names.

Definition at line 149 of file VehicleAI.h.

◆ waypoint_power

std::map<int, float> RoR::VehicleAI::waypoint_power
private

Map with all waypoint engine power.

Definition at line 152 of file VehicleAI.h.

◆ waypoint_speed

std::map<Ogre::String, float> RoR::VehicleAI::waypoint_speed
private

Map with all waypoint speeds.

Definition at line 151 of file VehicleAI.h.

◆ waypoint_wait_time

std::map<int, float> RoR::VehicleAI::waypoint_wait_time
private

Map with all waypoint wait times.

Definition at line 153 of file VehicleAI.h.

◆ waypoints

std::map<int, Ogre::Vector3> RoR::VehicleAI::waypoints
private

Map with all waypoints.

Definition at line 147 of file VehicleAI.h.


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