mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor g_peep_animation_entries into kPeepAnimationEntries
This commit is contained in:
parent
b52bf40a20
commit
642162853f
|
@ -26,6 +26,7 @@
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Finance.h>
|
#include <openrct2/management/Finance.h>
|
||||||
#include <openrct2/management/NewsItem.h>
|
#include <openrct2/management/NewsItem.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/sprites.h>
|
#include <openrct2/sprites.h>
|
||||||
#include <openrct2/world/Park.h>
|
#include <openrct2/world/Park.h>
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Marketing.h>
|
#include <openrct2/management/Marketing.h>
|
||||||
#include <openrct2/network/network.h>
|
#include <openrct2/network/network.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/ride/RideData.h>
|
#include <openrct2/ride/RideData.h>
|
||||||
#include <openrct2/ride/ShopItem.h>
|
#include <openrct2/ride/ShopItem.h>
|
||||||
#include <openrct2/scenario/Scenario.h>
|
#include <openrct2/scenario/Scenario.h>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <openrct2/localisation/Formatter.h>
|
#include <openrct2/localisation/Formatter.h>
|
||||||
#include <openrct2/localisation/Formatting.h>
|
#include <openrct2/localisation/Formatting.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/ride/RideData.h>
|
#include <openrct2/ride/RideData.h>
|
||||||
#include <openrct2/scenario/Scenario.h>
|
#include <openrct2/scenario/Scenario.h>
|
||||||
#include <openrct2/sprites.h>
|
#include <openrct2/sprites.h>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <openrct2/localisation/Formatter.h>
|
#include <openrct2/localisation/Formatter.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/NewsItem.h>
|
#include <openrct2/management/NewsItem.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/sprites.h>
|
#include <openrct2/sprites.h>
|
||||||
|
|
||||||
namespace OpenRCT2::Ui::Windows
|
namespace OpenRCT2::Ui::Windows
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <openrct2/localisation/Formatter.h>
|
#include <openrct2/localisation/Formatter.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Award.h>
|
#include <openrct2/management/Award.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/ride/RideData.h>
|
#include <openrct2/ride/RideData.h>
|
||||||
#include <openrct2/scenario/Scenario.h>
|
#include <openrct2/scenario/Scenario.h>
|
||||||
#include <openrct2/util/Util.h>
|
#include <openrct2/util/Util.h>
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include <openrct2/object/ObjectManager.h>
|
#include <openrct2/object/ObjectManager.h>
|
||||||
#include <openrct2/object/ObjectRepository.h>
|
#include <openrct2/object/ObjectRepository.h>
|
||||||
#include <openrct2/object/StationObject.h>
|
#include <openrct2/object/StationObject.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/rct1/RCT1.h>
|
#include <openrct2/rct1/RCT1.h>
|
||||||
#include <openrct2/rct2/T6Exporter.h>
|
#include <openrct2/rct2/T6Exporter.h>
|
||||||
#include <openrct2/ride/RideConstruction.h>
|
#include <openrct2/ride/RideConstruction.h>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Finance.h>
|
#include <openrct2/management/Finance.h>
|
||||||
#include <openrct2/network/network.h>
|
#include <openrct2/network/network.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/sprites.h>
|
#include <openrct2/sprites.h>
|
||||||
#include <openrct2/windows/Intent.h>
|
#include <openrct2/windows/Intent.h>
|
||||||
#include <openrct2/world/Footpath.h>
|
#include <openrct2/world/Footpath.h>
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <openrct2/localisation/Formatter.h>
|
#include <openrct2/localisation/Formatter.h>
|
||||||
#include <openrct2/localisation/Localisation.h>
|
#include <openrct2/localisation/Localisation.h>
|
||||||
#include <openrct2/management/Finance.h>
|
#include <openrct2/management/Finance.h>
|
||||||
|
#include <openrct2/peep/PeepData.h>
|
||||||
#include <openrct2/sprites.h>
|
#include <openrct2/sprites.h>
|
||||||
#include <openrct2/util/Util.h>
|
#include <openrct2/util/Util.h>
|
||||||
#include <openrct2/windows/Intent.h>
|
#include <openrct2/windows/Intent.h>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../localisation/StringIds.h"
|
#include "../localisation/StringIds.h"
|
||||||
#include "../management/Finance.h"
|
#include "../management/Finance.h"
|
||||||
|
#include "../peep/PeepData.h"
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
#include "../scenario/Scenario.h"
|
#include "../scenario/Scenario.h"
|
||||||
#include "../ui/UiContext.h"
|
#include "../ui/UiContext.h"
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "../object/PathAdditionEntry.h"
|
#include "../object/PathAdditionEntry.h"
|
||||||
#include "../object/WallSceneryEntry.h"
|
#include "../object/WallSceneryEntry.h"
|
||||||
#include "../peep/GuestPathfinding.h"
|
#include "../peep/GuestPathfinding.h"
|
||||||
|
#include "../peep/PeepData.h"
|
||||||
#include "../peep/RideUseSystem.h"
|
#include "../peep/RideUseSystem.h"
|
||||||
#include "../rct2/RCT2.h"
|
#include "../rct2/RCT2.h"
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "../network/network.h"
|
#include "../network/network.h"
|
||||||
#include "../paint/Paint.h"
|
#include "../paint/Paint.h"
|
||||||
#include "../peep/GuestPathfinding.h"
|
#include "../peep/GuestPathfinding.h"
|
||||||
|
#include "../peep/PeepData.h"
|
||||||
#include "../profiling/Profiling.h"
|
#include "../profiling/Profiling.h"
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
#include "../ride/RideData.h"
|
#include "../ride/RideData.h"
|
||||||
|
@ -333,7 +334,7 @@ PeepActionSpriteType Peep::GetActionSpriteType()
|
||||||
*/
|
*/
|
||||||
void Peep::UpdateCurrentActionSpriteType()
|
void Peep::UpdateCurrentActionSpriteType()
|
||||||
{
|
{
|
||||||
if (EnumValue(SpriteType) >= std::size(g_peep_animation_entries))
|
if (EnumValue(SpriteType) >= EnumValue(PeepSpriteType::Count))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -438,32 +439,34 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
|
||||||
nextDirection = 0;
|
nextDirection = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Orientation = nextDirection;
|
Orientation = nextDirection;
|
||||||
CoordsXY loc = { x, y };
|
CoordsXY loc = { x, y };
|
||||||
loc += word_981D7C[nextDirection / 8];
|
loc += word_981D7C[nextDirection / 8];
|
||||||
|
|
||||||
WalkingFrameNum++;
|
WalkingFrameNum++;
|
||||||
const PeepAnimation* peepAnimation = &GetPeepAnimation(SpriteType);
|
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
|
||||||
const uint8_t* imageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets;
|
if (WalkingFrameNum >= peepAnimation.frame_offsets.size())
|
||||||
if (WalkingFrameNum >= peepAnimation[EnumValue(ActionSpriteType)].num_frames)
|
|
||||||
{
|
{
|
||||||
WalkingFrameNum = 0;
|
WalkingFrameNum = 0;
|
||||||
}
|
}
|
||||||
ActionSpriteImageOffset = imageOffset[WalkingFrameNum];
|
ActionSpriteImageOffset = peepAnimation.frame_offsets[WalkingFrameNum];
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PeepAnimation* peepAnimation = &GetPeepAnimation(SpriteType);
|
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
|
||||||
ActionFrame++;
|
ActionFrame++;
|
||||||
|
|
||||||
// If last frame of action
|
// If last frame of action
|
||||||
if (ActionFrame >= peepAnimation[EnumValue(ActionSpriteType)].num_frames)
|
if (ActionFrame >= peepAnimation.frame_offsets.size())
|
||||||
{
|
{
|
||||||
ActionSpriteImageOffset = 0;
|
ActionSpriteImageOffset = 0;
|
||||||
Action = PeepActionType::Walking;
|
Action = PeepActionType::Walking;
|
||||||
UpdateCurrentActionSpriteType();
|
UpdateCurrentActionSpriteType();
|
||||||
return { { x, y } };
|
return { { x, y } };
|
||||||
}
|
}
|
||||||
ActionSpriteImageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets[ActionFrame];
|
ActionSpriteImageOffset = peepAnimation.frame_offsets[ActionFrame];
|
||||||
|
|
||||||
auto* guest = As<Guest>();
|
auto* guest = As<Guest>();
|
||||||
// If not throwing up and not at the frame where sick appears.
|
// If not throwing up and not at the frame where sick appears.
|
||||||
|
|
|
@ -427,26 +427,6 @@ private:
|
||||||
void UpdatePicked();
|
void UpdatePicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpriteBounds
|
|
||||||
{
|
|
||||||
uint8_t sprite_width; // 0x00
|
|
||||||
uint8_t sprite_height_negative; // 0x01
|
|
||||||
uint8_t sprite_height_positive; // 0x02
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PeepAnimation
|
|
||||||
{
|
|
||||||
uint32_t base_image; // 0x00
|
|
||||||
size_t num_frames;
|
|
||||||
const uint8_t* frame_offsets;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PeepAnimationEntry
|
|
||||||
{
|
|
||||||
const PeepAnimation* sprite_animation; // 0x00
|
|
||||||
const SpriteBounds* sprite_bounds; // 0x04
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PATHING_DESTINATION_REACHED = 1 << 0,
|
PATHING_DESTINATION_REACHED = 1 << 0,
|
||||||
|
@ -455,8 +435,6 @@ enum
|
||||||
PATHING_RIDE_ENTRANCE = 1 << 3,
|
PATHING_RIDE_ENTRANCE = 1 << 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
// rct2: 0x00982708
|
|
||||||
extern const PeepAnimationEntry g_peep_animation_entries[EnumValue(PeepSpriteType::Count)];
|
|
||||||
extern const bool gSpriteTypeToSlowWalkMap[48];
|
extern const bool gSpriteTypeToSlowWalkMap[48];
|
||||||
|
|
||||||
int32_t PeepGetStaffCount();
|
int32_t PeepGetStaffCount();
|
||||||
|
@ -479,15 +457,3 @@ int32_t PeepCompare(const EntityId sprite_index_a, const EntityId sprite_index_b
|
||||||
void PeepUpdateNames(bool realNames);
|
void PeepUpdateNames(bool realNames);
|
||||||
|
|
||||||
StringId GetRealNameStringIDFromPeepID(uint32_t id);
|
StringId GetRealNameStringIDFromPeepID(uint32_t id);
|
||||||
|
|
||||||
inline const PeepAnimation& GetPeepAnimation(
|
|
||||||
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None)
|
|
||||||
{
|
|
||||||
return g_peep_animation_entries[EnumValue(spriteType)].sprite_animation[EnumValue(actionSpriteType)];
|
|
||||||
};
|
|
||||||
|
|
||||||
inline const SpriteBounds& GetSpriteBounds(
|
|
||||||
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None)
|
|
||||||
{
|
|
||||||
return g_peep_animation_entries[EnumValue(spriteType)].sprite_bounds[EnumValue(actionSpriteType)];
|
|
||||||
};
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,43 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../entity/Peep.h"
|
||||||
|
|
||||||
|
#include <span>
|
||||||
|
|
||||||
|
namespace OpenRCT2
|
||||||
|
{
|
||||||
|
struct SpriteBounds
|
||||||
|
{
|
||||||
|
uint8_t sprite_width; // 0x00
|
||||||
|
uint8_t sprite_height_negative; // 0x01
|
||||||
|
uint8_t sprite_height_positive; // 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PeepAnimation
|
||||||
|
{
|
||||||
|
uint32_t base_image;
|
||||||
|
SpriteBounds bounds;
|
||||||
|
std::span<const uint8_t> frame_offsets;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PeepAnimationGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
constexpr PeepAnimation& operator[](PeepActionSpriteType n)
|
||||||
|
{
|
||||||
|
return animations[EnumValue(n)];
|
||||||
|
}
|
||||||
|
constexpr const PeepAnimation& operator[](PeepActionSpriteType n) const
|
||||||
|
{
|
||||||
|
return animations[EnumValue(n)];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PeepAnimation animations[37]{};
|
||||||
|
};
|
||||||
|
|
||||||
|
const PeepAnimation& GetPeepAnimation(
|
||||||
|
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None);
|
||||||
|
const SpriteBounds& GetSpriteBounds(
|
||||||
|
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None);
|
||||||
|
} // namespace OpenRCT2
|
|
@ -46,6 +46,7 @@
|
||||||
#include "../object/ObjectList.h"
|
#include "../object/ObjectList.h"
|
||||||
#include "../object/ObjectManager.h"
|
#include "../object/ObjectManager.h"
|
||||||
#include "../object/ObjectRepository.h"
|
#include "../object/ObjectRepository.h"
|
||||||
|
#include "../peep/PeepData.h"
|
||||||
#include "../peep/RideUseSystem.h"
|
#include "../peep/RideUseSystem.h"
|
||||||
#include "../rct12/EntryList.h"
|
#include "../rct12/EntryList.h"
|
||||||
#include "../ride/RideData.h"
|
#include "../ride/RideData.h"
|
||||||
|
|
Loading…
Reference in New Issue