Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
SoundScriptAngelscript.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2023 Petr Ohlidal
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
22
23#include "AngelScriptBindings.h"
24#include "ScriptEngine.h"
25#include "Sound.h"
26#include "SoundScriptManager.h"
28
29using namespace RoR;
30using namespace AngelScript;
31using namespace SoundScriptAngelscriptWrappers;
32
33void RoR::RegisterSoundScriptNative(AngelScript::asIScriptEngine* engine)
34{
35 int result = 0;
36
37 // NOTE: enums SoundTriggers and ModulationSources are registered in RegisterSoundScriptCommon()
38
39 // class SoundScriptTemplate
40 SoundScriptTemplate::RegisterRefCountingObject(engine, "SoundScriptTemplateClass");
41 SoundScriptTemplatePtr::RegisterRefCountingObjectPtr(engine, "SoundScriptTemplateClassPtr", "SoundScriptTemplateClass");
42
43 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "int getNumSounds()", asMETHOD(SoundScriptTemplate, getNumSounds), asCALL_THISCALL); ROR_ASSERT(result >= 0);
44 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getSoundName(int)", asMETHOD(SoundScriptTemplate, getSoundName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
45 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getSoundPitch(int)", asMETHOD(SoundScriptTemplate, getSoundPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
46
47 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getStartSoundName()", asMETHOD(SoundScriptTemplate, getStartSoundName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
48 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getStartSoundPitch()", asMETHOD(SoundScriptTemplate, getStartSoundPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
49 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getStopSoundName()", asMETHOD(SoundScriptTemplate, getStopSoundName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
50 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getStopSoundPitch()", asMETHOD(SoundScriptTemplate, getStopSoundPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
51
52 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getName()", asMETHOD(SoundScriptTemplate, getName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
53 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getFileName()", asMETHOD(SoundScriptTemplate, getFileName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
54 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getGroupName()", asMETHOD(SoundScriptTemplate, getGroupName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
55 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "bool isBaseTemplate()", asMETHOD(SoundScriptTemplate, isBaseTemplate), asCALL_THISCALL); ROR_ASSERT(result >= 0);
56
57 // class Sound
58 Sound::RegisterRefCountingObject(engine, "SoundClass");
59 SoundPtr::RegisterRefCountingObjectPtr(engine, "SoundClassPtr", "SoundClass");
60
61 result = engine->RegisterObjectMethod("SoundClass", "void setPitch(float pitch)", asMETHOD(Sound, setPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
62 result = engine->RegisterObjectMethod("SoundClass", "void setGain(float gain)", asMETHOD(Sound, setGain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
63 result = engine->RegisterObjectMethod("SoundClass", "void setPosition(vector3 pos)", asMETHOD(Sound, setPosition), asCALL_THISCALL); ROR_ASSERT(result >= 0);
64 result = engine->RegisterObjectMethod("SoundClass", "void setVelocity(vector3 vel)", asMETHOD(Sound, setVelocity), asCALL_THISCALL); ROR_ASSERT(result >= 0);
65 result = engine->RegisterObjectMethod("SoundClass", "void setLoop(bool loop)", asMETHOD(Sound, setLoop), asCALL_THISCALL); ROR_ASSERT(result >= 0);
66 result = engine->RegisterObjectMethod("SoundClass", "void setEnabled(bool e)", asMETHOD(Sound, setEnabled), asCALL_THISCALL); ROR_ASSERT(result >= 0);
67 result = engine->RegisterObjectMethod("SoundClass", "void play()", asMETHOD(Sound, play), asCALL_THISCALL); ROR_ASSERT(result >= 0);
68 result = engine->RegisterObjectMethod("SoundClass", "void stop()", asMETHOD(Sound, stop), asCALL_THISCALL); ROR_ASSERT(result >= 0);
69
70 result = engine->RegisterObjectMethod("SoundClass", "bool getEnabled()", asMETHOD(Sound, getEnabled), asCALL_THISCALL); ROR_ASSERT(result >= 0);
71 result = engine->RegisterObjectMethod("SoundClass", "bool isPlaying()", asMETHOD(Sound, isPlaying), asCALL_THISCALL); ROR_ASSERT(result >= 0);
72 result = engine->RegisterObjectMethod("SoundClass", "float getAudibility() ", asMETHOD(Sound, getAudibility), asCALL_THISCALL); ROR_ASSERT(result >= 0);
73 result = engine->RegisterObjectMethod("SoundClass", "float getGain() ", asMETHOD(Sound, getGain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
74 result = engine->RegisterObjectMethod("SoundClass", "float getPitch() ", asMETHOD(Sound, getPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
75 result = engine->RegisterObjectMethod("SoundClass", "bool getLoop()", asMETHOD(Sound, getLoop), asCALL_THISCALL); ROR_ASSERT(result >= 0);
76 result = engine->RegisterObjectMethod("SoundClass", "int getCurrentHardwareIndex()", asMETHOD(Sound, getCurrentHardwareIndex), asCALL_THISCALL); ROR_ASSERT(result >= 0);
77 result = engine->RegisterObjectMethod("SoundClass", "uint getBuffer()", asMETHOD(Sound, getBuffer), asCALL_THISCALL); ROR_ASSERT(result >= 0);
78 result = engine->RegisterObjectMethod("SoundClass", "vector3 getPosition()", asMETHOD(Sound, getPosition), asCALL_THISCALL); ROR_ASSERT(result >= 0);
79 result = engine->RegisterObjectMethod("SoundClass", "vector3 getVelocity()", asMETHOD(Sound, getVelocity), asCALL_THISCALL); ROR_ASSERT(result >= 0);
80 result = engine->RegisterObjectMethod("SoundClass", "int getSourceIndex()", asMETHOD(Sound, getSourceIndex), asCALL_THISCALL); ROR_ASSERT(result >= 0);
81
82 // class SoundScriptInstance
83 SoundScriptInstance::RegisterRefCountingObject(engine, "SoundScriptInstanceClass");
84 SoundScriptInstancePtr::RegisterRefCountingObjectPtr(engine, "SoundScriptInstanceClassPtr", "SoundScriptInstanceClass");
85
86 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void runOnce()", asMETHOD(SoundScriptInstance, runOnce), asCALL_THISCALL); ROR_ASSERT(result >= 0);
87 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setPitch(float pitch)", asMETHOD(SoundScriptInstance, setPitch), asCALL_THISCALL); ROR_ASSERT(result >= 0);
88 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setGain(float gain)", asMETHOD(SoundScriptInstance, setGain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
89 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setPosition(vector3 pos)", asMETHOD(SoundScriptInstance, setPosition), asCALL_THISCALL); ROR_ASSERT(result >= 0);
90 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setVelocity(vector3 velo)", asMETHOD(SoundScriptInstance, setVelocity), asCALL_THISCALL); ROR_ASSERT(result >= 0);
91 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void start()", asMETHOD(SoundScriptInstance, start), asCALL_THISCALL); ROR_ASSERT(result >= 0);
92 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void stop()", asMETHOD(SoundScriptInstance, stop), asCALL_THISCALL); ROR_ASSERT(result >= 0);
93 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void kill()", asMETHOD(SoundScriptInstance, kill), asCALL_THISCALL); ROR_ASSERT(result >= 0);
94
95 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundScriptTemplateClassPtr@ getTemplate()", asFUNCTION(SoundScriptInstance_getTemplate), asCALL_CDECL_OBJFIRST); ROR_ASSERT(result >= 0);
96 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getStartSound()", asFUNCTION(SoundScriptInstance_getStartSound), asCALL_CDECL_OBJFIRST); ROR_ASSERT(result >= 0);
97 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getStopSound()", asFUNCTION(SoundScriptInstance_getStopSound), asCALL_CDECL_OBJFIRST); ROR_ASSERT(result >= 0);
98 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getSound(int pos)", asFUNCTION(SoundScriptInstance_getSound), asCALL_CDECL_OBJFIRST); ROR_ASSERT(result >= 0);
99 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getStartSoundPitchgain()", asMETHOD(SoundScriptInstance, getStartSoundPitchgain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
100 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getStopSoundPitchgain()", asMETHOD(SoundScriptInstance, getStopSoundPitchgain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
101 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getSoundPitchgain(int pos)", asMETHOD(SoundScriptInstance, getSoundPitchgain), asCALL_THISCALL); ROR_ASSERT(result >= 0);
102 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "int getActorInstanceId()", asMETHOD(SoundScriptInstance, getActorInstanceId), asCALL_THISCALL); ROR_ASSERT(result >= 0);
103 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "const string& getInstanceName()", asMETHOD(SoundScriptInstance, getInstanceName), asCALL_THISCALL); ROR_ASSERT(result >= 0);
104
105}
radian getPitch(bool reprojectAxis=true) const
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
Helper/wrapper functions shared by native (SoundScriptAngelscript.cpp) and generic (SoundScriptAngels...
static void RegisterRefCountingObjectPtr(AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *handle_name, const char *obj_name)
void RegisterSoundScriptNative(AngelScript::asIScriptEngine *engine)
static SoundPtr SoundScriptInstance_getStopSound(SoundScriptInstance *self)
static SoundPtr SoundScriptInstance_getSound(SoundScriptInstance *self, int pos)
static SoundScriptTemplatePtr SoundScriptInstance_getTemplate(SoundScriptInstance *self)
static SoundPtr SoundScriptInstance_getStartSound(SoundScriptInstance *self)