Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
SoundScriptAngelscriptGeneric.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 "../../autowrapper/aswrappedcall.h"
24#include "AngelScriptBindings.h"
25#include "ScriptEngine.h"
26#include "Sound.h"
27#include "SoundScriptManager.h"
29
30using namespace RoR;
31using namespace AngelScript;
32using namespace SoundScriptAngelscriptWrappers;
33
34void RoR::RegisterSoundScriptGeneric(AngelScript::asIScriptEngine* engine)
35{
36 int result = 0;
37
38 // NOTE: enums SoundTriggers and ModulationSources are registered in RegisterSoundScriptCommon()
39
40 // class SoundScriptTemplate
41 SoundScriptTemplate::RegisterRefCountingObjectGeneric(engine, "SoundScriptTemplateClass");
42 SoundScriptTemplatePtr::RegisterRefCountingObjectPtrGeneric(engine, "SoundScriptTemplateClassPtr", "SoundScriptTemplateClass");
43
44 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "int getNumSounds()", WRAP_MFN(SoundScriptTemplate, getNumSounds), asCALL_GENERIC); ROR_ASSERT(result >= 0);
45 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getSoundName(int)", WRAP_MFN(SoundScriptTemplate, getSoundName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
46 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getSoundPitch(int)", WRAP_MFN(SoundScriptTemplate, getSoundPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
47
48 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getStartSoundName()", WRAP_MFN(SoundScriptTemplate, getStartSoundName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
49 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getStartSoundPitch()", WRAP_MFN(SoundScriptTemplate, getStartSoundPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
50 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getStopSoundName()", WRAP_MFN(SoundScriptTemplate, getStopSoundName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
51 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "float getStopSoundPitch()", WRAP_MFN(SoundScriptTemplate, getStopSoundPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
52
53 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getName()", WRAP_MFN(SoundScriptTemplate, getName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
54 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getFileName()", WRAP_MFN(SoundScriptTemplate, getFileName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
55 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "string getGroupName()", WRAP_MFN(SoundScriptTemplate, getGroupName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
56 result = engine->RegisterObjectMethod("SoundScriptTemplateClass", "bool isBaseTemplate()", WRAP_MFN(SoundScriptTemplate, isBaseTemplate), asCALL_GENERIC); ROR_ASSERT(result >= 0);
57
58 // class Sound
59 Sound::RegisterRefCountingObjectGeneric(engine, "SoundClass");
60 SoundPtr::RegisterRefCountingObjectPtrGeneric(engine, "SoundClassPtr", "SoundClass");
61
62 result = engine->RegisterObjectMethod("SoundClass", "void setPitch(float pitch)", WRAP_MFN(Sound, setPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
63 result = engine->RegisterObjectMethod("SoundClass", "void setGain(float gain)", WRAP_MFN(Sound, setGain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
64 result = engine->RegisterObjectMethod("SoundClass", "void setPosition(vector3 pos)", WRAP_MFN(Sound, setPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
65 result = engine->RegisterObjectMethod("SoundClass", "void setVelocity(vector3 vel)", WRAP_MFN(Sound, setVelocity), asCALL_GENERIC); ROR_ASSERT(result >= 0);
66 result = engine->RegisterObjectMethod("SoundClass", "void setLoop(bool loop)", WRAP_MFN(Sound, setLoop), asCALL_GENERIC); ROR_ASSERT(result >= 0);
67 result = engine->RegisterObjectMethod("SoundClass", "void setEnabled(bool e)", WRAP_MFN(Sound, setEnabled), asCALL_GENERIC); ROR_ASSERT(result >= 0);
68 result = engine->RegisterObjectMethod("SoundClass", "void play()", WRAP_MFN(Sound, play), asCALL_GENERIC); ROR_ASSERT(result >= 0);
69 result = engine->RegisterObjectMethod("SoundClass", "void stop()", WRAP_MFN(Sound, stop), asCALL_GENERIC); ROR_ASSERT(result >= 0);
70
71 result = engine->RegisterObjectMethod("SoundClass", "bool getEnabled()", WRAP_MFN(Sound, getEnabled), asCALL_GENERIC); ROR_ASSERT(result >= 0);
72 result = engine->RegisterObjectMethod("SoundClass", "bool isPlaying()", WRAP_MFN(Sound, isPlaying), asCALL_GENERIC); ROR_ASSERT(result >= 0);
73 result = engine->RegisterObjectMethod("SoundClass", "float getAudibility() ", WRAP_MFN(Sound, getAudibility), asCALL_GENERIC); ROR_ASSERT(result >= 0);
74 result = engine->RegisterObjectMethod("SoundClass", "float getGain() ", WRAP_MFN(Sound, getGain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
75 result = engine->RegisterObjectMethod("SoundClass", "float getPitch() ", WRAP_MFN(Sound, getPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
76 result = engine->RegisterObjectMethod("SoundClass", "bool getLoop()", WRAP_MFN(Sound, getLoop), asCALL_GENERIC); ROR_ASSERT(result >= 0);
77 result = engine->RegisterObjectMethod("SoundClass", "int getCurrentHardwareIndex()", WRAP_MFN(Sound, getCurrentHardwareIndex), asCALL_GENERIC); ROR_ASSERT(result >= 0);
78 result = engine->RegisterObjectMethod("SoundClass", "uint getBuffer()", WRAP_MFN(Sound, getBuffer), asCALL_GENERIC); ROR_ASSERT(result >= 0);
79 result = engine->RegisterObjectMethod("SoundClass", "vector3 getPosition()", WRAP_MFN(Sound, getPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
80 result = engine->RegisterObjectMethod("SoundClass", "vector3 getVelocity()", WRAP_MFN(Sound, getVelocity), asCALL_GENERIC); ROR_ASSERT(result >= 0);
81 result = engine->RegisterObjectMethod("SoundClass", "int getSourceIndex()", WRAP_MFN(Sound, getSourceIndex), asCALL_GENERIC); ROR_ASSERT(result >= 0);
82
83 // class SoundScriptInstance
84 SoundScriptInstance::RegisterRefCountingObjectGeneric(engine, "SoundScriptInstanceClass");
85 SoundScriptInstancePtr::RegisterRefCountingObjectPtrGeneric(engine, "SoundScriptInstanceClassPtr", "SoundScriptInstanceClass");
86
87 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void runOnce()", WRAP_MFN(SoundScriptInstance, runOnce), asCALL_GENERIC); ROR_ASSERT(result >= 0);
88 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setPitch(float pitch)", WRAP_MFN(SoundScriptInstance, setPitch), asCALL_GENERIC); ROR_ASSERT(result >= 0);
89 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setGain(float gain)", WRAP_MFN(SoundScriptInstance, setGain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
90 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setPosition(vector3 pos)", WRAP_MFN(SoundScriptInstance, setPosition), asCALL_GENERIC); ROR_ASSERT(result >= 0);
91 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void setVelocity(vector3 velo)", WRAP_MFN(SoundScriptInstance, setVelocity), asCALL_GENERIC); ROR_ASSERT(result >= 0);
92 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void start()", WRAP_MFN(SoundScriptInstance, start), asCALL_GENERIC); ROR_ASSERT(result >= 0);
93 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void stop()", WRAP_MFN(SoundScriptInstance, stop), asCALL_GENERIC); ROR_ASSERT(result >= 0);
94 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "void kill()", WRAP_MFN(SoundScriptInstance, kill), asCALL_GENERIC); ROR_ASSERT(result >= 0);
95
96 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundScriptTemplateClassPtr@ getTemplate()", WRAP_OBJ_FIRST(SoundScriptInstance_getTemplate), asCALL_GENERIC); ROR_ASSERT(result >= 0);
97 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getStartSound()", WRAP_OBJ_FIRST(SoundScriptInstance_getStartSound), asCALL_GENERIC); ROR_ASSERT(result >= 0);
98 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getStopSound()", WRAP_OBJ_FIRST(SoundScriptInstance_getStopSound), asCALL_GENERIC); ROR_ASSERT(result >= 0);
99 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "SoundClassPtr@ getSound(int pos)", WRAP_OBJ_FIRST(SoundScriptInstance_getSound), asCALL_GENERIC); ROR_ASSERT(result >= 0);
100 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getStartSoundPitchgain()", WRAP_MFN(SoundScriptInstance, getStartSoundPitchgain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
101 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getStopSoundPitchgain()", WRAP_MFN(SoundScriptInstance, getStopSoundPitchgain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
102 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "float getSoundPitchgain(int pos)", WRAP_MFN(SoundScriptInstance, getSoundPitchgain), asCALL_GENERIC); ROR_ASSERT(result >= 0);
103 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "int getActorInstanceId()", WRAP_MFN(SoundScriptInstance, getActorInstanceId), asCALL_GENERIC); ROR_ASSERT(result >= 0);
104 result = engine->RegisterObjectMethod("SoundScriptInstanceClass", "const string& getInstanceName()", WRAP_MFN(SoundScriptInstance, getInstanceName), asCALL_GENERIC); ROR_ASSERT(result >= 0);
105
106}
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...
#define WRAP_MFN(ClassType, name)
#define WRAP_OBJ_FIRST(name)
static void RegisterRefCountingObjectPtrGeneric(AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *handle_name, const char *obj_name)
Same as RegisterRefCountingObjectPtr() but uses the generic calling convention (for platforms with AS...
void RegisterSoundScriptGeneric(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)