1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Sound as ScriptType

This commit is contained in:
Filip Gawin 2018-08-12 16:00:47 +02:00
parent 4119afbae3
commit 1b1b924d8f
2 changed files with 15 additions and 2 deletions

View File

@ -239,6 +239,15 @@ ScriptObjectType<Payphone> ScriptArguments::getScriptObject(
}
return {param.handleValue(), payphone};
}
template <>
ScriptObjectType<Sound> ScriptArguments::getScriptObject(
unsigned int arg) const {
auto& param = (*this)[arg];
RW_CHECK(param.isLvalue(), "Non lvalue passed as object");
return {param.handleValue(), &getWorld()->sound.getSoundRef(arg)};
}
template <>
ScriptObjectType<BlipData> ScriptArguments::getScriptObject(
unsigned int arg) const {

View File

@ -11,6 +11,7 @@
#include <rw/debug.hpp>
#include "audio/Sound.hpp"
#include "engine/Garage.hpp"
class CharacterObject;
@ -109,9 +110,9 @@ struct BlipData;
using ScriptVehicleGenerator = ScriptObjectType<VehicleGenerator>;
using ScriptBlip = ScriptObjectType<BlipData>;
using ScriptPayphone = ScriptObjectType<Payphone>;
using ScriptSound = ScriptObjectType<Sound>;
/// @todo replace these with real types for sounds etc.
using ScriptSound = ScriptObjectType<int>;
/// @todo replace these with real types
using ScriptFire = ScriptObjectType<int>;
using ScriptSphere = ScriptObjectType<int>;
@ -349,6 +350,9 @@ ScriptObjectType<VehicleGenerator> ScriptArguments::getScriptObject(
template <>
ScriptObjectType<Garage> ScriptArguments::getScriptObject(
unsigned int arg) const;
template <>
ScriptObjectType<Sound> ScriptArguments::getScriptObject(
unsigned int arg) const;
typedef std::function<void(const ScriptArguments&)> ScriptFunction;
typedef std::function<bool(const ScriptArguments&)> ScriptFunctionBoolean;