forked from OpenRCT2/OpenRCT2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
327 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/***************************************************************************** | ||
* Copyright (c) 2014-2024 OpenRCT2 developers | ||
* | ||
* For a complete list of all authors, please refer to contributors.md | ||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 | ||
* | ||
* OpenRCT2 is licensed under the GNU General Public License version 3. | ||
*****************************************************************************/ | ||
|
||
#include "ScParticle.hpp" | ||
|
||
#include "../ride/ScRide.hpp" | ||
|
||
#ifdef ENABLE_SCRIPTING | ||
|
||
namespace OpenRCT2::Scripting | ||
{ | ||
|
||
ScCrashedVehicleParticle::ScCrashedVehicleParticle(EntityId id) | ||
: ScEntity(id) | ||
{ | ||
} | ||
void ScCrashedVehicleParticle::Register(duk_context* ctx) | ||
{ | ||
dukglue_set_base_class<ScEntity, ScCrashedVehicleParticle>(ctx); | ||
dukglue_register_property( | ||
ctx, &ScCrashedVehicleParticle::acceleration_get, &ScCrashedVehicleParticle::acceleration_set, "acceleration"); | ||
dukglue_register_property( | ||
ctx, &ScCrashedVehicleParticle::velocity_get, &ScCrashedVehicleParticle::velocity_set, "velocity"); | ||
dukglue_register_property( | ||
ctx, &ScCrashedVehicleParticle::colours_get, &ScCrashedVehicleParticle::colours_set, "colours"); | ||
dukglue_register_property( | ||
ctx, &ScCrashedVehicleParticle::timeToLive_get, &ScCrashedVehicleParticle::timeToLive_set, "timeToLive"); | ||
dukglue_register_property( | ||
ctx, &ScCrashedVehicleParticle::crashedSpriteBase_get, &ScCrashedVehicleParticle::crashedSpriteBase_set, "frame"); | ||
dukglue_register_property(ctx, &ScCrashedVehicleParticle::frame_get, &ScCrashedVehicleParticle::frame_set, "frame"); | ||
dukglue_register_method(ctx, &ScCrashedVehicleParticle::SetupValues, "setupValues"); | ||
} | ||
|
||
VehicleCrashParticle* ScCrashedVehicleParticle::GetCrashedVehicleParticle() const | ||
{ | ||
return ::GetEntity<VehicleCrashParticle>(_id); | ||
} | ||
|
||
void ScCrashedVehicleParticle::frame_set(uint16_t value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
entity->frame = value; | ||
} | ||
} | ||
|
||
uint16_t ScCrashedVehicleParticle::frame_get() const | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return entity->frame; | ||
} | ||
return 0; | ||
} | ||
|
||
void ScCrashedVehicleParticle::crashedSpriteBase_set(uint16_t value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
entity->crashed_sprite_base = value; | ||
} | ||
} | ||
|
||
uint16_t ScCrashedVehicleParticle::crashedSpriteBase_get() const | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return entity->crashed_sprite_base; | ||
} | ||
return 0; | ||
} | ||
|
||
void ScCrashedVehicleParticle::timeToLive_set(uint16_t value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
entity->time_to_live = value; | ||
} | ||
} | ||
|
||
uint16_t ScCrashedVehicleParticle::timeToLive_get() const | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return entity->time_to_live; | ||
} | ||
return 0; | ||
} | ||
|
||
void ScCrashedVehicleParticle::velocity_set(const DukValue& value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
auto velocity = FromDuk<CoordsXYZ>(value); | ||
entity->velocity_x = velocity.x; | ||
entity->velocity_y = velocity.y; | ||
entity->velocity_z = velocity.z; | ||
} | ||
} | ||
|
||
DukValue ScCrashedVehicleParticle::velocity_get() const | ||
{ | ||
auto ctx = GetContext()->GetScriptEngine().GetContext(); | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return ToDuk(ctx, CoordsXYZ(entity->velocity_x, entity->velocity_y, entity->velocity_z)); | ||
} | ||
return {}; | ||
} | ||
|
||
void ScCrashedVehicleParticle::acceleration_set(const DukValue& value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
auto acceleration = FromDuk<CoordsXYZ>(value); | ||
entity->acceleration_x = acceleration.x; | ||
entity->acceleration_y = acceleration.y; | ||
entity->acceleration_z = acceleration.z; | ||
} | ||
} | ||
|
||
DukValue ScCrashedVehicleParticle::acceleration_get() const | ||
{ | ||
auto ctx = GetContext()->GetScriptEngine().GetContext(); | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return ToDuk(ctx, CoordsXYZ(entity->acceleration_x, entity->acceleration_y, entity->acceleration_z)); | ||
} | ||
return {}; | ||
} | ||
|
||
void ScCrashedVehicleParticle::SetupValues(const DukValue& value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
auto colours = FromDuk<VehicleColour>(value); | ||
entity->SetupValues(colours); | ||
} | ||
} | ||
|
||
DukValue ScCrashedVehicleParticle::colours_get() const | ||
{ | ||
auto ctx = GetContext()->GetScriptEngine().GetContext(); | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
return ToDuk<VehicleColour>(ctx, VehicleColour(entity->colour[0], entity->colour[1], 0)); | ||
} | ||
return ToDuk(ctx, nullptr); | ||
} | ||
|
||
void ScCrashedVehicleParticle::colours_set(const DukValue& value) | ||
{ | ||
auto entity = GetCrashedVehicleParticle(); | ||
if (entity != nullptr) | ||
{ | ||
auto colours = FromDuk<VehicleColour>(value); | ||
entity->colour[0] = colours.Body; | ||
entity->colour[1] = colours.Trim; | ||
} | ||
} | ||
}; // namespace OpenRCT2::Scripting | ||
|
||
#endif |
Oops, something went wrong.