2021-08-10 16:21:20 +03:00
|
|
|
/*****************************************************************************
|
2026-01-05 14:42:59 +01:00
|
|
|
* Copyright (c) 2014-2026 OpenRCT2 developers
|
2021-08-10 16:21:20 +03:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_SCRIPTING
|
|
|
|
|
|
2024-11-29 12:04:56 +09:00
|
|
|
#include "ScTileElement.hpp"
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2024-11-29 12:04:56 +09:00
|
|
|
#include "../../../Context.h"
|
|
|
|
|
#include "../../../core/Guard.hpp"
|
2026-01-11 19:18:53 +01:00
|
|
|
#include "../../../drawing/ScrollingText.h"
|
2024-11-29 12:04:56 +09:00
|
|
|
#include "../../../entity/EntityRegistry.h"
|
|
|
|
|
#include "../../../object/LargeSceneryEntry.h"
|
|
|
|
|
#include "../../../object/WallSceneryEntry.h"
|
|
|
|
|
#include "../../../ride/Ride.h"
|
|
|
|
|
#include "../../../ride/RideData.h"
|
|
|
|
|
#include "../../../world/Footpath.h"
|
2025-09-04 21:57:41 +02:00
|
|
|
#include "../../../world/Map.h"
|
2024-11-29 12:04:56 +09:00
|
|
|
#include "../../../world/Scenery.h"
|
|
|
|
|
#include "../../../world/tile_element/BannerElement.h"
|
|
|
|
|
#include "../../../world/tile_element/EntranceElement.h"
|
|
|
|
|
#include "../../../world/tile_element/LargeSceneryElement.h"
|
|
|
|
|
#include "../../../world/tile_element/PathElement.h"
|
|
|
|
|
#include "../../../world/tile_element/SmallSceneryElement.h"
|
|
|
|
|
#include "../../../world/tile_element/SurfaceElement.h"
|
|
|
|
|
#include "../../../world/tile_element/TrackElement.h"
|
|
|
|
|
#include "../../../world/tile_element/WallElement.h"
|
|
|
|
|
#include "../../ScriptEngine.h"
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2024-11-29 12:04:56 +09:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <utility>
|
2021-08-10 16:21:20 +03:00
|
|
|
|
|
|
|
|
namespace OpenRCT2::Scripting
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
static inline std::string TileElementTypeToString(const TileElement* element)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Surface:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "surface";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "footpath";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Track:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "track";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "small_scenery";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Entrance:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "entrance";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "wall";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "large_scenery";
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Banner:
|
2021-08-10 16:21:20 +03:00
|
|
|
return "banner";
|
|
|
|
|
default:
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
using OpaqueTileElementData = struct
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
TileElement* element;
|
|
|
|
|
CoordsXY coords;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static inline void Invalidate(OpaqueTileElementData* data)
|
|
|
|
|
{
|
|
|
|
|
MapInvalidateTileFull(data->coords);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::type_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
|
|
|
|
auto type = TileElementTypeToString(element);
|
|
|
|
|
return JSFromStdString(ctx, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::type_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_STR(value, ctx, jsValue);
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
|
|
|
|
RemoveBannerEntryIfNeeded(element, data->coords);
|
2021-08-10 16:21:20 +03:00
|
|
|
if (value == "surface")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Surface);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "footpath")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Path);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "track")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Track);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "small_scenery")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::SmallScenery);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "entrance")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Entrance);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "wall")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Wall);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "large_scenery")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::LargeScenery);
|
2021-08-10 16:21:20 +03:00
|
|
|
else if (value == "banner")
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setType(TileElementType::Banner);
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
|
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Element type not recognised!");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
CreateBannerEntryIfNeeded(element, data->coords);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::baseHeight_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, element->baseHeight);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::baseHeight_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(newBaseHeight, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->baseHeight = newBaseHeight;
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::baseZ_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, element->getBaseZ());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::baseZ_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->setBaseZ(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::clearanceHeight_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, element->clearanceHeight);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::clearanceHeight_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(newClearanceHeight, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->clearanceHeight = newClearanceHeight;
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::clearanceZ_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, element->getClearanceZ());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::clearanceZ_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->setClearanceZ(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::slope_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Surface:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSurface();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSlope());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSlope());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot read 'slope' property, tile element is not a SurfaceElement or WallElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::slope_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
const auto type = element->getType();
|
2021-12-11 00:30:59 +01:00
|
|
|
|
2021-12-11 00:39:39 +01:00
|
|
|
if (type == TileElementType::Surface)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSurface();
|
2021-12-11 00:30:59 +01:00
|
|
|
el->SetSlope(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-12-11 00:30:59 +01:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
else if (type == TileElementType::Wall)
|
2021-12-11 00:30:59 +01:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2021-12-11 00:30:59 +01:00
|
|
|
el->SetSlope(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
else
|
|
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'slope' property, tile element is not a SurfaceElement or WallElement.");
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::waterHeight_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewInt32(ctx, el->GetWaterHeight());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'waterHeight' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::waterHeight_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_INT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'waterHeight' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
|
|
|
|
el->SetWaterHeight(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::surfaceStyle_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSurfaceObjectIndex());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'surfaceStyle' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::surfaceStyle_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'surfaceStyle' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
2023-08-26 20:50:06 +03:00
|
|
|
el->SetSurfaceObjectIndex(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edgeStyle_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEdgeObjectIndex());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'edgeStyle' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edgeStyle_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'edgeStyle' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
2023-08-26 21:01:27 +03:00
|
|
|
el->SetEdgeObjectIndex(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::grassLength_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetGrassLength());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'grassLength' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::grassLength_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'grassLength' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
|
|
|
|
// TODO: Give warning when value > GRASS_LENGTH_CLUMPS_2
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetGrassLengthAndInvalidate(value, data->coords);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::hasOwnership_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->GetOwnership() & OWNERSHIP_OWNED);
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'hasOwnership' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::hasConstructionRights_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto ownership = el->GetOwnership();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, (ownership & OWNERSHIP_OWNED) || (ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'hasConstructionRights' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::ownership_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetOwnership());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'ownership' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::ownership_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'ownership' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
|
|
|
|
el->SetOwnership(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::parkFences_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetParkFences());
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 00:40:34 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'parkFences' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 00:40:34 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::parkFences_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSurface();
|
2022-05-08 00:40:34 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'parkFences' property, tile element is not a SurfaceElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 00:40:34 +02:00
|
|
|
|
|
|
|
|
el->SetParkFences(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::trackType_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetTrackType()));
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'trackType' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::trackType_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2022-05-08 19:54:33 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'trackType' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
|
2024-10-11 15:30:27 +02:00
|
|
|
el->SetTrackType(static_cast<TrackElemType>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::rideType_get(JSContext* ctx, JSValue thisValue)
|
2021-12-01 14:39:03 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2021-12-01 14:39:03 +01:00
|
|
|
if (el != nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetRideType());
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-12-01 14:39:03 +01:00
|
|
|
else
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2024-02-26 22:10:47 +01:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'rideType' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-12-01 14:39:03 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::rideType_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-12-01 14:39:03 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
2022-05-08 19:54:33 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
if (value >= RIDE_TYPE_COUNT)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2025-09-29 02:05:00 +10:00
|
|
|
scriptEngine.LogPluginInfo("'rideType' value is invalid.");
|
|
|
|
|
return JS_UNDEFINED;
|
2021-12-01 14:39:03 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'rideType' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
el->SetRideType(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-12-01 14:39:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::sequence_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSequenceIndex());
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Track:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
2022-12-14 08:21:21 -05:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
if (ride != nullptr)
|
|
|
|
|
{
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType == RtdSpecialType::maze)
|
2022-12-14 08:21:21 -05:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'sequence' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_NULL;
|
2022-12-14 08:21:21 -05:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSequenceIndex());
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSequenceIndex());
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot read 'sequence' property, tile element is not a TrackElement, "
|
|
|
|
|
"LargeSceneryElement, or EntranceElement.");
|
|
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::sequence_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2022-05-08 19:54:33 +02:00
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
RemoveBannerEntryIfNeeded(element, data->coords);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetSequenceIndex(value);
|
|
|
|
|
CreateBannerEntryIfNeeded(element, data->coords);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Track:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
auto ride = GetRide(el->GetRideIndex());
|
2022-12-14 08:21:21 -05:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
if (ride != nullptr)
|
|
|
|
|
{
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType == RtdSpecialType::maze)
|
2022-12-14 08:21:21 -05:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'sequence' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_UNDEFINED;
|
2022-12-14 08:21:21 -05:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
}
|
2022-05-05 23:59:19 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetSequenceIndex(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::Entrance:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetSequenceIndex(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
default:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot read 'sequence' property, tile element is not a TrackElement, "
|
|
|
|
|
"LargeSceneryElement, or EntranceElement.");
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::ride_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::Path:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!el->IsQueue())
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'ride' property, path is not a queue.");
|
|
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!el->GetRideIndex().IsNull())
|
|
|
|
|
return JS_NewUint32(ctx, el->GetRideIndex().ToUnderlying());
|
|
|
|
|
|
|
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::Track:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetRideIndex().ToUnderlying());
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetRideIndex().ToUnderlying());
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot read 'ride' property, tile element is not PathElement, TrackElement, or EntranceElement");
|
|
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::ride_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
|
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
case TileElementType::Path:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!el->IsQueue())
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set ride property, path is not a queue.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetRideIndex(RideId::FromUnderlying(value));
|
|
|
|
|
}
|
|
|
|
|
else if (JS_IsNull(jsValue))
|
|
|
|
|
{
|
|
|
|
|
el->SetRideIndex(RideId::GetNull());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'ride' must be a number or null.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Track:
|
|
|
|
|
{
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'ride' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetRideIndex(RideId::FromUnderlying(value));
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
|
{
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'ride' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetRideIndex(RideId::FromUnderlying(value));
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot set 'ride' property, tile element is not PathElement, TrackElement, or EntranceElement");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::station_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2025-09-29 02:05:00 +10:00
|
|
|
{
|
|
|
|
|
case TileElementType::Path:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!el->IsQueue())
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'station' property, path is not a queue.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (el->GetRideIndex().IsNull())
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'station' property, queue is not linked to a ride.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!el->GetStationIndex().IsNull())
|
|
|
|
|
return JS_NewUint32(ctx, el->GetStationIndex().ToUnderlying());
|
|
|
|
|
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Track:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!el->IsStation())
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'station' property, track is not a station.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_NewUint32(ctx, el->GetStationIndex().ToUnderlying());
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetStationIndex().ToUnderlying());
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo(
|
|
|
|
|
"Cannot read 'station' property, tile element is not PathElement, TrackElement, or EntranceElement");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::station_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
|
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2025-09-29 02:05:00 +10:00
|
|
|
{
|
|
|
|
|
case TileElementType::Path:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetStationIndex(StationIndex::FromUnderlying(value));
|
|
|
|
|
}
|
|
|
|
|
else if (JS_IsNull(jsValue))
|
|
|
|
|
{
|
|
|
|
|
el->SetStationIndex(StationIndex::GetNull());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'station' must be a number or null.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Track:
|
|
|
|
|
{
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'station' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetStationIndex(StationIndex::FromUnderlying(value));
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Entrance:
|
|
|
|
|
{
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'station' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetStationIndex(StationIndex::FromUnderlying(value));
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::hasChainLift_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->HasChain());
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'hasChainLift' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::hasChainLift_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2022-05-08 19:54:33 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'hasChainLift' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
|
|
|
|
|
el->SetHasChain(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::mazeEntry_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
2022-05-05 23:59:19 +02:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2025-09-29 02:05:00 +10:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'mazeEntry' property, element is not a TrackElement.");
|
|
|
|
|
return JS_NULL;
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
Ride* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2025-09-29 02:05:00 +10:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'mazeEntry' property, ride is invalid.");
|
|
|
|
|
return JS_NULL;
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType != RtdSpecialType::maze)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2025-09-29 02:05:00 +10:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'mazeEntry' property, ride is not a maze.");
|
|
|
|
|
return JS_NULL;
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
|
|
|
|
|
return JS_NewUint32(ctx, el->GetMazeEntry());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::mazeEntry_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
2022-05-08 19:54:33 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
if (!JS_IsNumber(jsValue))
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2025-09-29 02:05:00 +10:00
|
|
|
scriptEngine.LogPluginInfo("'mazeEntry' property must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'mazeEntry' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'mazeEntry' property, ride is invalid.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType != RtdSpecialType::maze)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'mazeEntry' property, ride is not a maze.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetMazeEntry(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::colourScheme_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'colourScheme' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'colourScheme' property, ride is invalid.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType == RtdSpecialType::maze)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'colourScheme' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_NewUint32(ctx, el->GetColourScheme());
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::colourScheme_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'colourScheme' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'colourScheme' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'colourScheme', ride is invalid.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType == RtdSpecialType::maze)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'colourScheme' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetColourScheme(static_cast<RideColourScheme>(value));
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::seatRotation_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'seatRotation' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'seatRotation' property, ride is invalid.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType == RtdSpecialType::maze)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'seatRotation' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_NewUint32(ctx, el->GetSeatRotation());
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::seatRotation_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'seatRotation' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'seatRotation' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto* ride = GetRide(el->GetRideIndex());
|
|
|
|
|
if (ride == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'seatRotation' property, ride is invalid.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto& rtd = ride->getRideTypeDescriptor();
|
|
|
|
|
if (rtd.specialType != RtdSpecialType::maze)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'seatRotation' property, TrackElement belongs to a maze.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetSeatRotation(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::brakeBoosterSpeed_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'brakeBoosterSpeed' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!trackTypeHasSpeedSetting(el->GetTrackType()))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'brakeBoosterSpeed' property, track element has no speed setting.");
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return JS_NewUint32(ctx, el->GetBrakeBoosterSpeed());
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::brakeBoosterSpeed_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
|
|
|
|
|
if (!JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("'brakeBoosterSpeed' must be a number.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el == nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'brakeBoosterSpeed' property, tile element is not a TrackElement.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!trackTypeHasSpeedSetting(el->GetTrackType()))
|
|
|
|
|
{
|
|
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'brakeBoosterSpeed' property, track element has no speed setting.");
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetBrakeBoosterSpeed(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::isInverted_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsInverted());
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'isInverted' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isInverted_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2022-05-08 19:54:33 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'isInverted' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
|
|
|
|
|
el->SetInverted(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::hasCableLift_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->HasCableLift());
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2022-05-08 19:54:33 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
2022-05-09 21:13:58 +02:00
|
|
|
scriptEngine.LogPluginInfo("Cannot read 'hasCableLift' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-05-08 19:54:33 +02:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::hasCableLift_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asTrack();
|
2022-05-08 19:54:33 +02:00
|
|
|
if (el == nullptr)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2022-05-09 21:13:58 +02:00
|
|
|
auto& scriptEngine = GetContext()->GetScriptEngine();
|
|
|
|
|
scriptEngine.LogPluginInfo("Cannot set 'hasCableLift' property, tile element is not a TrackElement.");
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2022-05-08 19:54:33 +02:00
|
|
|
|
|
|
|
|
el->SetHasCableLift(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isHighlighted_get(JSContext* ctx, JSValue thisValue)
|
2022-03-13 03:02:55 +00:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto el = data->element->asTrack();
|
2022-03-13 03:02:55 +00:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsHighlighted());
|
2022-03-13 03:02:55 +00:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2022-03-13 03:02:55 +00:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isHighlighted_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2022-03-13 03:02:55 +00:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto el = data->element->asTrack();
|
2022-03-13 03:02:55 +00:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetHighlight(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2022-03-13 03:02:55 +00:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2022-03-13 03:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::object_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2021-12-16 21:41:02 +01:00
|
|
|
auto index = el->GetLegacyPathEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
if (index != kObjectEntryIndexNull)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, index);
|
|
|
|
|
|
|
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEntryIndex());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEntryIndex());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEntryIndex());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Entrance:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEntranceType());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetBanner()->type);
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
default:
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
2021-10-27 14:21:14 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::object_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2021-10-27 14:21:14 +02:00
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-12-16 21:41:02 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2021-12-16 21:41:02 +01:00
|
|
|
el->SetLegacyPathEntryIndex(index);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2021-10-27 14:21:14 +02:00
|
|
|
el->SetEntryIndex(index);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
|
|
|
|
RemoveBannerEntryIfNeeded(element, data->coords);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2021-10-27 14:21:14 +02:00
|
|
|
el->SetEntryIndex(index);
|
2025-09-29 02:05:00 +10:00
|
|
|
CreateBannerEntryIfNeeded(element, data->coords);
|
|
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
|
|
|
|
RemoveBannerEntryIfNeeded(element, data->coords);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2021-10-27 14:21:14 +02:00
|
|
|
el->SetEntryIndex(index);
|
2025-09-29 02:05:00 +10:00
|
|
|
CreateBannerEntryIfNeeded(element, data->coords);
|
|
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Entrance:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asEntrance();
|
2021-10-27 14:21:14 +02:00
|
|
|
el->SetEntranceType(index);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(index, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2024-03-26 12:42:09 +01:00
|
|
|
el->GetBanner()->type = index;
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2024-03-26 12:42:09 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:30:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isHidden_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewBool(ctx, data->element->isInvisible());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-10-27 14:21:14 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isHidden_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(hide, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->setInvisible(hide);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::age_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSmallScenery();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetAge());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::age_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSmallScenery();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetAge(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::quadrant_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSmallScenery();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSceneryQuadrant());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::quadrant_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asSmallScenery();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetSceneryQuadrant(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::occupiedQuadrants_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, data->element->getOccupiedQuadrants());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::occupiedQuadrants_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->setOccupiedQuadrants(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isGhost_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewBool(ctx, data->element->isGhost());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isGhost_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
data->element->setGhost(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
|
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::primaryColour_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetPrimaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetPrimaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetPrimaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetBanner()->colour));
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
default:
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::primaryColour_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetPrimaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetPrimaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetPrimaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->GetBanner()->colour = static_cast<Drawing::Colour>(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2024-03-26 12:42:09 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:30:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::secondaryColour_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetSecondaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetSecondaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetSecondaryColour()));
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetBanner()->textColour));
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
default:
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::secondaryColour_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::SmallScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetSecondaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetSecondaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetSecondaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2024-03-26 12:42:09 +01:00
|
|
|
case TileElementType::Banner:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-12-16 21:09:14 +01:00
|
|
|
el->GetBanner()->textColour = static_cast<Drawing::TextColour>(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2024-03-26 12:42:09 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:30:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::tertiaryColour_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2022-06-09 21:03:32 +02:00
|
|
|
{
|
2023-10-01 12:27:04 +02:00
|
|
|
case TileElementType::SmallScenery:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetTertiaryColour()));
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::LargeScenery:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetTertiaryColour()));
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Wall:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, EnumValue(el->GetTertiaryColour()));
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::tertiaryColour_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2025-09-29 02:05:00 +10:00
|
|
|
{
|
|
|
|
|
case TileElementType::SmallScenery:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asSmallScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetTertiaryColour(static_cast<Drawing::Colour>(value));
|
|
|
|
|
Invalidate(data);
|
2023-10-01 12:27:04 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2022-06-09 21:03:32 +02:00
|
|
|
case TileElementType::LargeScenery:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetTertiaryColour(static_cast<Drawing::Colour>(value));
|
|
|
|
|
Invalidate(data);
|
2022-06-09 21:03:32 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::Wall:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2026-01-28 10:06:45 +01:00
|
|
|
el->SetTertiaryColour(static_cast<Drawing::Colour>(value));
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2022-06-09 21:03:32 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::bannerIndex_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
BannerIndex idx = data->element->GetBannerIndex();
|
2021-11-24 22:25:36 +02:00
|
|
|
if (idx == BannerIndex::GetNull())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, idx.ToUnderlying());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::bannerIndex_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::LargeScenery:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asLargeScenery();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetBannerIndex(BannerIndex::FromUnderlying(value));
|
|
|
|
|
}
|
2021-12-16 21:41:02 +01:00
|
|
|
else
|
|
|
|
|
el->SetBannerIndex(BannerIndex::GetNull());
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Wall:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asWall();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetBannerIndex(BannerIndex::FromUnderlying(value));
|
|
|
|
|
}
|
2021-12-16 21:41:02 +01:00
|
|
|
else
|
|
|
|
|
el->SetBannerIndex(BannerIndex::GetNull());
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Banner:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetIndex(BannerIndex::FromUnderlying(value));
|
|
|
|
|
}
|
2021-12-16 21:41:02 +01:00
|
|
|
else
|
|
|
|
|
el->SetIndex(BannerIndex::GetNull());
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:30:59 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-08-28 00:33:05 +02:00
|
|
|
// Deprecated in favor of separate 'edges' and 'corners' properties,
|
2021-08-10 16:21:20 +03:00
|
|
|
// left here to maintain compatibility with older plugins.
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edgesAndCorners_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el != nullptr ? el->GetEdgesAndCorners() : 0);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edgesAndCorners_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetEdgesAndCorners(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edges_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetEdges());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::edges_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetEdges(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::corners_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetCorners());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::corners_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetCorners(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::slopeDirection_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr && el->IsSloped())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetSlopeDirection());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::slopeDirection_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2021-08-10 16:21:20 +03:00
|
|
|
el->SetSloped(true);
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetSlopeDirection(value);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
el->SetSloped(false);
|
|
|
|
|
el->SetSlopeDirection(0);
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isQueue_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsQueue());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isQueue_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetIsQueue(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::queueBannerDirection_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr && el->HasQueueBanner())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetQueueBannerDirection());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::queueBannerDirection_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2021-08-10 16:21:20 +03:00
|
|
|
el->SetHasQueueBanner(true);
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetQueueBannerDirection(value);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
el->SetHasQueueBanner(false);
|
|
|
|
|
el->SetQueueBannerDirection(0);
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isBlockedByVehicle_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsBlockedByVehicle());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isBlockedByVehicle_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetIsBlockedByVehicle(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isWide_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsWide());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isWide_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
el->SetWide(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::surfaceObject_get(JSContext* ctx, JSValue thisValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Path)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2021-10-27 14:21:14 +02:00
|
|
|
auto index = el->GetSurfaceEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
if (index != kObjectEntryIndexNull)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, index);
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::surfaceObject_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Path)
|
2021-12-16 21:41:02 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetSurfaceEntryIndex(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::railingsObject_get(JSContext* ctx, JSValue thisValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Path)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2021-10-27 14:21:14 +02:00
|
|
|
auto index = el->GetRailingsEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
if (index != kObjectEntryIndexNull)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, index);
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::railingsObject_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Path)
|
2021-12-16 21:41:02 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
el->SetRailingsEntryIndex(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::addition_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr && el->HasAddition())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetAdditionEntryIndex());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::addition_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(addition, ctx, jsValue);
|
2024-06-07 05:39:22 +10:00
|
|
|
if (addition <= 254)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2023-05-20 10:33:02 +02:00
|
|
|
el->SetAdditionEntryIndex(addition);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
el->SetAddition(0);
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::additionStatus_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el != nullptr && el->HasAddition() && !el->IsQueue())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetAdditionStatus());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::additionStatus_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-12-16 21:41:02 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
{
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el->HasAddition() && !el->IsQueue())
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetAdditionStatus(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isAdditionBroken_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr && el->HasAddition())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->IsBroken());
|
2021-08-10 16:21:20 +03:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isAdditionBroken_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsBool(jsValue))
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
el->SetIsBroken(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isAdditionGhost_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el != nullptr && el->HasAddition())
|
|
|
|
|
return JS_NewBool(ctx, el->AdditionIsGhost());
|
|
|
|
|
else
|
|
|
|
|
return JS_NULL;
|
|
|
|
|
}
|
|
|
|
|
JSValue ScTileElement::isAdditionGhost_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
|
|
|
|
{
|
|
|
|
|
if (JS_IsBool(jsValue))
|
|
|
|
|
{
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asPath();
|
2025-09-29 02:05:00 +10:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
el->SetAdditionIsGhost(value);
|
|
|
|
|
Invalidate(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSValue ScTileElement::footpathObject_get(JSContext* ctx, JSValue thisValue)
|
|
|
|
|
{
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asEntrance();
|
2021-08-10 16:21:20 +03:00
|
|
|
if (el != nullptr)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
|
|
|
|
auto index = el->GetLegacyPathEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
if (index != kObjectEntryIndexNull)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, index);
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::footpathObject_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asEntrance();
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetLegacyPathEntryIndex(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::footpathSurfaceObject_get(JSContext* ctx, JSValue thisValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asEntrance();
|
2021-10-27 14:21:14 +02:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
|
|
|
|
auto index = el->GetSurfaceEntryIndex();
|
2025-01-22 17:16:55 +01:00
|
|
|
if (index != kObjectEntryIndexNull)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, index);
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::footpathSurfaceObject_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
if (JS_IsNumber(jsValue))
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asEntrance();
|
2021-12-16 21:41:02 +01:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
el->SetSurfaceEntryIndex(value);
|
|
|
|
|
Invalidate(data);
|
2021-12-16 21:41:02 +01:00
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::direction_get(JSContext* ctx, JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Banner:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewUint32(ctx, el->GetPosition());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
|
|
|
|
case TileElementType::Surface:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
return JS_NewUint32(ctx, element->getDirection());
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::direction_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_UINT32(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Banner:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = element->asBanner();
|
2021-08-10 16:21:20 +03:00
|
|
|
el->SetPosition(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
break;
|
|
|
|
|
}
|
2021-12-11 00:39:39 +01:00
|
|
|
case TileElementType::Path:
|
|
|
|
|
case TileElementType::Surface:
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
element->setDirection(value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::bannerText_get(JSContext* ctx, JSValue thisValue)
|
2024-03-26 12:42:09 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
BannerIndex idx = data->element->GetBannerIndex();
|
2024-03-26 12:42:09 +01:00
|
|
|
if (idx == BannerIndex::GetNull())
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2024-03-26 12:42:09 +01:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JSFromStdString(ctx, GetBanner(idx)->getText());
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::bannerText_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2024-03-26 12:42:09 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_STR(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
|
|
|
|
auto element = data->element;
|
|
|
|
|
BannerIndex idx = element->GetBannerIndex();
|
2024-03-26 12:42:09 +01:00
|
|
|
if (idx != BannerIndex::GetNull())
|
|
|
|
|
{
|
|
|
|
|
auto banner = GetBanner(idx);
|
|
|
|
|
banner->text = value;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() != TileElementType::Banner)
|
2024-03-26 12:42:09 +01:00
|
|
|
{
|
|
|
|
|
if (value.empty())
|
2025-05-20 23:36:51 +02:00
|
|
|
banner->rideIndex = BannerGetClosestRideIndex({ banner->position.ToCoordsXY(), 16 });
|
2024-03-26 12:42:09 +01:00
|
|
|
else
|
2025-05-20 23:36:51 +02:00
|
|
|
banner->rideIndex = RideId::GetNull();
|
2024-03-26 12:42:09 +01:00
|
|
|
|
2025-05-20 23:36:51 +02:00
|
|
|
banner->flags.set(BannerFlag::linkedToRide, !banner->rideIndex.IsNull());
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isNoEntry_get(JSContext* ctx, JSValue thisValue)
|
2024-03-26 12:42:09 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asBanner();
|
2024-03-26 12:42:09 +01:00
|
|
|
if (el != nullptr)
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NewBool(ctx, el->GetBanner()->flags.has(BannerFlag::noEntry));
|
2024-03-26 12:42:09 +01:00
|
|
|
else
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_NULL;
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::isNoEntry_set(JSContext* ctx, JSValue thisValue, JSValue jsValue)
|
2024-03-26 12:42:09 +01:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_UNPACK_BOOL(value, ctx, jsValue);
|
|
|
|
|
JS_THROW_IF_GAME_STATE_NOT_MUTABLE();
|
|
|
|
|
auto data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue);
|
2026-05-17 15:21:16 +02:00
|
|
|
auto* el = data->element->asBanner();
|
2024-03-26 12:42:09 +01:00
|
|
|
if (el != nullptr)
|
|
|
|
|
{
|
2025-05-20 23:28:40 +02:00
|
|
|
el->GetBanner()->flags.set(BannerFlag::noEntry, value);
|
2025-09-29 02:05:00 +10:00
|
|
|
Invalidate(data);
|
2024-03-26 12:42:09 +01:00
|
|
|
}
|
2025-09-29 02:05:00 +10:00
|
|
|
return JS_UNDEFINED;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
2024-05-17 12:54:51 +02:00
|
|
|
const LargeSceneryElement* ScTileElement::GetOtherLargeSceneryElement(
|
|
|
|
|
const CoordsXY& loc, const LargeSceneryElement* const largeScenery)
|
|
|
|
|
{
|
|
|
|
|
const auto* const largeEntry = largeScenery->GetEntry();
|
2026-05-17 15:21:16 +02:00
|
|
|
const auto direction = largeScenery->getDirection();
|
2024-05-17 12:54:51 +02:00
|
|
|
const auto sequenceIndex = largeScenery->GetSequenceIndex();
|
2024-10-16 22:35:29 +01:00
|
|
|
const auto& tiles = largeEntry->tiles;
|
|
|
|
|
const auto& initialTile = tiles[sequenceIndex];
|
2024-05-17 12:54:51 +02:00
|
|
|
const auto rotatedFirstTile = CoordsXYZ{
|
2024-10-16 22:35:29 +01:00
|
|
|
CoordsXY{ initialTile.offset }.Rotate(direction),
|
|
|
|
|
initialTile.offset.z,
|
2024-05-17 12:54:51 +02:00
|
|
|
};
|
|
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
const auto firstTile = CoordsXYZ{ loc, largeScenery->getBaseZ() } - rotatedFirstTile;
|
2024-10-16 22:35:29 +01:00
|
|
|
for (auto& tile : tiles)
|
2024-05-17 12:54:51 +02:00
|
|
|
{
|
2024-10-16 22:35:29 +01:00
|
|
|
const auto rotatedCurrentTile = CoordsXYZ{ CoordsXY{ tile.offset }.Rotate(direction), tile.offset.z };
|
2024-05-17 12:54:51 +02:00
|
|
|
|
|
|
|
|
const auto currentTile = firstTile + rotatedCurrentTile;
|
|
|
|
|
|
|
|
|
|
const TileElement* tileElement = MapGetFirstElementAt(currentTile);
|
|
|
|
|
if (tileElement != nullptr)
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->getType() != TileElementType::LargeScenery)
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->getDirection() != direction)
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->getBaseZ() != currentTile.z)
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
|
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->asLargeScenery() == largeScenery)
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->asLargeScenery()->GetEntryIndex() != largeScenery->GetEntryIndex())
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
2026-05-17 15:21:16 +02:00
|
|
|
if (tileElement->asLargeScenery()->GetSequenceIndex() != tile.index)
|
2024-05-17 12:54:51 +02:00
|
|
|
continue;
|
|
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
return tileElement->asLargeScenery();
|
|
|
|
|
} while (!(tileElement++)->isLastForTile());
|
2024-05-17 12:54:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
void ScTileElement::RemoveBannerEntryIfNeeded(TileElement* element, CoordsXY& coords)
|
2024-05-17 12:54:51 +02:00
|
|
|
{
|
|
|
|
|
// check if other element still uses the banner entry
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::LargeScenery
|
|
|
|
|
&& element->asLargeScenery()->GetEntry()->scrolling_mode != kScrollingModeNone
|
|
|
|
|
&& GetOtherLargeSceneryElement(coords, element->asLargeScenery()) != nullptr)
|
2024-05-17 12:54:51 +02:00
|
|
|
return;
|
|
|
|
|
// remove banner entry (if one exists)
|
2025-09-29 02:05:00 +10:00
|
|
|
element->RemoveBannerEntry();
|
2024-05-17 12:54:51 +02:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
void ScTileElement::CreateBannerEntryIfNeeded(TileElement* element, CoordsXY& coords)
|
2024-05-17 12:54:51 +02:00
|
|
|
{
|
|
|
|
|
// check if creation is needed
|
2026-05-17 15:21:16 +02:00
|
|
|
switch (element->getType())
|
2024-05-17 12:54:51 +02:00
|
|
|
{
|
|
|
|
|
case TileElementType::Banner:
|
|
|
|
|
break;
|
|
|
|
|
case TileElementType::Wall:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto wallEntry = element->asWall()->GetEntry();
|
2025-05-20 22:57:59 +02:00
|
|
|
if (wallEntry == nullptr || wallEntry->scrolling_mode == kScrollingModeNone)
|
2024-05-17 12:54:51 +02:00
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TileElementType::LargeScenery:
|
|
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
auto largeScenery = element->asLargeScenery();
|
2024-05-17 12:54:51 +02:00
|
|
|
auto largeSceneryEntry = largeScenery->GetEntry();
|
2025-05-20 22:57:59 +02:00
|
|
|
if (largeSceneryEntry == nullptr || largeSceneryEntry->scrolling_mode == kScrollingModeNone)
|
2024-05-17 12:54:51 +02:00
|
|
|
return;
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
auto otherElement = GetOtherLargeSceneryElement(coords, largeScenery);
|
2024-05-17 12:54:51 +02:00
|
|
|
if (otherElement != nullptr)
|
|
|
|
|
{
|
|
|
|
|
largeScenery->SetBannerIndex(otherElement->GetBannerIndex());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create banner entry and initialise it
|
|
|
|
|
auto* banner = CreateBanner();
|
|
|
|
|
if (banner == nullptr)
|
|
|
|
|
GetContext()->GetScriptEngine().LogPluginInfo("No free banners available.");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
banner->text = {};
|
2026-01-28 10:06:45 +01:00
|
|
|
banner->colour = Drawing::Colour::black;
|
2025-12-16 21:09:14 +01:00
|
|
|
banner->textColour = Drawing::TextColour::black;
|
2025-05-20 23:28:40 +02:00
|
|
|
banner->flags = {};
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Wall)
|
2025-05-20 23:28:40 +02:00
|
|
|
banner->flags.set(BannerFlag::isWall);
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::LargeScenery)
|
2025-05-20 23:28:40 +02:00
|
|
|
banner->flags.set(BannerFlag::isLargeScenery);
|
2024-05-17 12:54:51 +02:00
|
|
|
banner->type = 0;
|
2025-09-29 02:05:00 +10:00
|
|
|
banner->position = TileCoordsXY(coords);
|
2024-05-17 12:54:51 +02:00
|
|
|
|
2026-05-17 15:21:16 +02:00
|
|
|
if (element->getType() == TileElementType::Wall || element->getType() == TileElementType::LargeScenery)
|
2024-05-17 12:54:51 +02:00
|
|
|
{
|
2026-05-17 15:21:16 +02:00
|
|
|
RideId rideIndex = BannerGetClosestRideIndex({ coords, element->baseHeight });
|
2024-05-17 12:54:51 +02:00
|
|
|
if (!rideIndex.IsNull())
|
|
|
|
|
{
|
2025-05-20 23:36:51 +02:00
|
|
|
banner->rideIndex = rideIndex;
|
2025-05-20 23:28:40 +02:00
|
|
|
banner->flags.set(BannerFlag::linkedToRide);
|
2024-05-17 12:54:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
element->SetBannerIndex(banner->id);
|
2024-05-17 12:54:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
TileElement* ScTileElement::GetTileElement(JSValue thisValue)
|
2021-08-10 16:21:20 +03:00
|
|
|
{
|
2025-09-29 02:05:00 +10:00
|
|
|
return gScTileElement.GetOpaque<OpaqueTileElementData*>(thisValue)->element;
|
|
|
|
|
}
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JSValue ScTileElement::New(JSContext* ctx, TileElement* element, CoordsXY& coords)
|
2026-03-02 00:48:18 +11:00
|
|
|
{
|
|
|
|
|
return MakeWithOpaque(ctx, new OpaqueTileElementData{ element, coords });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScTileElement::Register(JSContext* ctx)
|
2025-09-29 02:05:00 +10:00
|
|
|
{
|
|
|
|
|
static constexpr JSCFunctionListEntry funcs[] = {
|
|
|
|
|
// All
|
|
|
|
|
JS_CGETSET_DEF("type", ScTileElement::type_get, ScTileElement::type_set),
|
|
|
|
|
JS_CGETSET_DEF("baseHeight", ScTileElement::baseHeight_get, ScTileElement::baseHeight_set),
|
|
|
|
|
JS_CGETSET_DEF("baseZ", ScTileElement::baseZ_get, ScTileElement::baseZ_set),
|
|
|
|
|
JS_CGETSET_DEF("clearanceHeight", ScTileElement::clearanceHeight_get, ScTileElement::clearanceHeight_set),
|
|
|
|
|
JS_CGETSET_DEF("clearanceZ", ScTileElement::clearanceZ_get, ScTileElement::clearanceZ_set),
|
|
|
|
|
JS_CGETSET_DEF("occupiedQuadrants", ScTileElement::occupiedQuadrants_get, ScTileElement::occupiedQuadrants_set),
|
|
|
|
|
JS_CGETSET_DEF("isGhost", ScTileElement::isGhost_get, ScTileElement::isGhost_set),
|
|
|
|
|
JS_CGETSET_DEF("isHidden", ScTileElement::isHidden_get, ScTileElement::isHidden_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Track | Small Scenery | Wall | Entrance | Large Scenery | Banner
|
|
|
|
|
JS_CGETSET_DEF("direction", ScTileElement::direction_get, ScTileElement::direction_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Path | Small Scenery | Wall | Entrance | Large Scenery | Banner
|
|
|
|
|
JS_CGETSET_DEF("object", ScTileElement::object_get, ScTileElement::object_set),
|
2024-03-26 12:42:09 +01:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Small Scenery | Wall | Large Scenery | Banner
|
|
|
|
|
JS_CGETSET_DEF("primaryColour", ScTileElement::primaryColour_get, ScTileElement::primaryColour_set),
|
|
|
|
|
JS_CGETSET_DEF("secondaryColour", ScTileElement::secondaryColour_get, ScTileElement::secondaryColour_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Small Scenery | Wall | Large Scenery
|
|
|
|
|
JS_CGETSET_DEF("tertiaryColour", ScTileElement::tertiaryColour_get, ScTileElement::tertiaryColour_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Wall | Large Scenery | Banner
|
|
|
|
|
JS_CGETSET_DEF("bannerText", ScTileElement::bannerText_get, ScTileElement::bannerText_set),
|
|
|
|
|
JS_CGETSET_DEF("bannerIndex", ScTileElement::bannerIndex_get, ScTileElement::bannerIndex_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Path | Track | Entrance
|
|
|
|
|
JS_CGETSET_DEF("ride", ScTileElement::ride_get, ScTileElement::ride_set),
|
|
|
|
|
JS_CGETSET_DEF("station", ScTileElement::station_get, ScTileElement::station_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Track | Entrance | Large Scenery
|
|
|
|
|
JS_CGETSET_DEF("sequence", ScTileElement::sequence_get, ScTileElement::sequence_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Surface | Wall
|
|
|
|
|
JS_CGETSET_DEF("slope", ScTileElement::slope_get, ScTileElement::slope_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Surface only
|
|
|
|
|
JS_CGETSET_DEF("waterHeight", ScTileElement::waterHeight_get, ScTileElement::waterHeight_set),
|
|
|
|
|
JS_CGETSET_DEF("surfaceStyle", ScTileElement::surfaceStyle_get, ScTileElement::surfaceStyle_set),
|
|
|
|
|
JS_CGETSET_DEF("edgeStyle", ScTileElement::edgeStyle_get, ScTileElement::edgeStyle_set),
|
|
|
|
|
JS_CGETSET_DEF("grassLength", ScTileElement::grassLength_get, ScTileElement::grassLength_set),
|
|
|
|
|
JS_CGETSET_DEF("hasOwnership", ScTileElement::hasOwnership_get, nullptr),
|
|
|
|
|
JS_CGETSET_DEF("hasConstructionRights", ScTileElement::hasConstructionRights_get, nullptr),
|
|
|
|
|
JS_CGETSET_DEF("ownership", ScTileElement::ownership_get, ScTileElement::ownership_set),
|
|
|
|
|
JS_CGETSET_DEF("parkFences", ScTileElement::parkFences_get, ScTileElement::parkFences_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Footpath only
|
|
|
|
|
JS_CGETSET_DEF("edgesAndCorners", ScTileElement::edgesAndCorners_get, ScTileElement::edgesAndCorners_set),
|
|
|
|
|
JS_CGETSET_DEF("edges", ScTileElement::edges_get, ScTileElement::edges_set),
|
|
|
|
|
JS_CGETSET_DEF("corners", ScTileElement::corners_get, ScTileElement::corners_set),
|
|
|
|
|
JS_CGETSET_DEF("slopeDirection", ScTileElement::slopeDirection_get, ScTileElement::slopeDirection_set),
|
|
|
|
|
JS_CGETSET_DEF("isQueue", ScTileElement::isQueue_get, ScTileElement::isQueue_set),
|
|
|
|
|
JS_CGETSET_DEF(
|
|
|
|
|
"queueBannerDirection", ScTileElement::queueBannerDirection_get, ScTileElement::queueBannerDirection_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_CGETSET_DEF("isBlockedByVehicle", ScTileElement::isBlockedByVehicle_get, ScTileElement::isBlockedByVehicle_set),
|
|
|
|
|
JS_CGETSET_DEF("isWide", ScTileElement::isWide_get, ScTileElement::isWide_set),
|
2021-10-27 14:21:14 +02:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_CGETSET_DEF("surfaceObject", ScTileElement::surfaceObject_get, ScTileElement::surfaceObject_set),
|
|
|
|
|
JS_CGETSET_DEF("railingsObject", ScTileElement::railingsObject_get, ScTileElement::railingsObject_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
JS_CGETSET_DEF("addition", ScTileElement::addition_get, ScTileElement::addition_set),
|
|
|
|
|
JS_CGETSET_DEF("additionStatus", ScTileElement::additionStatus_get, ScTileElement::additionStatus_set),
|
|
|
|
|
JS_CGETSET_DEF("isAdditionBroken", ScTileElement::isAdditionBroken_get, ScTileElement::isAdditionBroken_set),
|
|
|
|
|
JS_CGETSET_DEF("isAdditionGhost", ScTileElement::isAdditionGhost_get, ScTileElement::isAdditionGhost_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Track only
|
|
|
|
|
JS_CGETSET_DEF("trackType", ScTileElement::trackType_get, ScTileElement::trackType_set),
|
|
|
|
|
JS_CGETSET_DEF("rideType", ScTileElement::rideType_get, ScTileElement::rideType_set),
|
|
|
|
|
JS_CGETSET_DEF("mazeEntry", ScTileElement::mazeEntry_get, ScTileElement::mazeEntry_set),
|
|
|
|
|
JS_CGETSET_DEF("colourScheme", ScTileElement::colourScheme_get, ScTileElement::colourScheme_set),
|
|
|
|
|
JS_CGETSET_DEF("seatRotation", ScTileElement::seatRotation_get, ScTileElement::seatRotation_set),
|
|
|
|
|
JS_CGETSET_DEF("brakeBoosterSpeed", ScTileElement::brakeBoosterSpeed_get, ScTileElement::brakeBoosterSpeed_set),
|
|
|
|
|
JS_CGETSET_DEF("hasChainLift", ScTileElement::hasChainLift_get, ScTileElement::hasChainLift_set),
|
|
|
|
|
JS_CGETSET_DEF("isInverted", ScTileElement::isInverted_get, ScTileElement::isInverted_set),
|
|
|
|
|
JS_CGETSET_DEF("hasCableLift", ScTileElement::hasCableLift_get, ScTileElement::hasCableLift_set),
|
|
|
|
|
JS_CGETSET_DEF("isHighlighted", ScTileElement::isHighlighted_get, ScTileElement::isHighlighted_set),
|
2021-08-10 16:21:20 +03:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Small Scenery only
|
|
|
|
|
JS_CGETSET_DEF("age", ScTileElement::age_get, ScTileElement::age_set),
|
|
|
|
|
JS_CGETSET_DEF("quadrant", ScTileElement::quadrant_get, ScTileElement::quadrant_set),
|
2024-03-26 12:42:09 +01:00
|
|
|
|
2025-09-29 02:05:00 +10:00
|
|
|
// Entrance only
|
|
|
|
|
JS_CGETSET_DEF("footpathObject", ScTileElement::footpathObject_get, ScTileElement::footpathObject_set),
|
|
|
|
|
JS_CGETSET_DEF(
|
|
|
|
|
"footpathSurfaceObject", ScTileElement::footpathSurfaceObject_get, ScTileElement::footpathSurfaceObject_set),
|
|
|
|
|
|
|
|
|
|
// Banner only
|
|
|
|
|
JS_CGETSET_DEF("isNoEntry", ScTileElement::isNoEntry_get, ScTileElement::isNoEntry_set)
|
|
|
|
|
};
|
2026-03-02 00:48:18 +11:00
|
|
|
RegisterBase(ctx, "TileElement", Finalize, funcs);
|
2025-09-29 02:05:00 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScTileElement::Finalize(JSRuntime* rt, JSValue thisVal)
|
|
|
|
|
{
|
|
|
|
|
OpaqueTileElementData* data = gScTileElement.GetOpaque<OpaqueTileElementData*>(thisVal);
|
|
|
|
|
if (data)
|
|
|
|
|
delete data;
|
2021-08-10 16:21:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace OpenRCT2::Scripting
|
|
|
|
|
|
|
|
|
|
#endif
|