mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Separate RCT12PeepAnimationGroup further from PeepAnimationGroup
This commit is contained in:
@@ -360,10 +360,6 @@ PeepAnimationType Peep::GetAnimationType()
|
||||
*/
|
||||
void Peep::UpdateCurrentAnimationType()
|
||||
{
|
||||
if (EnumValue(AnimationGroup) >= EnumValue(PeepAnimationGroup::Count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PeepAnimationType newAnimationType = GetAnimationType();
|
||||
if (AnimationType == newAnimationType)
|
||||
{
|
||||
|
||||
@@ -234,60 +234,43 @@ enum PeepNextFlags
|
||||
enum class PeepAnimationGroup : uint8_t
|
||||
{
|
||||
Normal = 0,
|
||||
Handyman = 0, // 1,
|
||||
Mechanic = 0, // 2,
|
||||
|
||||
Security = 0, // 3,
|
||||
SecurityAlt = 1, // 23,
|
||||
// Security staff
|
||||
Alternate = 1,
|
||||
|
||||
EntertainerPanda = 0, // 4,
|
||||
EntertainerTiger = 0, // 5,
|
||||
EntertainerElephant = 0, // 6,
|
||||
EntertainerRoman = 0, // 7,
|
||||
EntertainerGorilla = 0, // 8,
|
||||
EntertainerSnowman = 0, // 9,
|
||||
EntertainerKnight = 0, // 10,
|
||||
EntertainerAstronaut = 0, // 11,
|
||||
EntertainerBandit = 0, // 12,
|
||||
EntertainerSheriff = 0, // 13,
|
||||
EntertainerPirate = 0, // 14,
|
||||
|
||||
// Guest variations (compensate for Staff/Entertainer slots)
|
||||
IceCream = 15 - 14,
|
||||
Chips = 16 - 14,
|
||||
Burger = 17 - 14,
|
||||
Drink = 18 - 14,
|
||||
Balloon = 19 - 14,
|
||||
Candyfloss = 20 - 14,
|
||||
Umbrella = 21 - 14,
|
||||
Pizza = 22 - 14,
|
||||
|
||||
// Guest variations (compensate for SecurityAlt as well)
|
||||
Popcorn = 24 - 15,
|
||||
ArmsCrossed = 25 - 15,
|
||||
HeadDown = 26 - 15,
|
||||
Nauseous = 27 - 15,
|
||||
VeryNauseous = 28 - 15,
|
||||
RequireToilet = 29 - 15,
|
||||
Hat = 30 - 15,
|
||||
HotDog = 31 - 15,
|
||||
Tentacle = 32 - 15,
|
||||
ToffeeApple = 33 - 15,
|
||||
Doughnut = 34 - 15,
|
||||
Coffee = 35 - 15,
|
||||
Chicken = 36 - 15,
|
||||
Lemonade = 37 - 15,
|
||||
Watching = 38 - 15,
|
||||
Pretzel = 39 - 15,
|
||||
Sunglasses = 40 - 15,
|
||||
SuJongkwa = 41 - 15,
|
||||
Juice = 42 - 15,
|
||||
FunnelCake = 43 - 15,
|
||||
Noodles = 44 - 15,
|
||||
Sausage = 45 - 15,
|
||||
Soup = 46 - 15,
|
||||
Sandwich = 47 - 15,
|
||||
Count = 48 - 15,
|
||||
// Guest variations
|
||||
IceCream = 1,
|
||||
Chips = 2,
|
||||
Burger = 3,
|
||||
Drink = 4,
|
||||
Balloon = 5,
|
||||
Candyfloss = 6,
|
||||
Umbrella = 7,
|
||||
Pizza = 8,
|
||||
Popcorn = 9,
|
||||
ArmsCrossed = 10,
|
||||
HeadDown = 11,
|
||||
Nauseous = 12,
|
||||
VeryNauseous = 13,
|
||||
RequireToilet = 14,
|
||||
Hat = 15,
|
||||
HotDog = 16,
|
||||
Tentacle = 17,
|
||||
ToffeeApple = 18,
|
||||
Doughnut = 19,
|
||||
Coffee = 20,
|
||||
Chicken = 21,
|
||||
Lemonade = 22,
|
||||
Watching = 23,
|
||||
Pretzel = 24,
|
||||
Sunglasses = 25,
|
||||
SuJongkwa = 26,
|
||||
Juice = 27,
|
||||
FunnelCake = 28,
|
||||
Noodles = 29,
|
||||
Sausage = 30,
|
||||
Soup = 31,
|
||||
Sandwich = 32,
|
||||
|
||||
Invalid = 255
|
||||
};
|
||||
|
||||
@@ -1637,9 +1637,9 @@ void Staff::Tick128UpdateStaff()
|
||||
if (AssignedStaffType != StaffType::Security)
|
||||
return;
|
||||
|
||||
PeepAnimationGroup newAnimationGroup = PeepAnimationGroup::SecurityAlt;
|
||||
PeepAnimationGroup newAnimationGroup = PeepAnimationGroup::Alternate;
|
||||
if (State != PeepState::Patrolling)
|
||||
newAnimationGroup = PeepAnimationGroup::Security;
|
||||
newAnimationGroup = PeepAnimationGroup::Normal;
|
||||
|
||||
if (AnimationGroup == newAnimationGroup)
|
||||
return;
|
||||
|
||||
@@ -117,9 +117,13 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root)
|
||||
auto position = Json::GetNumber<uint8_t>(groupJson["legacyPosition"]);
|
||||
if (position <= EnumValue(RCT12PeepAnimationGroup::Count))
|
||||
{
|
||||
group.legacyPosition = static_cast<PeepAnimationGroup>(position);
|
||||
group.legacyPosition = static_cast<RCT12PeepAnimationGroup>(position);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
group.legacyPosition = RCT12PeepAnimationGroup::Invalid;
|
||||
}
|
||||
|
||||
// Do we have a preferred way of addressing this object in scripts?
|
||||
if (groupJson.contains("scriptName"))
|
||||
@@ -166,7 +170,7 @@ size_t PeepAnimationsObject::GetNumAnimationGroups() const
|
||||
return _animationGroups.size();
|
||||
}
|
||||
|
||||
PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup animGroup) const
|
||||
RCT12PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup animGroup) const
|
||||
{
|
||||
return _animationGroups[EnumValue(animGroup)].legacyPosition;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
enum class RCT12PeepAnimationGroup : uint8_t;
|
||||
|
||||
class PeepAnimationsObject final : public Object
|
||||
{
|
||||
private:
|
||||
@@ -41,7 +43,7 @@ public:
|
||||
|
||||
OpenRCT2::AnimationPeepType GetPeepType() const;
|
||||
size_t GetNumAnimationGroups() const;
|
||||
PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const;
|
||||
RCT12PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const;
|
||||
std::string_view GetScriptName(PeepAnimationGroup animGroup) const;
|
||||
|
||||
bool IsSlowWalking()
|
||||
|
||||
@@ -2297,8 +2297,7 @@ const std::vector<std::string_view>& GetLegacyPeepAnimationObjects(const ObjectL
|
||||
return peepAnimObjects;
|
||||
}
|
||||
|
||||
// TODO: change type to legacy PeepAnimationGroup and new PeepAnimationGroup
|
||||
using AnimObjectConversionTable = std::map<PeepAnimationGroup, std::pair<ObjectEntryIndex, uint8_t>>;
|
||||
using AnimObjectConversionTable = std::map<RCT12PeepAnimationGroup, std::pair<ObjectEntryIndex, PeepAnimationGroup>>;
|
||||
|
||||
static AnimObjectConversionTable BuildPeepAnimObjectConversionTable()
|
||||
{
|
||||
@@ -2313,11 +2312,12 @@ static AnimObjectConversionTable BuildPeepAnimObjectConversionTable()
|
||||
|
||||
for (auto j = 0u; j < object->GetNumAnimationGroups(); j++)
|
||||
{
|
||||
auto legacyPosition = object->GetLegacyPosition(PeepAnimationGroup(j));
|
||||
if (legacyPosition == PeepAnimationGroup::Invalid)
|
||||
auto pag = PeepAnimationGroup(j);
|
||||
auto legacyPosition = object->GetLegacyPosition(pag);
|
||||
if (legacyPosition == RCT12PeepAnimationGroup::Invalid)
|
||||
continue;
|
||||
|
||||
table[legacyPosition] = { i, j };
|
||||
table[legacyPosition] = { i, pag };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2331,7 +2331,8 @@ static bool ConvertPeepAnimationType(TPeepType* peep, AnimObjectConversionTable&
|
||||
return false;
|
||||
|
||||
// TODO: catch missings
|
||||
auto conversion = table[peep->AnimationGroup];
|
||||
auto legacyPAG = RCT12PeepAnimationGroup(peep->AnimationGroup);
|
||||
auto& conversion = table[legacyPAG];
|
||||
peep->AnimationObjectIndex = conversion.first;
|
||||
peep->AnimationGroup = static_cast<PeepAnimationGroup>(conversion.second);
|
||||
return true;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
class PeepAnimationsObject;
|
||||
enum class RCT12PeepAnimationGroup : uint8_t;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
@@ -50,8 +51,7 @@ namespace OpenRCT2
|
||||
struct PeepAnimations
|
||||
{
|
||||
public:
|
||||
// TODO: move type to RCT12?
|
||||
PeepAnimationGroup legacyPosition = PeepAnimationGroup::Invalid;
|
||||
RCT12PeepAnimationGroup legacyPosition;
|
||||
std::string scriptName{};
|
||||
|
||||
constexpr PeepAnimation& operator[](PeepAnimationType n)
|
||||
@@ -79,7 +79,7 @@ namespace OpenRCT2
|
||||
{
|
||||
ObjectEntryIndex objectId;
|
||||
PeepAnimationGroup group;
|
||||
PeepAnimationGroup legacyPosition;
|
||||
RCT12PeepAnimationGroup legacyPosition;
|
||||
std::string_view scriptName;
|
||||
};
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace OpenRCT2::Scripting
|
||||
else if (value.type() == DukValue::Type::NUMBER)
|
||||
{
|
||||
// Find the peep's current costume by legacy number
|
||||
auto target = PeepAnimationGroup(value.as_uint() + EnumValue(PeepAnimationGroup::EntertainerPanda));
|
||||
auto target = RCT12PeepAnimationGroup(value.as_uint() + EnumValue(RCT12PeepAnimationGroup::EntertainerPanda));
|
||||
costume = std::find_if(
|
||||
costumes.begin(), costumes.end(), [target](auto& candidate) { return candidate.legacyPosition == target; });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user