Move ScPeep ScGuest and ScStaff to their own files

This commit is contained in:
ZehMatt 2021-08-09 19:56:11 +03:00
parent 33e2878d2d
commit 2e951877cb
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
9 changed files with 823 additions and 615 deletions

View File

@ -774,6 +774,11 @@
F8A3BFA6806D448B86F1FF6A /* ScTile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 22D7DD798F054A068273739B /* ScTile.hpp */; };
73FB2E7C254144D9BAE4925A /* ScVehicle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B734D45D6B1D45E89AD2E6CE /* ScVehicle.cpp */; };
D274ADAB9B644AC581EA2299 /* ScVehicle.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8E2C4C07B668487DA3493122 /* ScVehicle.hpp */; };
BC39D70B9A2249E4B14E99FA /* ScGuest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DB792F5A06849BDAF95B28F /* ScGuest.cpp */; };
428B1DADD66C4829894AD0A1 /* ScGuest.hpp in Headers */ = {isa = PBXBuildFile; fileRef = CAFBD63A702F42F2BDB53A39 /* ScGuest.hpp */; };
D7B575F07C4D4E42887C72AA /* ScPeep.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */; };
7A06F880718F49CA9FB71F52 /* ScStaff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */; };
9DF65BAE250C4307AE5794DB /* ScStaff.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C30AB6C640464647ABE90EC4 /* ScStaff.hpp */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -1850,6 +1855,11 @@
22D7DD798F054A068273739B /* ScTile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScTile.hpp; path = src/openrct2/scripting/bindings/world/ScTile.hpp; sourceTree = SOURCE_ROOT; };
B734D45D6B1D45E89AD2E6CE /* ScVehicle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScVehicle.cpp; path = src/openrct2/scripting/bindings/entity/ScVehicle.cpp; sourceTree = SOURCE_ROOT; };
8E2C4C07B668487DA3493122 /* ScVehicle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScVehicle.hpp; path = src/openrct2/scripting/bindings/entity/ScVehicle.hpp; sourceTree = SOURCE_ROOT; };
5DB792F5A06849BDAF95B28F /* ScGuest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScGuest.cpp; path = src/openrct2/scripting/bindings/entity/ScGuest.cpp; sourceTree = SOURCE_ROOT; };
CAFBD63A702F42F2BDB53A39 /* ScGuest.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScGuest.hpp; path = src/openrct2/scripting/bindings/entity/ScGuest.hpp; sourceTree = SOURCE_ROOT; };
2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScPeep.hpp; path = src/openrct2/scripting/bindings/entity/ScPeep.hpp; sourceTree = SOURCE_ROOT; };
3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScStaff.cpp; path = src/openrct2/scripting/bindings/entity/ScStaff.cpp; sourceTree = SOURCE_ROOT; };
C30AB6C640464647ABE90EC4 /* ScStaff.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScStaff.hpp; path = src/openrct2/scripting/bindings/entity/ScStaff.hpp; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -3365,6 +3375,11 @@
6DF61461D47C40CF92019B24 /* ScEntity.hpp */,
B734D45D6B1D45E89AD2E6CE /* ScVehicle.cpp */,
8E2C4C07B668487DA3493122 /* ScVehicle.hpp */,
5DB792F5A06849BDAF95B28F /* ScGuest.cpp */,
CAFBD63A702F42F2BDB53A39 /* ScGuest.hpp */,
2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */,
3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */,
C30AB6C640464647ABE90EC4 /* ScStaff.hpp */,
);
name = entity;
sourceTree = "<group>";
@ -3563,6 +3578,9 @@
0AFABA9549854247A5C61D52 /* ScScenario.hpp in Headers */,
F8A3BFA6806D448B86F1FF6A /* ScTile.hpp in Headers */,
D274ADAB9B644AC581EA2299 /* ScVehicle.hpp in Headers */,
428B1DADD66C4829894AD0A1 /* ScGuest.hpp in Headers */,
D7B575F07C4D4E42887C72AA /* ScPeep.hpp in Headers */,
9DF65BAE250C4307AE5794DB /* ScStaff.hpp in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -4369,6 +4387,8 @@
0746674FA0794ABF86E406A1 /* Litter.cpp in Sources */,
B9B6F97CE24E4A559C7BBA0A /* RideConstruction.cpp in Sources */,
73FB2E7C254144D9BAE4925A /* ScVehicle.cpp in Sources */,
BC39D70B9A2249E4B14E99FA /* ScGuest.cpp in Sources */,
7A06F880718F49CA9FB71F52 /* ScStaff.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -405,6 +405,9 @@
<ClInclude Include="scenario\Scenario.h" />
<ClInclude Include="scenario\ScenarioRepository.h" />
<ClInclude Include="scenario\ScenarioSources.h" />
<ClInclude Include="scripting\bindings\entity\ScGuest.hpp" />
<ClInclude Include="scripting\bindings\entity\ScPeep.hpp" />
<ClInclude Include="scripting\bindings\entity\ScStaff.hpp" />
<ClInclude Include="scripting\bindings\entity\ScVehicle.hpp" />
<ClInclude Include="scripting\Duktape.hpp" />
<ClInclude Include="scripting\HookEngine.h" />
@ -850,6 +853,8 @@
<ClCompile Include="scenario\Scenario.cpp" />
<ClCompile Include="scenario\ScenarioRepository.cpp" />
<ClCompile Include="scenario\ScenarioSources.cpp" />
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
<ClCompile Include="scripting\bindings\entity\ScVehicle.cpp" />
<ClCompile Include="scripting\HookEngine.cpp" />
<ClCompile Include="scripting\Plugin.cpp" />

View File

@ -25,6 +25,9 @@
# include "../platform/Platform2.h"
# include "Duktape.hpp"
# include "bindings/entity/ScEntity.hpp"
# include "bindings/entity/ScGuest.hpp"
# include "bindings/entity/ScPeep.hpp"
# include "bindings/entity/ScStaff.hpp"
# include "bindings/game/ScCheats.hpp"
# include "bindings/game/ScConsole.hpp"
# include "bindings/game/ScContext.hpp"

View File

@ -210,621 +210,6 @@ namespace OpenRCT2::Scripting
}
};
static const DukEnumMap<uint32_t> PeepFlagMap({
{ "leavingPark", PEEP_FLAGS_LEAVING_PARK },
{ "slowWalk", PEEP_FLAGS_SLOW_WALK },
{ "tracking", PEEP_FLAGS_TRACKING },
{ "waving", PEEP_FLAGS_WAVING },
{ "hasPaidForParkEntry", PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY },
{ "photo", PEEP_FLAGS_PHOTO },
{ "painting", PEEP_FLAGS_PAINTING },
{ "wow", PEEP_FLAGS_WOW },
{ "litter", PEEP_FLAGS_LITTER },
{ "lost", PEEP_FLAGS_LOST },
{ "hunger", PEEP_FLAGS_HUNGER },
{ "toilet", PEEP_FLAGS_TOILET },
{ "crowded", PEEP_FLAGS_CROWDED },
{ "happiness", PEEP_FLAGS_HAPPINESS },
{ "nausea", PEEP_FLAGS_NAUSEA },
{ "purple", PEEP_FLAGS_PURPLE },
{ "pizza", PEEP_FLAGS_PIZZA },
{ "explode", PEEP_FLAGS_EXPLODE },
{ "rideShouldBeMarkedAsFavourite", PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE },
{ "parkEntranceChosen", PEEP_FLAGS_PARK_ENTRANCE_CHOSEN },
{ "contagious", PEEP_FLAGS_CONTAGIOUS },
{ "joy", PEEP_FLAGS_JOY },
{ "angry", PEEP_FLAGS_ANGRY },
{ "iceCream", PEEP_FLAGS_ICE_CREAM },
{ "hereWeAre", PEEP_FLAGS_HERE_WE_ARE },
});
class ScPeep : public ScEntity
{
public:
ScPeep(uint16_t id)
: ScEntity(id)
{
}
static void Register(duk_context* ctx)
{
dukglue_set_base_class<ScEntity, ScPeep>(ctx);
dukglue_register_property(ctx, &ScPeep::peepType_get, nullptr, "peepType");
dukglue_register_property(ctx, &ScPeep::name_get, &ScPeep::name_set, "name");
dukglue_register_property(ctx, &ScPeep::destination_get, &ScPeep::destination_set, "destination");
dukglue_register_property(ctx, &ScPeep::energy_get, &ScPeep::energy_set, "energy");
dukglue_register_property(ctx, &ScPeep::energyTarget_get, &ScPeep::energyTarget_set, "energyTarget");
dukglue_register_method(ctx, &ScPeep::getFlag, "getFlag");
dukglue_register_method(ctx, &ScPeep::setFlag, "setFlag");
}
private:
std::string peepType_get() const
{
auto peep = GetPeep();
if (peep != nullptr)
{
return peep->Is<Staff>() ? "staff" : "guest";
}
return "";
}
std::string name_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->GetName() : std::string();
}
void name_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->SetName(value);
}
}
bool getFlag(const std::string& key) const
{
auto peep = GetPeep();
if (peep != nullptr)
{
auto mask = PeepFlagMap[key];
return (peep->PeepFlags & mask) != 0;
}
return false;
}
void setFlag(const std::string& key, bool value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
auto mask = PeepFlagMap[key];
if (value)
peep->PeepFlags |= mask;
else
peep->PeepFlags &= ~mask;
peep->Invalidate();
}
}
DukValue destination_get() const
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
auto peep = GetPeep();
if (peep != nullptr)
{
return ToDuk(ctx, peep->GetDestination());
}
return ToDuk(ctx, nullptr);
}
void destination_set(const DukValue& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
auto pos = FromDuk<CoordsXY>(value);
peep->SetDestination(pos);
peep->Invalidate();
}
}
uint8_t energy_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->Energy : 0;
}
void energy_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->Energy = value;
}
}
uint8_t energyTarget_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->EnergyTarget : 0;
}
void energyTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->EnergyTarget = value;
}
}
protected:
Peep* GetPeep() const
{
return ::GetEntity<Peep>(_id);
}
};
class ScGuest : public ScPeep
{
public:
ScGuest(uint16_t id)
: ScPeep(id)
{
}
static void Register(duk_context* ctx)
{
dukglue_set_base_class<ScPeep, ScGuest>(ctx);
dukglue_register_property(ctx, &ScGuest::tshirtColour_get, &ScGuest::tshirtColour_set, "tshirtColour");
dukglue_register_property(ctx, &ScGuest::trousersColour_get, &ScGuest::trousersColour_set, "trousersColour");
dukglue_register_property(ctx, &ScGuest::balloonColour_get, &ScGuest::balloonColour_set, "balloonColour");
dukglue_register_property(ctx, &ScGuest::hatColour_get, &ScGuest::hatColour_set, "hatColour");
dukglue_register_property(ctx, &ScGuest::umbrellaColour_get, &ScGuest::umbrellaColour_set, "umbrellaColour");
dukglue_register_property(ctx, &ScGuest::happiness_get, &ScGuest::happiness_set, "happiness");
dukglue_register_property(ctx, &ScGuest::happinessTarget_get, &ScGuest::happinessTarget_set, "happinessTarget");
dukglue_register_property(ctx, &ScGuest::nausea_get, &ScGuest::nausea_set, "nausea");
dukglue_register_property(ctx, &ScGuest::nauseaTarget_get, &ScGuest::nauseaTarget_set, "nauseaTarget");
dukglue_register_property(ctx, &ScGuest::hunger_get, &ScGuest::hunger_set, "hunger");
dukglue_register_property(ctx, &ScGuest::thirst_get, &ScGuest::thirst_set, "thirst");
dukglue_register_property(ctx, &ScGuest::toilet_get, &ScGuest::toilet_set, "toilet");
dukglue_register_property(ctx, &ScGuest::mass_get, &ScGuest::mass_set, "mass");
dukglue_register_property(ctx, &ScGuest::minIntensity_get, &ScGuest::minIntensity_set, "minIntensity");
dukglue_register_property(ctx, &ScGuest::maxIntensity_get, &ScGuest::maxIntensity_set, "maxIntensity");
dukglue_register_property(ctx, &ScGuest::nauseaTolerance_get, &ScGuest::nauseaTolerance_set, "nauseaTolerance");
dukglue_register_property(ctx, &ScGuest::cash_get, &ScGuest::cash_set, "cash");
dukglue_register_property(ctx, &ScGuest::isInPark_get, nullptr, "isInPark");
dukglue_register_property(ctx, &ScGuest::isLost_get, nullptr, "isLost");
dukglue_register_property(ctx, &ScGuest::lostCountdown_get, &ScGuest::lostCountdown_set, "lostCountdown");
}
private:
Guest* GetGuest() const
{
return ::GetEntity<Guest>(_id);
}
uint8_t tshirtColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->TshirtColour : 0;
}
void tshirtColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->TshirtColour = value;
peep->Invalidate();
}
}
uint8_t trousersColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->TrousersColour : 0;
}
void trousersColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->TrousersColour = value;
peep->Invalidate();
}
}
uint8_t balloonColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->BalloonColour : 0;
}
void balloonColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->BalloonColour = value;
peep->Invalidate();
}
}
uint8_t hatColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->HatColour : 0;
}
void hatColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->HatColour = value;
peep->Invalidate();
}
}
uint8_t umbrellaColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->UmbrellaColour : 0;
}
void umbrellaColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->UmbrellaColour = value;
peep->Invalidate();
}
}
uint8_t happiness_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Happiness : 0;
}
void happiness_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Happiness = value;
}
}
uint8_t happinessTarget_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->HappinessTarget : 0;
}
void happinessTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->HappinessTarget = value;
}
}
uint8_t nausea_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Nausea : 0;
}
void nausea_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Nausea = value;
}
}
uint8_t nauseaTarget_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->NauseaTarget : 0;
}
void nauseaTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->NauseaTarget = value;
}
}
uint8_t hunger_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Hunger : 0;
}
void hunger_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Hunger = value;
}
}
uint8_t thirst_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Thirst : 0;
}
void thirst_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Thirst = value;
}
}
uint8_t toilet_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Toilet : 0;
}
void toilet_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Toilet = value;
}
}
uint8_t mass_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Mass : 0;
}
void mass_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Mass = value;
}
}
uint8_t minIntensity_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Intensity.GetMinimum() : 0;
}
void minIntensity_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Intensity = peep->Intensity.WithMinimum(value);
}
}
uint8_t maxIntensity_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Intensity.GetMaximum() : 0;
}
void maxIntensity_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Intensity = peep->Intensity.WithMaximum(value);
}
}
uint8_t nauseaTolerance_get() const
{
auto peep = GetGuest();
return peep != nullptr ? EnumValue(peep->NauseaTolerance) : 0;
}
void nauseaTolerance_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->NauseaTolerance = static_cast<PeepNauseaTolerance>(std::min<uint8_t>(value, 3));
}
}
int32_t cash_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->CashInPocket : 0;
}
void cash_set(int32_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->CashInPocket = std::max(0, value);
}
}
bool isInPark_get() const
{
auto peep = GetGuest();
return (peep != nullptr && !peep->OutsideOfPark);
}
bool isLost_get() const
{
auto peep = GetGuest();
return (peep != nullptr && peep->GuestIsLostCountdown < 90);
}
uint8_t lostCountdown_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->GuestIsLostCountdown : 0;
}
void lostCountdown_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->GuestIsLostCountdown = value;
}
}
};
class ScStaff : public ScPeep
{
public:
ScStaff(uint16_t Id)
: ScPeep(Id)
{
}
static void Register(duk_context* ctx)
{
dukglue_set_base_class<ScPeep, ScStaff>(ctx);
dukglue_register_property(ctx, &ScStaff::staffType_get, &ScStaff::staffType_set, "staffType");
dukglue_register_property(ctx, &ScStaff::colour_get, &ScStaff::colour_set, "colour");
dukglue_register_property(ctx, &ScStaff::costume_get, &ScStaff::costume_set, "costume");
dukglue_register_property(ctx, &ScStaff::orders_get, &ScStaff::orders_set, "orders");
}
private:
Staff* GetStaff() const
{
return ::GetEntity<Staff>(_id);
}
std::string staffType_get() const
{
auto peep = GetStaff();
if (peep != nullptr)
{
switch (peep->AssignedStaffType)
{
case StaffType::Handyman:
return "handyman";
case StaffType::Mechanic:
return "mechanic";
case StaffType::Security:
return "security";
case StaffType::Entertainer:
return "entertainer";
case StaffType::Count:
break;
}
}
return "";
}
void staffType_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
if (value == "handyman" && peep->AssignedStaffType != StaffType::Handyman)
{
peep->AssignedStaffType = StaffType::Handyman;
peep->SpriteType = PeepSpriteType::Handyman;
}
else if (value == "mechanic" && peep->AssignedStaffType != StaffType::Mechanic)
{
peep->AssignedStaffType = StaffType::Mechanic;
peep->SpriteType = PeepSpriteType::Mechanic;
}
else if (value == "security" && peep->AssignedStaffType != StaffType::Security)
{
peep->AssignedStaffType = StaffType::Security;
peep->SpriteType = PeepSpriteType::Security;
}
else if (value == "entertainer" && peep->AssignedStaffType != StaffType::Entertainer)
{
peep->AssignedStaffType = StaffType::Entertainer;
peep->SpriteType = PeepSpriteType::EntertainerPanda;
}
}
}
uint8_t colour_get() const
{
auto peep = GetStaff();
return peep != nullptr ? peep->TshirtColour : 0;
}
void colour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->TshirtColour = value;
peep->TrousersColour = value;
}
}
uint8_t costume_get() const
{
auto peep = GetStaff();
if (peep != nullptr && peep->AssignedStaffType == StaffType::Entertainer)
{
return peep->GetCostume();
}
return 0;
}
void costume_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->SetCostume(value);
}
}
uint8_t orders_get() const
{
auto peep = GetStaff();
return peep != nullptr ? peep->StaffOrders : 0;
}
void orders_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->StaffOrders = value;
}
}
};
static const DukEnumMap<Litter::Type> LitterTypeMap({
{ "vomit", Litter::Type::Vomit },
{ "vomit_alt", Litter::Type::VomitAlt },

View File

@ -0,0 +1,342 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#ifdef ENABLE_SCRIPTING
# include "ScGuest.hpp"
namespace OpenRCT2::Scripting
{
ScGuest::ScGuest(uint16_t id)
: ScPeep(id)
{
}
void ScGuest::Register(duk_context* ctx)
{
dukglue_set_base_class<ScPeep, ScGuest>(ctx);
dukglue_register_property(ctx, &ScGuest::tshirtColour_get, &ScGuest::tshirtColour_set, "tshirtColour");
dukglue_register_property(ctx, &ScGuest::trousersColour_get, &ScGuest::trousersColour_set, "trousersColour");
dukglue_register_property(ctx, &ScGuest::balloonColour_get, &ScGuest::balloonColour_set, "balloonColour");
dukglue_register_property(ctx, &ScGuest::hatColour_get, &ScGuest::hatColour_set, "hatColour");
dukglue_register_property(ctx, &ScGuest::umbrellaColour_get, &ScGuest::umbrellaColour_set, "umbrellaColour");
dukglue_register_property(ctx, &ScGuest::happiness_get, &ScGuest::happiness_set, "happiness");
dukglue_register_property(ctx, &ScGuest::happinessTarget_get, &ScGuest::happinessTarget_set, "happinessTarget");
dukglue_register_property(ctx, &ScGuest::nausea_get, &ScGuest::nausea_set, "nausea");
dukglue_register_property(ctx, &ScGuest::nauseaTarget_get, &ScGuest::nauseaTarget_set, "nauseaTarget");
dukglue_register_property(ctx, &ScGuest::hunger_get, &ScGuest::hunger_set, "hunger");
dukglue_register_property(ctx, &ScGuest::thirst_get, &ScGuest::thirst_set, "thirst");
dukglue_register_property(ctx, &ScGuest::toilet_get, &ScGuest::toilet_set, "toilet");
dukglue_register_property(ctx, &ScGuest::mass_get, &ScGuest::mass_set, "mass");
dukglue_register_property(ctx, &ScGuest::minIntensity_get, &ScGuest::minIntensity_set, "minIntensity");
dukglue_register_property(ctx, &ScGuest::maxIntensity_get, &ScGuest::maxIntensity_set, "maxIntensity");
dukglue_register_property(ctx, &ScGuest::nauseaTolerance_get, &ScGuest::nauseaTolerance_set, "nauseaTolerance");
dukglue_register_property(ctx, &ScGuest::cash_get, &ScGuest::cash_set, "cash");
dukglue_register_property(ctx, &ScGuest::isInPark_get, nullptr, "isInPark");
dukglue_register_property(ctx, &ScGuest::isLost_get, nullptr, "isLost");
dukglue_register_property(ctx, &ScGuest::lostCountdown_get, &ScGuest::lostCountdown_set, "lostCountdown");
}
Guest* ScGuest::GetGuest() const
{
return ::GetEntity<Guest>(_id);
}
uint8_t ScGuest::tshirtColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->TshirtColour : 0;
}
void ScGuest::tshirtColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->TshirtColour = value;
peep->Invalidate();
}
}
uint8_t ScGuest::trousersColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->TrousersColour : 0;
}
void ScGuest::trousersColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->TrousersColour = value;
peep->Invalidate();
}
}
uint8_t ScGuest::balloonColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->BalloonColour : 0;
}
void ScGuest::balloonColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->BalloonColour = value;
peep->Invalidate();
}
}
uint8_t ScGuest::hatColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->HatColour : 0;
}
void ScGuest::hatColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->HatColour = value;
peep->Invalidate();
}
}
uint8_t ScGuest::umbrellaColour_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->UmbrellaColour : 0;
}
void ScGuest::umbrellaColour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->UmbrellaColour = value;
peep->Invalidate();
}
}
uint8_t ScGuest::happiness_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Happiness : 0;
}
void ScGuest::happiness_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Happiness = value;
}
}
uint8_t ScGuest::happinessTarget_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->HappinessTarget : 0;
}
void ScGuest::happinessTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->HappinessTarget = value;
}
}
uint8_t ScGuest::nausea_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Nausea : 0;
}
void ScGuest::nausea_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Nausea = value;
}
}
uint8_t ScGuest::nauseaTarget_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->NauseaTarget : 0;
}
void ScGuest::nauseaTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->NauseaTarget = value;
}
}
uint8_t ScGuest::hunger_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Hunger : 0;
}
void ScGuest::hunger_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Hunger = value;
}
}
uint8_t ScGuest::thirst_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Thirst : 0;
}
void ScGuest::thirst_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Thirst = value;
}
}
uint8_t ScGuest::toilet_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Toilet : 0;
}
void ScGuest::toilet_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Toilet = value;
}
}
uint8_t ScGuest::mass_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Mass : 0;
}
void ScGuest::mass_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Mass = value;
}
}
uint8_t ScGuest::minIntensity_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Intensity.GetMinimum() : 0;
}
void ScGuest::minIntensity_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Intensity = peep->Intensity.WithMinimum(value);
}
}
uint8_t ScGuest::maxIntensity_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->Intensity.GetMaximum() : 0;
}
void ScGuest::maxIntensity_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->Intensity = peep->Intensity.WithMaximum(value);
}
}
uint8_t ScGuest::nauseaTolerance_get() const
{
auto peep = GetGuest();
return peep != nullptr ? EnumValue(peep->NauseaTolerance) : 0;
}
void ScGuest::nauseaTolerance_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->NauseaTolerance = static_cast<PeepNauseaTolerance>(std::min<uint8_t>(value, 3));
}
}
int32_t ScGuest::cash_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->CashInPocket : 0;
}
void ScGuest::cash_set(int32_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->CashInPocket = std::max(0, value);
}
}
bool ScGuest::isInPark_get() const
{
auto peep = GetGuest();
return (peep != nullptr && !peep->OutsideOfPark);
}
bool ScGuest::isLost_get() const
{
auto peep = GetGuest();
return (peep != nullptr && peep->GuestIsLostCountdown < 90);
}
uint8_t ScGuest::lostCountdown_get() const
{
auto peep = GetGuest();
return peep != nullptr ? peep->GuestIsLostCountdown : 0;
}
void ScGuest::lostCountdown_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetGuest();
if (peep != nullptr)
{
peep->GuestIsLostCountdown = value;
}
}
} // namespace OpenRCT2::Scripting
#endif

View File

@ -0,0 +1,89 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#ifdef ENABLE_SCRIPTING
# include "ScPeep.hpp"
namespace OpenRCT2::Scripting
{
class ScGuest : public ScPeep
{
public:
ScGuest(uint16_t id);
static void Register(duk_context* ctx);
private:
Guest* GetGuest() const;
uint8_t tshirtColour_get() const;
void tshirtColour_set(uint8_t value);
uint8_t trousersColour_get() const;
void trousersColour_set(uint8_t value);
uint8_t balloonColour_get() const;
void balloonColour_set(uint8_t value);
uint8_t hatColour_get() const;
void hatColour_set(uint8_t value);
uint8_t umbrellaColour_get() const;
void umbrellaColour_set(uint8_t value);
uint8_t happiness_get() const;
void happiness_set(uint8_t value);
uint8_t happinessTarget_get() const;
void happinessTarget_set(uint8_t value);
uint8_t nausea_get() const;
void nausea_set(uint8_t value);
uint8_t nauseaTarget_get() const;
void nauseaTarget_set(uint8_t value);
uint8_t hunger_get() const;
void hunger_set(uint8_t value);
uint8_t thirst_get() const;
void thirst_set(uint8_t value);
uint8_t toilet_get() const;
void toilet_set(uint8_t value);
uint8_t mass_get() const;
void mass_set(uint8_t value);
uint8_t minIntensity_get() const;
void minIntensity_set(uint8_t value);
uint8_t maxIntensity_get() const;
void maxIntensity_set(uint8_t value);
uint8_t nauseaTolerance_get() const;
void nauseaTolerance_set(uint8_t value);
int32_t cash_get() const;
void cash_set(int32_t value);
bool isInPark_get() const;
bool isLost_get() const;
uint8_t lostCountdown_get() const;
void lostCountdown_set(uint8_t value);
};
} // namespace OpenRCT2::Scripting
#endif

View File

@ -0,0 +1,180 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#ifdef ENABLE_SCRIPTING
# include "ScEntity.hpp"
namespace OpenRCT2::Scripting
{
static const DukEnumMap<uint32_t> PeepFlagMap({
{ "leavingPark", PEEP_FLAGS_LEAVING_PARK },
{ "slowWalk", PEEP_FLAGS_SLOW_WALK },
{ "tracking", PEEP_FLAGS_TRACKING },
{ "waving", PEEP_FLAGS_WAVING },
{ "hasPaidForParkEntry", PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY },
{ "photo", PEEP_FLAGS_PHOTO },
{ "painting", PEEP_FLAGS_PAINTING },
{ "wow", PEEP_FLAGS_WOW },
{ "litter", PEEP_FLAGS_LITTER },
{ "lost", PEEP_FLAGS_LOST },
{ "hunger", PEEP_FLAGS_HUNGER },
{ "toilet", PEEP_FLAGS_TOILET },
{ "crowded", PEEP_FLAGS_CROWDED },
{ "happiness", PEEP_FLAGS_HAPPINESS },
{ "nausea", PEEP_FLAGS_NAUSEA },
{ "purple", PEEP_FLAGS_PURPLE },
{ "pizza", PEEP_FLAGS_PIZZA },
{ "explode", PEEP_FLAGS_EXPLODE },
{ "rideShouldBeMarkedAsFavourite", PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE },
{ "parkEntranceChosen", PEEP_FLAGS_PARK_ENTRANCE_CHOSEN },
{ "contagious", PEEP_FLAGS_CONTAGIOUS },
{ "joy", PEEP_FLAGS_JOY },
{ "angry", PEEP_FLAGS_ANGRY },
{ "iceCream", PEEP_FLAGS_ICE_CREAM },
{ "hereWeAre", PEEP_FLAGS_HERE_WE_ARE },
});
class ScPeep : public ScEntity
{
public:
ScPeep(uint16_t id)
: ScEntity(id)
{
}
static void Register(duk_context* ctx)
{
dukglue_set_base_class<ScEntity, ScPeep>(ctx);
dukglue_register_property(ctx, &ScPeep::peepType_get, nullptr, "peepType");
dukglue_register_property(ctx, &ScPeep::name_get, &ScPeep::name_set, "name");
dukglue_register_property(ctx, &ScPeep::destination_get, &ScPeep::destination_set, "destination");
dukglue_register_property(ctx, &ScPeep::energy_get, &ScPeep::energy_set, "energy");
dukglue_register_property(ctx, &ScPeep::energyTarget_get, &ScPeep::energyTarget_set, "energyTarget");
dukglue_register_method(ctx, &ScPeep::getFlag, "getFlag");
dukglue_register_method(ctx, &ScPeep::setFlag, "setFlag");
}
private:
std::string peepType_get() const
{
auto peep = GetPeep();
if (peep != nullptr)
{
return peep->Is<Staff>() ? "staff" : "guest";
}
return "";
}
std::string name_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->GetName() : std::string();
}
void name_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->SetName(value);
}
}
bool getFlag(const std::string& key) const
{
auto peep = GetPeep();
if (peep != nullptr)
{
auto mask = PeepFlagMap[key];
return (peep->PeepFlags & mask) != 0;
}
return false;
}
void setFlag(const std::string& key, bool value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
auto mask = PeepFlagMap[key];
if (value)
peep->PeepFlags |= mask;
else
peep->PeepFlags &= ~mask;
peep->Invalidate();
}
}
DukValue destination_get() const
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
auto peep = GetPeep();
if (peep != nullptr)
{
return ToDuk(ctx, peep->GetDestination());
}
return ToDuk(ctx, nullptr);
}
void destination_set(const DukValue& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
auto pos = FromDuk<CoordsXY>(value);
peep->SetDestination(pos);
peep->Invalidate();
}
}
uint8_t energy_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->Energy : 0;
}
void energy_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->Energy = value;
}
}
uint8_t energyTarget_get() const
{
auto peep = GetPeep();
return peep != nullptr ? peep->EnergyTarget : 0;
}
void energyTarget_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetPeep();
if (peep != nullptr)
{
peep->EnergyTarget = value;
}
}
protected:
Peep* GetPeep() const
{
return ::GetEntity<Peep>(_id);
}
};
} // namespace OpenRCT2::Scripting
#endif

View File

@ -0,0 +1,141 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#ifdef ENABLE_SCRIPTING
# include "ScStaff.hpp"
namespace OpenRCT2::Scripting
{
ScStaff::ScStaff(uint16_t Id)
: ScPeep(Id)
{
}
void ScStaff::Register(duk_context* ctx)
{
dukglue_set_base_class<ScPeep, ScStaff>(ctx);
dukglue_register_property(ctx, &ScStaff::staffType_get, &ScStaff::staffType_set, "staffType");
dukglue_register_property(ctx, &ScStaff::colour_get, &ScStaff::colour_set, "colour");
dukglue_register_property(ctx, &ScStaff::costume_get, &ScStaff::costume_set, "costume");
dukglue_register_property(ctx, &ScStaff::orders_get, &ScStaff::orders_set, "orders");
}
Staff* ScStaff::GetStaff() const
{
return ::GetEntity<Staff>(_id);
}
std::string ScStaff::staffType_get() const
{
auto peep = GetStaff();
if (peep != nullptr)
{
switch (peep->AssignedStaffType)
{
case StaffType::Handyman:
return "handyman";
case StaffType::Mechanic:
return "mechanic";
case StaffType::Security:
return "security";
case StaffType::Entertainer:
return "entertainer";
case StaffType::Count:
break;
}
}
return "";
}
void ScStaff::staffType_set(const std::string& value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
if (value == "handyman" && peep->AssignedStaffType != StaffType::Handyman)
{
peep->AssignedStaffType = StaffType::Handyman;
peep->SpriteType = PeepSpriteType::Handyman;
}
else if (value == "mechanic" && peep->AssignedStaffType != StaffType::Mechanic)
{
peep->AssignedStaffType = StaffType::Mechanic;
peep->SpriteType = PeepSpriteType::Mechanic;
}
else if (value == "security" && peep->AssignedStaffType != StaffType::Security)
{
peep->AssignedStaffType = StaffType::Security;
peep->SpriteType = PeepSpriteType::Security;
}
else if (value == "entertainer" && peep->AssignedStaffType != StaffType::Entertainer)
{
peep->AssignedStaffType = StaffType::Entertainer;
peep->SpriteType = PeepSpriteType::EntertainerPanda;
}
}
}
uint8_t ScStaff::colour_get() const
{
auto peep = GetStaff();
return peep != nullptr ? peep->TshirtColour : 0;
}
void ScStaff::colour_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->TshirtColour = value;
peep->TrousersColour = value;
}
}
uint8_t ScStaff::costume_get() const
{
auto peep = GetStaff();
if (peep != nullptr && peep->AssignedStaffType == StaffType::Entertainer)
{
return peep->GetCostume();
}
return 0;
}
void ScStaff::costume_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->SetCostume(value);
}
}
uint8_t ScStaff::orders_get() const
{
auto peep = GetStaff();
return peep != nullptr ? peep->StaffOrders : 0;
}
void ScStaff::orders_set(uint8_t value)
{
ThrowIfGameStateNotMutable();
auto peep = GetStaff();
if (peep != nullptr)
{
peep->StaffOrders = value;
}
}
} // namespace OpenRCT2::Scripting
#endif

View File

@ -0,0 +1,43 @@
/*****************************************************************************
* Copyright (c) 2014-2021 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#ifdef ENABLE_SCRIPTING
# include "ScPeep.hpp"
namespace OpenRCT2::Scripting
{
class ScStaff : public ScPeep
{
public:
ScStaff(uint16_t Id);
static void Register(duk_context* ctx);
private:
Staff* GetStaff() const;
std::string staffType_get() const;
void staffType_set(const std::string& value);
uint8_t colour_get() const;
void colour_set(uint8_t value);
uint8_t costume_get() const;
void costume_set(uint8_t value);
uint8_t orders_get() const;
void orders_set(uint8_t value);
};
} // namespace OpenRCT2::Scripting
#endif