1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01: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}; 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 <> template <>
ScriptObjectType<BlipData> ScriptArguments::getScriptObject( ScriptObjectType<BlipData> ScriptArguments::getScriptObject(
unsigned int arg) const { unsigned int arg) const {

View File

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