mirror of https://github.com/OpenRCT2/OpenRCT2.git
Move ScRideStation into its own files
This commit is contained in:
parent
99eee53c60
commit
fe57dece6b
|
@ -786,6 +786,8 @@
|
|||
E436DE7807A74621B7BF2276 /* ScPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E2A4181A243F4B77BA36ACE2 /* ScPlayer.cpp */; };
|
||||
2D0A43F28D5747C9B617F342 /* ScPlayer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 7A08C451885D4D419FB4820D /* ScPlayer.hpp */; };
|
||||
F08623EA69E7456DB79F3E06 /* ScNetwork.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 200F0E6CAD3B41499A3CFC36 /* ScNetwork.cpp */; };
|
||||
CDC72A71A28542F4AD73A91C /* ScRideStation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 522FE124ED4F4E18BCF79042 /* ScRideStation.cpp */; };
|
||||
63858E295E3F451283987982 /* ScRideStation.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1260386710BF4EA4B4FC31D3 /* ScRideStation.hpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -1874,6 +1876,8 @@
|
|||
E2A4181A243F4B77BA36ACE2 /* ScPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScPlayer.cpp; path = src/openrct2/scripting/bindings/network/ScPlayer.cpp; sourceTree = SOURCE_ROOT; };
|
||||
7A08C451885D4D419FB4820D /* ScPlayer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScPlayer.hpp; path = src/openrct2/scripting/bindings/network/ScPlayer.hpp; sourceTree = SOURCE_ROOT; };
|
||||
200F0E6CAD3B41499A3CFC36 /* ScNetwork.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScNetwork.cpp; path = src/openrct2/scripting/bindings/network/ScNetwork.cpp; sourceTree = SOURCE_ROOT; };
|
||||
522FE124ED4F4E18BCF79042 /* ScRideStation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScRideStation.cpp; path = src/openrct2/scripting/bindings/ride/ScRideStation.cpp; sourceTree = SOURCE_ROOT; };
|
||||
1260386710BF4EA4B4FC31D3 /* ScRideStation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScRideStation.hpp; path = src/openrct2/scripting/bindings/ride/ScRideStation.hpp; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -3438,6 +3442,8 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
AD97B712FDF7454CADC7A328 /* ScRide.hpp */,
|
||||
522FE124ED4F4E18BCF79042 /* ScRideStation.cpp */,
|
||||
1260386710BF4EA4B4FC31D3 /* ScRideStation.hpp */,
|
||||
);
|
||||
name = ride;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3605,6 +3611,7 @@
|
|||
359328A3A65D49578912CA40 /* ScLitter.hpp in Headers */,
|
||||
97C222A2A4F543E9AEC3912B /* ScPlayerGroup.hpp in Headers */,
|
||||
2D0A43F28D5747C9B617F342 /* ScPlayer.hpp in Headers */,
|
||||
63858E295E3F451283987982 /* ScRideStation.hpp in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4417,6 +4424,7 @@
|
|||
149D1ACFD5FA42938364C843 /* ScPlayerGroup.cpp in Sources */,
|
||||
E436DE7807A74621B7BF2276 /* ScPlayer.cpp in Sources */,
|
||||
F08623EA69E7456DB79F3E06 /* ScNetwork.cpp in Sources */,
|
||||
CDC72A71A28542F4AD73A91C /* ScRideStation.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -412,6 +412,7 @@
|
|||
<ClInclude Include="scripting\bindings\entity\ScVehicle.hpp" />
|
||||
<ClInclude Include="scripting\bindings\network\ScPlayer.hpp" />
|
||||
<ClInclude Include="scripting\bindings\network\ScPlayerGroup.hpp" />
|
||||
<ClInclude Include="scripting\bindings\ride\ScRideStation.hpp" />
|
||||
<ClInclude Include="scripting\Duktape.hpp" />
|
||||
<ClInclude Include="scripting\HookEngine.h" />
|
||||
<ClInclude Include="scripting\Plugin.h" />
|
||||
|
@ -863,6 +864,7 @@
|
|||
<ClCompile Include="scripting\bindings\network\ScNetwork.cpp" />
|
||||
<ClCompile Include="scripting\bindings\network\ScPlayer.cpp" />
|
||||
<ClCompile Include="scripting\bindings\network\ScPlayerGroup.cpp" />
|
||||
<ClCompile Include="scripting\bindings\ride\ScRideStation.cpp" />
|
||||
<ClCompile Include="scripting\HookEngine.cpp" />
|
||||
<ClCompile Include="scripting\Plugin.cpp" />
|
||||
<ClCompile Include="scripting\ScriptEngine.cpp" />
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
# include "bindings/network/ScSocket.hpp"
|
||||
# include "bindings/object/ScObject.hpp"
|
||||
# include "bindings/ride/ScRide.hpp"
|
||||
# include "bindings/ride/ScRideStation.hpp"
|
||||
# include "bindings/world/ScClimate.hpp"
|
||||
# include "bindings/world/ScDate.hpp"
|
||||
# include "bindings/world/ScMap.hpp"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# include "../../Duktape.hpp"
|
||||
# include "../../ScriptEngine.h"
|
||||
# include "../object/ScObject.hpp"
|
||||
# include "ScRideStation.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
@ -56,124 +57,6 @@ namespace OpenRCT2::Scripting
|
|||
return result;
|
||||
}
|
||||
|
||||
class ScRideStation
|
||||
{
|
||||
private:
|
||||
ride_id_t _rideId = RIDE_ID_NULL;
|
||||
StationIndex _stationIndex{};
|
||||
|
||||
public:
|
||||
ScRideStation(ride_id_t rideId, StationIndex stationIndex)
|
||||
: _rideId(rideId)
|
||||
, _stationIndex(stationIndex)
|
||||
{
|
||||
}
|
||||
|
||||
static void Register(duk_context* ctx)
|
||||
{
|
||||
dukglue_register_property(ctx, &ScRideStation::start_get, &ScRideStation::start_set, "start");
|
||||
dukglue_register_property(ctx, &ScRideStation::length_get, &ScRideStation::length_set, "length");
|
||||
dukglue_register_property(ctx, &ScRideStation::entrance_get, &ScRideStation::entrance_set, "entrance");
|
||||
dukglue_register_property(ctx, &ScRideStation::exit_get, &ScRideStation::exit_set, "exit");
|
||||
}
|
||||
|
||||
private:
|
||||
DukValue start_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
auto start = CoordsXYZ(station->Start, station->GetBaseZ());
|
||||
return ToDuk(ctx, start);
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void start_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
auto start = FromDuk<CoordsXYZ>(value);
|
||||
station->Start = { start.x, start.y };
|
||||
station->SetBaseZ(start.z);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t length_get() const
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return station->Length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void length_set(int32_t value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Length = value;
|
||||
}
|
||||
}
|
||||
|
||||
DukValue entrance_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return ToDuk(ctx, station->Entrance.ToCoordsXYZD());
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void entrance_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Entrance = FromDuk<CoordsXYZD>(value);
|
||||
}
|
||||
}
|
||||
|
||||
DukValue exit_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return ToDuk(ctx, station->Exit.ToCoordsXYZD());
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void exit_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Exit = FromDuk<CoordsXYZD>(value);
|
||||
}
|
||||
}
|
||||
|
||||
RideStation* GetRideStation() const
|
||||
{
|
||||
auto ride = get_ride(_rideId);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
if (_stationIndex < std::size(ride->stations))
|
||||
{
|
||||
return &ride->stations[_stationIndex];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
class ScRide
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2021 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "ScRideStation.hpp"
|
||||
|
||||
# include "../../../Context.h"
|
||||
# include "../../../common.h"
|
||||
# include "../../../ride/Ride.h"
|
||||
# include "../../Duktape.hpp"
|
||||
# include "../../ScriptEngine.h"
|
||||
# include "../object/ScObject.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
ScRideStation::ScRideStation(ride_id_t rideId, StationIndex stationIndex)
|
||||
: _rideId(rideId)
|
||||
, _stationIndex(stationIndex)
|
||||
{
|
||||
}
|
||||
|
||||
void ScRideStation::Register(duk_context* ctx)
|
||||
{
|
||||
dukglue_register_property(ctx, &ScRideStation::start_get, &ScRideStation::start_set, "start");
|
||||
dukglue_register_property(ctx, &ScRideStation::length_get, &ScRideStation::length_set, "length");
|
||||
dukglue_register_property(ctx, &ScRideStation::entrance_get, &ScRideStation::entrance_set, "entrance");
|
||||
dukglue_register_property(ctx, &ScRideStation::exit_get, &ScRideStation::exit_set, "exit");
|
||||
}
|
||||
|
||||
DukValue ScRideStation::start_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
auto start = CoordsXYZ(station->Start, station->GetBaseZ());
|
||||
return ToDuk(ctx, start);
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void ScRideStation::start_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
auto start = FromDuk<CoordsXYZ>(value);
|
||||
station->Start = { start.x, start.y };
|
||||
station->SetBaseZ(start.z);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ScRideStation::length_get() const
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return station->Length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScRideStation::length_set(int32_t value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Length = value;
|
||||
}
|
||||
}
|
||||
|
||||
DukValue ScRideStation::entrance_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return ToDuk(ctx, station->Entrance.ToCoordsXYZD());
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void ScRideStation::entrance_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Entrance = FromDuk<CoordsXYZD>(value);
|
||||
}
|
||||
}
|
||||
|
||||
DukValue ScRideStation::exit_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
return ToDuk(ctx, station->Exit.ToCoordsXYZD());
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
|
||||
void ScRideStation::exit_set(const DukValue& value)
|
||||
{
|
||||
auto station = GetRideStation();
|
||||
if (station != nullptr)
|
||||
{
|
||||
station->Exit = FromDuk<CoordsXYZD>(value);
|
||||
}
|
||||
}
|
||||
|
||||
RideStation* ScRideStation::GetRideStation() const
|
||||
{
|
||||
auto ride = get_ride(_rideId);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
if (_stationIndex < std::size(ride->stations))
|
||||
{
|
||||
return &ride->stations[_stationIndex];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2021 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "../../../Context.h"
|
||||
# include "../../../common.h"
|
||||
# include "../../../ride/Ride.h"
|
||||
# include "../../Duktape.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
class ScRideStation
|
||||
{
|
||||
private:
|
||||
ride_id_t _rideId = RIDE_ID_NULL;
|
||||
StationIndex _stationIndex{};
|
||||
|
||||
public:
|
||||
ScRideStation(ride_id_t rideId, StationIndex stationIndex);
|
||||
|
||||
static void Register(duk_context* ctx);
|
||||
|
||||
private:
|
||||
DukValue start_get() const;
|
||||
|
||||
void start_set(const DukValue& value);
|
||||
|
||||
int32_t length_get() const;
|
||||
|
||||
void length_set(int32_t value);
|
||||
|
||||
DukValue entrance_get() const;
|
||||
|
||||
void entrance_set(const DukValue& value);
|
||||
|
||||
DukValue exit_get() const;
|
||||
|
||||
void exit_set(const DukValue& value);
|
||||
|
||||
RideStation* GetRideStation() const;
|
||||
};
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue