1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-28 17:24:47 +01:00

Expose getCostumeStrings to scripts

This commit is contained in:
Aaron van Geffen
2024-12-11 19:06:47 +01:00
parent 11f683101c
commit 2f0af0a005
4 changed files with 36 additions and 12 deletions

View File

@@ -38,6 +38,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScStaff::animationOffset_get, &ScStaff::animationOffset_set, "animationOffset");
dukglue_register_property(ctx, &ScStaff::animationLength_get, nullptr, "animationLength");
dukglue_register_method(ctx, &ScStaff::getAnimationSpriteIds, "getAnimationSpriteIds");
dukglue_register_method(ctx, &ScStaff::getCostumeStrings, "getCostumeStrings");
}
Staff* ScStaff::GetStaff() const
@@ -124,18 +125,8 @@ namespace OpenRCT2::Scripting
static const std::vector<AnimationGroupResult> costumesByStaffType(StaffType staffType)
{
// TODO: shouldn't get hit repeatedly, but cache these if (and only if) it's too slow
switch (staffType)
{
case StaffType::Handyman:
return getAnimationGroupsByPeepType(AnimationPeepType::Handyman);
case StaffType::Mechanic:
return getAnimationGroupsByPeepType(AnimationPeepType::Mechanic);
case StaffType::Security:
return getAnimationGroupsByPeepType(AnimationPeepType::Security);
case StaffType::Entertainer:
default:
return getAnimationGroupsByPeepType(AnimationPeepType::Entertainer);
}
auto animPeepType = getAnimationPeepType(staffType);
return getAnimationGroupsByPeepType(animPeepType);
}
std::vector<std::string> ScStaff::availableCostumes_get() const
@@ -152,6 +143,19 @@ namespace OpenRCT2::Scripting
return availableCostumes;
}
std::vector<std::string> ScStaff::getCostumeStrings() const
{
auto peep = GetStaff();
auto animPeepType = getAnimationPeepType(peep->AssignedStaffType);
std::vector<std::string> availableCostumes{};
for (auto& costume : getAvailableCostumeStrings(animPeepType))
{
availableCostumes.push_back(costume.friendlyName);
}
return availableCostumes;
}
std::string ScStaff::costume_get() const
{
auto peep = GetStaff();

View File

@@ -60,6 +60,7 @@ namespace OpenRCT2::Scripting
void colour_set(uint8_t value);
std::vector<std::string> availableCostumes_get() const;
std::vector<std::string> getCostumeStrings() const;
std::string costume_get() const;
void costume_set(const DukValue& value);