RigsofRods
Soft-body Physics Simulation
VehicleAiAngelscript.cpp
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2022 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "VehicleAI.h"
23 #include "AngelScriptBindings.h"
24 #include <angelscript.h>
25 
26 using namespace AngelScript;
27 
28 void RoR::RegisterVehicleAi(asIScriptEngine *engine)
29 {
30  int result;
31 
32  // enum aiEvents
33  result = engine->RegisterEnum("aiEvents"); ROR_ASSERT(result >= 0);
34  result = engine->RegisterEnumValue("aiEvents", "AI_LIGHTSTOGGLE", AI_LIGHTSTOGGLE); ROR_ASSERT(result >= 0);
35  result = engine->RegisterEnumValue("aiEvents", "AI_WAIT_SECONDS", AI_WAIT_SECONDS); ROR_ASSERT(result >= 0);
36  result = engine->RegisterEnumValue("aiEvents", "AI_BEACONSTOGGLE", AI_BEACONSTOGGLE); ROR_ASSERT(result >= 0);
37 
38  // enum aiEvents
39  result = engine->RegisterEnum("AiValues"); ROR_ASSERT(result >= 0);
40  result = engine->RegisterEnumValue("AiValues", "AI_SPEED", AI_SPEED); ROR_ASSERT(result >= 0);
41  result = engine->RegisterEnumValue("AiValues", "AI_POWER", AI_POWER); ROR_ASSERT(result >= 0);
42 
43  // (ref object) VehicleAI
44  VehicleAI::RegisterRefCountingObject(engine, "VehicleAIClass");
45  VehicleAIPtr::RegisterRefCountingObjectPtr(engine, "VehicleAIClassPtr", "VehicleAIClass");
46 
47  // PLEASE maintain the same order as in 'VehicleAI.h' and 'doc/../VehicleAIClass.h'
48  result = engine->RegisterObjectMethod("VehicleAIClass", "void setActive(bool)", asMETHOD(VehicleAI, setActive), asCALL_THISCALL); ROR_ASSERT(result >= 0);
49  result = engine->RegisterObjectMethod("VehicleAIClass", "bool isActive()", asMETHOD(VehicleAI, isActive), asCALL_THISCALL); ROR_ASSERT(result >= 0);
50  result = engine->RegisterObjectMethod("VehicleAIClass", "void addWaypoint(const string &in id, const vector3 &in pos)", asMETHOD(VehicleAI, addWaypoint), asCALL_THISCALL); ROR_ASSERT(result >= 0);
51  result = engine->RegisterObjectMethod("VehicleAIClass", "void addWaypoints(dictionary &in d)", asMETHOD(VehicleAI, addWaypoints), asCALL_THISCALL); ROR_ASSERT(result >= 0);
52  result = engine->RegisterObjectMethod("VehicleAIClass", "void addEvent(const string &in id,int ev)", asMETHOD(VehicleAI, addEvent), asCALL_THISCALL); ROR_ASSERT(result >= 0);
53  result = engine->RegisterObjectMethod("VehicleAIClass", "void setValueAtWaypoint(const string &in id, int value_id, float value)", asMETHOD(VehicleAI, setValueAtWaypoint), asCALL_THISCALL); ROR_ASSERT(result >= 0);
54  result = engine->RegisterObjectMethod("VehicleAIClass", "vector3 getTranslation(int offset, uint wp)", AngelScript::asMETHOD(VehicleAI, getTranslation), asCALL_THISCALL); ROR_ASSERT(result >= 0);
55 
56 }
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
RoR::AI_WAIT_SECONDS
@ AI_WAIT_SECONDS
Definition: VehicleAI.h:48
RoR::RegisterVehicleAi
void RegisterVehicleAi(AngelScript::asIScriptEngine *engine)
defined in VehicleAiAngelscript.cpp
VehicleAI.h
Simple waypoint AI.
AngelScriptBindings.h
RoR::AI_BEACONSTOGGLE
@ AI_BEACONSTOGGLE
Definition: VehicleAI.h:49
RoR::AI_POWER
@ AI_POWER
Definition: VehicleAI.h:58
RoR::AI_SPEED
@ AI_SPEED
Definition: VehicleAI.h:57
RoR::AI_LIGHTSTOGGLE
@ AI_LIGHTSTOGGLE
Definition: VehicleAI.h:47