1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +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

@@ -12,6 +12,7 @@
#include "../Context.h"
#include "../drawing/Drawing.h"
#include "../entity/Peep.h"
#include "../entity/Staff.h"
#include "../object/ObjectLimits.h"
#include "../object/ObjectManager.h"
#include "../object/PeepAnimationsObject.h"
@@ -110,6 +111,22 @@ namespace OpenRCT2
}
}
AnimationPeepType getAnimationPeepType(StaffType staffType)
{
switch (staffType)
{
case StaffType::Handyman:
return AnimationPeepType::Handyman;
case StaffType::Mechanic:
return AnimationPeepType::Mechanic;
case StaffType::Security:
return AnimationPeepType::Security;
case StaffType::Entertainer:
default:
return AnimationPeepType::Entertainer;
}
}
ObjectEntryIndex findPeepAnimationsIndexForType(const AnimationPeepType type)
{
auto& objManager = GetContext()->GetObjectManager();

View File

@@ -19,6 +19,7 @@
class PeepAnimationsObject;
enum class RCT12PeepAnimationGroup : uint8_t;
enum class StaffType : uint8_t;
namespace OpenRCT2
{
@@ -32,6 +33,7 @@ namespace OpenRCT2
};
const EnumMap<PeepAnimationType>& getAnimationsByPeepType(AnimationPeepType peepType);
AnimationPeepType getAnimationPeepType(StaffType staffType);
struct SpriteBounds
{

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);