Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
GameScriptAngelscriptGeneric.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-2024 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 "../../autowrapper/aswrappedcall.h"
23#include "Actor.h"
24#include "AngelScriptBindings.h"
25#include "GameScript.h"
26#include "ScriptEngine.h"
27
28#include <angelscript.h>
29
30using namespace AngelScript;
31
32// We need to manually define a wrap function for getScriptVariable
33// since aswrappedcall.h has no support for functions with parameters
34// of type ?&out.
35static void getScriptVariable(asIScriptGeneric* gen)
36{
37 RoR::GameScript* obj = reinterpret_cast<RoR::GameScript*>(gen->GetObject());
38
39 // We'll use the proxy from aswrappedcall.h for strings.
40 const std::string& arg0 = static_cast<gw::Proxy<const std::string&>*>(gen->GetAddressOfArg(0))->value;
41 void** arg1ref = reinterpret_cast<void**>(gen->GetArgAddress(1));
42 int arg1id = gen->GetArgTypeId(1);
43 int arg2 = gen->GetArgDWord(2);
44 int ret = obj->getScriptVariable(arg0, arg1ref, arg1id, arg2);
45 gen->SetReturnDWord(ret);
46}
47
48void RoR::RegisterGameScriptGeneric(asIScriptEngine *engine)
49{
50 int result;
51
52 // class GameScript
53 result = engine->RegisterObjectType("GameScriptClass", sizeof(GameScript), asOBJ_REF | asOBJ_NOCOUNT); ROR_ASSERT(result >= 0);
54
55 // PLEASE maintain the same order as in GameScript.h!
56
57 // > General
58 result = engine->RegisterObjectMethod("GameScriptClass", "void log(const string &in)", WRAP_MFN(GameScript,log), asCALL_GENERIC); ROR_ASSERT(result>=0);
59 result = engine->RegisterObjectMethod("GameScriptClass", "float getTime()", WRAP_MFN(GameScript,getTime), asCALL_GENERIC); ROR_ASSERT(result>=0);
60 result = engine->RegisterObjectMethod("GameScriptClass", "void backToMenu()", WRAP_MFN(GameScript, backToMenu), asCALL_GENERIC); ROR_ASSERT(result >= 0);
61 result = engine->RegisterObjectMethod("GameScriptClass", "void quitGame()", WRAP_MFN(GameScript, quitGame), asCALL_GENERIC); ROR_ASSERT(result >= 0);
62 result = engine->RegisterObjectMethod("GameScriptClass", "float getFPS()", WRAP_MFN(GameScript, getFPS), asCALL_GENERIC); ROR_ASSERT(result >= 0);
63 result = engine->RegisterObjectMethod("GameScriptClass", "float getAvgFPS()", WRAP_MFN(GameScript, getAvgFPS), asCALL_GENERIC); ROR_ASSERT(result >= 0);
64 result = engine->RegisterObjectMethod("GameScriptClass", "float rangeRandom(float, float)", WRAP_MFN(GameScript,rangeRandom), asCALL_GENERIC); ROR_ASSERT(result>=0);
65 result = engine->RegisterObjectMethod("GameScriptClass", "int useOnlineAPI(const string &in, const dictionary &in, string &out)", WRAP_MFN(GameScript, useOnlineAPI), asCALL_GENERIC); ROR_ASSERT(result >= 0);
66 result = engine->RegisterObjectMethod("GameScriptClass", "void openUrlInDefaultBrowser(const string &in)", WRAP_MFN(GameScript, openUrlInDefaultBrowser), asCALL_GENERIC); ROR_ASSERT(result >= 0);
67 result = engine->RegisterObjectMethod("GameScriptClass", "bool pushMessage(MsgType, dictionary@)", WRAP_MFN(GameScript, pushMessage), asCALL_GENERIC); ROR_ASSERT(result >= 0);
68 result = engine->RegisterObjectMethod("GameScriptClass", "bool checkResourceExists(const string &in, const string &in)", WRAP_MFN(GameScript, checkResourceExists), asCALL_GENERIC); ROR_ASSERT(result >= 0);
69 result = engine->RegisterObjectMethod("GameScriptClass", "bool deleteResource(const string &in, const string &in)", WRAP_MFN(GameScript, deleteResource), asCALL_GENERIC); ROR_ASSERT(result >= 0);
70 result = engine->RegisterObjectMethod("GameScriptClass", "string loadTextResourceAsString(const string &in, const string &in)", WRAP_MFN(GameScript, loadTextResourceAsString), asCALL_GENERIC); ROR_ASSERT(result >= 0);
71 result = engine->RegisterObjectMethod("GameScriptClass", "bool createTextResourceFromString(const string &in, const string &in, const string &in, bool=false)", WRAP_MFN(GameScript, createTextResourceFromString), asCALL_GENERIC); ROR_ASSERT(result >= 0);
72 result = engine->RegisterObjectMethod("GameScriptClass", "Ogre::SceneManager@ getSceneManager()", WRAP_MFN(GameScript, getSceneManager), asCALL_GENERIC); ROR_ASSERT(result >= 0);
73 result = engine->RegisterObjectMethod("GameScriptClass", "array<dictionary>@ findResourceFileInfo(const string &in, const string &in, bool=false)", WRAP_MFN(GameScript, findResourceFileInfo), asCALL_GENERIC); ROR_ASSERT(result >= 0);
74 result = engine->RegisterObjectMethod("GameScriptClass", "void fetchUrlAsStringAsync(const string &in, const string &in)", WRAP_MFN(GameScript, fetchUrlAsStringAsync), asCALL_GENERIC); ROR_ASSERT(result >= 0);
75 result = engine->RegisterObjectMethod("GameScriptClass", "Ogre::Image loadImageResource(const string &in, const string &in)", WRAP_MFN(GameScript, loadImageResource), asCALL_GENERIC); ROR_ASSERT(result >= 0);
76 result = engine->RegisterObjectMethod("GameScriptClass", "bool serializeMeshResource(const string &in, const string &in, const Ogre::MeshPtr &in)", WRAP_MFN(GameScript, serializeMeshResource), asCALL_GENERIC); ROR_ASSERT(result >= 0);
77
78 // > GUI
79 result = engine->RegisterObjectMethod("GameScriptClass", "void flashMessage(const string &in, float, float)", WRAP_MFN(GameScript, flashMessage), asCALL_GENERIC); ROR_ASSERT(result >= 0);
80 result = engine->RegisterObjectMethod("GameScriptClass", "void message(const string &in, const string &in, float, bool)", WRAP_MFN(GameScript, message), asCALL_GENERIC); ROR_ASSERT(result >= 0);
81 result = engine->RegisterObjectMethod("GameScriptClass", "int getChatFontSize()", WRAP_MFN(GameScript, getChatFontSize), asCALL_GENERIC); ROR_ASSERT(result >= 0);
82 result = engine->RegisterObjectMethod("GameScriptClass", "void setChatFontSize(int)", WRAP_MFN(GameScript, setChatFontSize), asCALL_GENERIC); ROR_ASSERT(result >= 0);
83 result = engine->RegisterObjectMethod("GameScriptClass", "void showMessageBox(string &in, string &in, bool button1, string &in, bool AllowClose, bool button2,string &in)", WRAP_MFN(GameScript, showMessageBox), asCALL_GENERIC); ROR_ASSERT(result >= 0);
84 result = engine->RegisterObjectMethod("GameScriptClass", "void showChooser(const string &in, const string &in, const string &in)", WRAP_MFN(GameScript, showChooser), asCALL_GENERIC); ROR_ASSERT(result >= 0);
85 result = engine->RegisterObjectMethod("GameScriptClass", "void updateDirectionArrow(const string &in, vector3 &in)", WRAP_MFN(GameScript, updateDirectionArrow), asCALL_GENERIC); ROR_ASSERT(result >= 0);
86 result = engine->RegisterObjectMethod("GameScriptClass", "void hideDirectionArrow()", WRAP_MFN(GameScript, hideDirectionArrow), asCALL_GENERIC); ROR_ASSERT(result >= 0);
87 result = engine->RegisterObjectMethod("GameScriptClass", "bool getScreenPosFromWorldPos(const vector3&in, vector2&out)", WRAP_MFN(GameScript, getScreenPosFromWorldPos), asCALL_GENERIC); ROR_ASSERT(result >= 0);
88 result = engine->RegisterObjectMethod("GameScriptClass", "vector2 getDisplaySize()", WRAP_MFN(GameScript, getDisplaySize), asCALL_GENERIC); ROR_ASSERT(result >= 0);
89 result = engine->RegisterObjectMethod("GameScriptClass", "vector2 getMouseScreenPosition()", WRAP_MFN(GameScript, getMouseScreenPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
90
91 // > Script management
92 result = engine->RegisterObjectMethod("GameScriptClass", "void registerForEvent(int)", WRAP_MFN(GameScript, registerForEvent), asCALL_GENERIC); ROR_ASSERT(result >= 0);
93 result = engine->RegisterObjectMethod("GameScriptClass", "void unRegisterEvent(int)", WRAP_MFN(GameScript, unRegisterEvent), asCALL_GENERIC); ROR_ASSERT(result >= 0);
94 result = engine->RegisterObjectMethod("GameScriptClass", "int getRegisteredEventsMask(int)", WRAP_MFN(GameScript, getRegisteredEventsMask), asCALL_GENERIC); ROR_ASSERT(result >= 0);
95 result = engine->RegisterObjectMethod("GameScriptClass", "void setRegisteredEventsMask(int, int)", WRAP_MFN(GameScript, setRegisteredEventsMask), asCALL_GENERIC); ROR_ASSERT(result >= 0);
96 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode addScriptFunction(const string &in, int = -2)", WRAP_MFN(GameScript, addScriptFunction), asCALL_GENERIC); ROR_ASSERT(result >= 0);
97 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode scriptFunctionExists(const string &in, int = -2)", WRAP_MFN(GameScript, scriptFunctionExists), asCALL_GENERIC); ROR_ASSERT(result >= 0);
98 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode deleteScriptFunction(const string &in, int = -2)", WRAP_MFN(GameScript, deleteScriptFunction), asCALL_GENERIC); ROR_ASSERT(result >= 0);
99 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode addScriptVariable(const string &in, int = -2)", WRAP_MFN(GameScript, addScriptVariable), asCALL_GENERIC); ROR_ASSERT(result >= 0);
100 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode scriptVariableExists(const string &in, int = -2)", WRAP_MFN(GameScript, scriptVariableExists), asCALL_GENERIC); ROR_ASSERT(result >= 0);
101 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode deleteScriptVariable(const string &in, int = -2)", WRAP_MFN(GameScript, deleteScriptVariable), asCALL_GENERIC); ROR_ASSERT(result >= 0);
102 result = engine->RegisterObjectMethod("GameScriptClass", "ScriptRetCode getScriptVariable(const string &in, ?&out, int = -2)", asFUNCTION(getScriptVariable), asCALL_GENERIC); ROR_ASSERT(result >= 0);
103 result = engine->RegisterObjectMethod("GameScriptClass", "void clearEventCache()", WRAP_MFN(GameScript, clearEventCache), asCALL_GENERIC); ROR_ASSERT(result >= 0);
104 result = engine->RegisterObjectMethod("GameScriptClass", "int sendGameCmd(const string &in)", WRAP_MFN(GameScript, sendGameCmd), asCALL_GENERIC); ROR_ASSERT(result >= 0);
105 result = engine->RegisterObjectMethod("GameScriptClass", "array<int>@ getRunningScripts()", WRAP_MFN(GameScript, getRunningScripts), asCALL_GENERIC); ROR_ASSERT(result >= 0);
106 result = engine->RegisterObjectMethod("GameScriptClass", "dictionary@ getScriptDetails(int)", WRAP_MFN(GameScript, getScriptDetails), asCALL_GENERIC); ROR_ASSERT(result >= 0);
107
108 // > Terrain
109 result = engine->RegisterObjectMethod("GameScriptClass", "void loadTerrain(const string &in)", WRAP_MFN(GameScript, loadTerrain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
110 result = engine->RegisterObjectMethod("GameScriptClass", "int getLoadedTerrain(string &out)", WRAP_MFN(GameScript, getLoadedTerrain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
111 result = engine->RegisterObjectMethod("GameScriptClass", "bool getCaelumAvailable()", WRAP_MFN(GameScript, getCaelumAvailable), asCALL_GENERIC); ROR_ASSERT(result >= 0);
112 result = engine->RegisterObjectMethod("GameScriptClass", "string getCaelumTime()", WRAP_MFN(GameScript, getCaelumTime), asCALL_GENERIC); ROR_ASSERT(result >= 0);
113 result = engine->RegisterObjectMethod("GameScriptClass", "void setCaelumTime(float)", WRAP_MFN(GameScript, setCaelumTime), asCALL_GENERIC); ROR_ASSERT(result >= 0);
114 result = engine->RegisterObjectMethod("GameScriptClass", "float getGravity()", WRAP_MFN(GameScript, getGravity), asCALL_GENERIC); ROR_ASSERT(result >= 0);
115 result = engine->RegisterObjectMethod("GameScriptClass", "void setGravity(float)", WRAP_MFN(GameScript, setGravity), asCALL_GENERIC); ROR_ASSERT(result >= 0);
116 result = engine->RegisterObjectMethod("GameScriptClass", "float getGroundHeight(vector3 &in)", WRAP_MFN(GameScript, getGroundHeight), asCALL_GENERIC); ROR_ASSERT(result >= 0);
117 result = engine->RegisterObjectMethod("GameScriptClass", "float getWaterHeight()", WRAP_MFN(GameScript, getWaterHeight), asCALL_GENERIC); ROR_ASSERT(result >= 0);
118 result = engine->RegisterObjectMethod("GameScriptClass", "void setWaterHeight(float)", WRAP_MFN(GameScript, setWaterHeight), asCALL_GENERIC); ROR_ASSERT(result >= 0);
119 result = engine->RegisterObjectMethod("GameScriptClass", "void spawnObject(const string &in, const string &in, vector3 &in, vector3 &in, const string &in, bool)", WRAP_MFN(GameScript, spawnObject), asCALL_GENERIC); ROR_ASSERT(result >= 0);
120 result = engine->RegisterObjectMethod("GameScriptClass", "void moveObjectVisuals(const string &in, vector3 &in)", WRAP_MFN(GameScript, moveObjectVisuals), asCALL_GENERIC); ROR_ASSERT(result >= 0);
121 result = engine->RegisterObjectMethod("GameScriptClass", "void destroyObject(const string &in)", WRAP_MFN(GameScript, destroyObject), asCALL_GENERIC); ROR_ASSERT(result >= 0);
122 result = engine->RegisterObjectMethod("GameScriptClass", "array<TerrainEditorObjectClassPtr@>@ getEditorObjects()", WRAP_MFN(GameScript, getEditorObjects), asCALL_GENERIC); ROR_ASSERT(result >= 0);
123 result = engine->RegisterObjectMethod("GameScriptClass", "bool getMousePositionOnTerrain(vector3 &out)", WRAP_MFN(GameScript, getMousePositionOnTerrain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
124 result = engine->RegisterObjectMethod("GameScriptClass", "TerrainClassPtr@ getTerrain()", WRAP_MFN(GameScript,getTerrain), asCALL_GENERIC); ROR_ASSERT(result>=0);
125 result = engine->RegisterObjectMethod("GameScriptClass", "array<Ogre::MovableObject@>@ getMousePointedMovableObjects()", WRAP_MFN(GameScript, getMousePointedMovableObjects), asCALL_GENERIC); ROR_ASSERT(result >= 0);
126
127 // > Character
128 result = engine->RegisterObjectMethod("GameScriptClass", "vector3 getPersonPosition()", WRAP_MFN(GameScript, getPersonPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
129 result = engine->RegisterObjectMethod("GameScriptClass", "void setPersonPosition(vector3 &in)", WRAP_MFN(GameScript, setPersonPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
130 result = engine->RegisterObjectMethod("GameScriptClass", "void movePerson(vector3 &in)", WRAP_MFN(GameScript, movePerson), asCALL_GENERIC); ROR_ASSERT(result >= 0);
131 result = engine->RegisterObjectMethod("GameScriptClass", "void setPersonRotation(radian &in)", WRAP_MFN(GameScript, setPersonRotation), asCALL_GENERIC); ROR_ASSERT(result >= 0);
132 result = engine->RegisterObjectMethod("GameScriptClass", "radian getPersonRotation()", WRAP_MFN(GameScript, getPersonRotation), asCALL_GENERIC); ROR_ASSERT(result >= 0);
133
134 // > Actors
135 result = engine->RegisterObjectMethod("GameScriptClass", "void activateAllVehicles()", WRAP_MFN(GameScript,activateAllVehicles), asCALL_GENERIC); ROR_ASSERT(result>=0);
136 result = engine->RegisterObjectMethod("GameScriptClass", "void setTrucksForcedActive(bool forceActive)", WRAP_MFN(GameScript,setTrucksForcedAwake), asCALL_GENERIC); ROR_ASSERT(result>=0);
137 result = engine->RegisterObjectMethod("GameScriptClass", "void boostCurrentTruck(float)", WRAP_MFN(GameScript, boostCurrentTruck), asCALL_GENERIC); ROR_ASSERT(result >= 0);
138 result = engine->RegisterObjectMethod("GameScriptClass", "BeamClassPtr @getCurrentTruck()", WRAP_MFN(GameScript, getCurrentTruck), asCALL_GENERIC); ROR_ASSERT(result >= 0);
139 result = engine->RegisterObjectMethod("GameScriptClass", "BeamClassPtr @getTruckByNum(int)", WRAP_MFN(GameScript, getTruckByNum), asCALL_GENERIC); ROR_ASSERT(result >= 0);
140 result = engine->RegisterObjectMethod("GameScriptClass", "array<BeamClass@> @getAllTrucks()", WRAP_MFN(GameScript, getAllTrucks), asCALL_GENERIC); ROR_ASSERT(result >= 0);
141 result = engine->RegisterObjectMethod("GameScriptClass", "int getCurrentTruckNumber()", WRAP_MFN(GameScript, getCurrentTruckNumber), asCALL_GENERIC); ROR_ASSERT(result >= 0);
142 result = engine->RegisterObjectMethod("GameScriptClass", "BeamClassPtr @spawnTruck(string &in, vector3 &in, vector3 &in)", WRAP_MFN(GameScript, spawnTruck), asCALL_GENERIC); ROR_ASSERT(result >= 0);
143 result = engine->RegisterObjectMethod("GameScriptClass", "void repairVehicle(const string &in, const string &in, bool)", WRAP_MFN(GameScript, repairVehicle), asCALL_GENERIC); ROR_ASSERT(result >= 0);
144 result = engine->RegisterObjectMethod("GameScriptClass", "void removeVehicle(const string &in, const string &in)", WRAP_MFN(GameScript, removeVehicle), asCALL_GENERIC); ROR_ASSERT(result >= 0);
145 result = engine->RegisterObjectMethod("GameScriptClass", "int getNumTrucksByFlag(int)", WRAP_MFN(GameScript, getNumTrucksByFlag), asCALL_GENERIC); ROR_ASSERT(result >= 0);
146 result = engine->RegisterObjectMethod("GameScriptClass", "int getActorNextInstanceId()", WRAP_MFN(GameScript, getActorNextInstanceId), asCALL_GENERIC); ROR_ASSERT(result >= 0);
147 result = engine->RegisterObjectMethod("GameScriptClass", "BeamClassPtr @getTruckRemotelyReceivingCommands()", WRAP_MFN(GameScript, getTruckRemotelyReceivingCommands), asCALL_GENERIC); ROR_ASSERT(result >= 0);
148
149 // > FreeForces
150 result = engine->RegisterObjectMethod("GameScriptClass", "int getFreeForceNextId()", WRAP_MFN(GameScript, getFreeForceNextId), asCALL_GENERIC); ROR_ASSERT(result >= 0);
151 result = engine->RegisterObjectMethod("GameScriptClass", "int getFreeBeamGfxNextId()", WRAP_MFN(GameScript, getFreeBeamGfxNextId), asCALL_GENERIC); ROR_ASSERT(result >= 0);
152
153 // > Waypoint AI for actors
154 result = engine->RegisterObjectMethod("GameScriptClass", "BeamClassPtr @spawnTruckAI(string &in, vector3 &in, string &in, string &in, int x)", WRAP_MFN(GameScript, spawnTruckAI), asCALL_GENERIC); ROR_ASSERT(result >= 0);
155 result = engine->RegisterObjectMethod("GameScriptClass", "array<vector3> @getWaypoints(int x)", WRAP_MFN(GameScript, getWaypoints), asCALL_GENERIC); ROR_ASSERT(result >= 0);
156 result = engine->RegisterObjectMethod("GameScriptClass", "array<int> @getWaypointsSpeed()", WRAP_MFN(GameScript, getWaypointsSpeed), asCALL_GENERIC); ROR_ASSERT(result >= 0);
157 result = engine->RegisterObjectMethod("GameScriptClass", "void addWaypoint(vector3 &in)", WRAP_MFN(GameScript, addWaypoint), asCALL_GENERIC); ROR_ASSERT(result >= 0);
158 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIVehicleCount()", WRAP_MFN(GameScript, getAIVehicleCount), asCALL_GENERIC); ROR_ASSERT(result >= 0);
159 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIVehicleDistance()", WRAP_MFN(GameScript, getAIVehicleDistance), asCALL_GENERIC); ROR_ASSERT(result >= 0);
160 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIVehiclePositionScheme()", WRAP_MFN(GameScript, getAIVehiclePositionScheme), asCALL_GENERIC); ROR_ASSERT(result >= 0);
161 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIVehicleSpeed()", WRAP_MFN(GameScript, getAIVehicleSpeed), asCALL_GENERIC); ROR_ASSERT(result >= 0);
162 result = engine->RegisterObjectMethod("GameScriptClass", "string getAIVehicleName(int x)", WRAP_MFN(GameScript, getAIVehicleName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
163 result = engine->RegisterObjectMethod("GameScriptClass", "string getAIVehicleSectionConfig(int x)", WRAP_MFN(GameScript, getAIVehicleSectionConfig), asCALL_GENERIC); ROR_ASSERT(result >= 0);
164 result = engine->RegisterObjectMethod("GameScriptClass", "string getAIVehicleSkin(int x)", WRAP_MFN(GameScript, getAIVehicleSkin), asCALL_GENERIC); ROR_ASSERT(result >= 0);
165 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIRepeatTimes()", WRAP_MFN(GameScript, getAIRepeatTimes), asCALL_GENERIC); ROR_ASSERT(result >= 0);
166 result = engine->RegisterObjectMethod("GameScriptClass", "int getAIMode()", WRAP_MFN(GameScript, getAIMode), asCALL_GENERIC); ROR_ASSERT(result >= 0);
167 result = engine->RegisterObjectMethod("GameScriptClass", "VehicleAIClassPtr @getCurrentTruckAI()", WRAP_MFN(GameScript, getCurrentTruckAI), asCALL_GENERIC); ROR_ASSERT(result >= 0);
168 result = engine->RegisterObjectMethod("GameScriptClass", "VehicleAIClassPtr @getTruckAIByNum(int)", WRAP_MFN(GameScript, getTruckAIByNum), asCALL_GENERIC); ROR_ASSERT(result >= 0);
169 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleCount(int count)", WRAP_MFN(GameScript, setAIVehicleCount), asCALL_GENERIC); ROR_ASSERT(result >= 0);
170 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleDistance(int dist)", WRAP_MFN(GameScript, setAIVehicleDistance), asCALL_GENERIC); ROR_ASSERT(result >= 0);
171 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehiclePositionScheme(int scheme)", WRAP_MFN(GameScript, setAIVehiclePositionScheme), asCALL_GENERIC); ROR_ASSERT(result >= 0);
172 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleSpeed(int speed)", WRAP_MFN(GameScript, setAIVehicleSpeed), asCALL_GENERIC); ROR_ASSERT(result >= 0);
173 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleName(int x, string name)", WRAP_MFN(GameScript, setAIVehicleName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
174 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleSectionConfig(int x, string config)", WRAP_MFN(GameScript, setAIVehicleSectionConfig), asCALL_GENERIC); ROR_ASSERT(result >= 0);
175 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIVehicleSkin(int x, string skin)", WRAP_MFN(GameScript, setAIVehicleSkin), asCALL_GENERIC); ROR_ASSERT(result >= 0);
176 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIRepeatTimes(int times)", WRAP_MFN(GameScript, setAIRepeatTimes), asCALL_GENERIC); ROR_ASSERT(result >= 0);
177 result = engine->RegisterObjectMethod("GameScriptClass", "void setAIMode(int mode)", WRAP_MFN(GameScript, setAIMode), asCALL_GENERIC); ROR_ASSERT(result >= 0);
178
179 // > Camera
180 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraPosition(vector3 &in)", WRAP_MFN(GameScript, setCameraPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
181 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraDirection(vector3 &in)", WRAP_MFN(GameScript, setCameraDirection), asCALL_GENERIC); ROR_ASSERT(result >= 0);
182 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraOrientation(quaternion &in)", WRAP_MFN(GameScript, setCameraOrientation), asCALL_GENERIC); ROR_ASSERT(result >= 0);
183 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraRoll(float)", WRAP_MFN(GameScript, setCameraRoll), asCALL_GENERIC); ROR_ASSERT(result >= 0);
184 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraYaw(float)", WRAP_MFN(GameScript, setCameraYaw), asCALL_GENERIC); ROR_ASSERT(result >= 0);
185 result = engine->RegisterObjectMethod("GameScriptClass", "void setCameraPitch(float)", WRAP_MFN(GameScript, setCameraPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
186 result = engine->RegisterObjectMethod("GameScriptClass", "vector3 getCameraPosition()", WRAP_MFN(GameScript, getCameraPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
187 result = engine->RegisterObjectMethod("GameScriptClass", "vector3 getCameraDirection()", WRAP_MFN(GameScript, getCameraDirection), asCALL_GENERIC); ROR_ASSERT(result >= 0);
188 result = engine->RegisterObjectMethod("GameScriptClass", "quaternion getCameraOrientation()", WRAP_MFN(GameScript, getCameraOrientation), asCALL_GENERIC); ROR_ASSERT(result >= 0);
189 result = engine->RegisterObjectMethod("GameScriptClass", "void cameraLookAt(vector3 &in)", WRAP_MFN(GameScript, cameraLookAt), asCALL_GENERIC); ROR_ASSERT(result >= 0);
190
191 // > Race system
192 result = engine->RegisterObjectMethod("GameScriptClass", "void setBestLapTime(float time)", WRAP_MFN(GameScript,setBestLapTime), asCALL_GENERIC); ROR_ASSERT(result>=0);
193 result = engine->RegisterObjectMethod("GameScriptClass", "void setTimeDiff(float diff)", WRAP_MFN(GameScript,setTimeDiff), asCALL_GENERIC); ROR_ASSERT(result>=0);
194 result = engine->RegisterObjectMethod("GameScriptClass", "void startTimer(int id)", WRAP_MFN(GameScript,startTimer), asCALL_GENERIC); ROR_ASSERT(result>=0);
195 result = engine->RegisterObjectMethod("GameScriptClass", "void stopTimer()", WRAP_MFN(GameScript,stopTimer), asCALL_GENERIC); ROR_ASSERT(result>=0);
196
197 // > Material helpers
198 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialAmbient(const string &in, float, float, float)", WRAP_MFN(GameScript,setMaterialAmbient), asCALL_GENERIC); ROR_ASSERT(result>=0);
199 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialDiffuse(const string &in, float, float, float, float)", WRAP_MFN(GameScript,setMaterialDiffuse), asCALL_GENERIC); ROR_ASSERT(result>=0);
200 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialSpecular(const string &in, float, float, float, float)", WRAP_MFN(GameScript,setMaterialSpecular), asCALL_GENERIC); ROR_ASSERT(result>=0);
201 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialEmissive(const string &in, float, float, float)", WRAP_MFN(GameScript,setMaterialEmissive), asCALL_GENERIC); ROR_ASSERT(result>=0);
202 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialTextureName(const string &in, int, int, int, const string &in)", WRAP_MFN(GameScript,setMaterialTextureName), asCALL_GENERIC); ROR_ASSERT(result>=0);
203 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialTextureRotate(const string &in, int, int, int, float)", WRAP_MFN(GameScript,setMaterialTextureRotate), asCALL_GENERIC); ROR_ASSERT(result>=0);
204 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialTextureScroll(const string &in, int, int, int, float, float)", WRAP_MFN(GameScript,setMaterialTextureScroll), asCALL_GENERIC); ROR_ASSERT(result>=0);
205 result = engine->RegisterObjectMethod("GameScriptClass", "int setMaterialTextureScale(const string &in, int, int, int, float, float)", WRAP_MFN(GameScript,setMaterialTextureScale), asCALL_GENERIC); ROR_ASSERT(result>=0);
206
207 // > Audio
208 result = engine->RegisterObjectMethod("GameScriptClass", "array<SoundScriptTemplateClass@>@ getAllSoundScriptTemplates()", WRAP_MFN(GameScript, getAllSoundScriptTemplates), asCALL_GENERIC); ROR_ASSERT(result >= 0);
209 result = engine->RegisterObjectMethod("GameScriptClass", "SoundScriptTemplateClassPtr@ getSoundScriptTemplate(const string &in)", WRAP_MFN(GameScript, getSoundScriptTemplate), asCALL_GENERIC); ROR_ASSERT(result >= 0);
210 result = engine->RegisterObjectMethod("GameScriptClass", "array<SoundScriptInstanceClass@>@ getAllSoundScriptInstances()", WRAP_MFN(GameScript, getAllSoundScriptInstances), asCALL_GENERIC); ROR_ASSERT(result >= 0);
211 result = engine->RegisterObjectMethod("GameScriptClass", "SoundClassPtr@ createSoundFromResource(const string &in filename, const string &in rg_name = string())", WRAP_MFN(GameScript, createSoundFromResource), asCALL_GENERIC); ROR_ASSERT(result >= 0);
212 result = engine->RegisterObjectMethod("GameScriptClass", "SoundScriptInstanceClassPtr@ createSoundScriptInstance(const string &in template, int actor_instance_id = -1)", WRAP_MFN(GameScript, createSoundScriptInstance), asCALL_GENERIC); ROR_ASSERT(result >= 0);
213
214}
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
static void getScriptVariable(asIScriptGeneric *gen)
#define WRAP_MFN(ClassType, name)
Proxy class that can be called by script functions.
Definition GameScript.h:42
ScriptRetCode_t getScriptVariable(const Ogre::String &varName, void *ref, int refTypeId, ScriptUnitID_t nid)
Retrieves a memory address of a global variable in any script.
void RegisterGameScriptGeneric(AngelScript::asIScriptEngine *engine)