Move entities into OpenRCT2 namespace (#26173)

This commit is contained in:
Aaron van Geffen authored and GitHub committed 2026-03-10 07:39:53 +01:00
1 parent b96c0cda52
commit 586c2edb57
47 files changed
+15015 -14936

No files matched your search

+1 -1
View File
@@ -16,7 +16,6 @@
#include <string_view>
struct StringWithArgs;
struct Peep;
struct Ride;
struct RideSelection;
struct TrackDesign;
@@ -32,6 +31,7 @@ namespace OpenRCT2
{
class Formatter;
struct ObjectEntryDescriptor;
struct Peep;
struct TileElement;
} // namespace OpenRCT2
+1 -1
View File
@@ -38,7 +38,7 @@ struct GameStateSpriteChange
};
uint8_t changeType;
EntityType entityType;
OpenRCT2::EntityType entityType;
uint32_t spriteIndex;
std::vector<Diff> diffs;
+2 -2
View File
@@ -16,12 +16,12 @@
struct CoordsXY;
struct Vehicle;
struct CoordsXYZ;
struct EntityBase;
namespace OpenRCT2
{
struct EntityBase;
struct Viewport;
}
} // namespace OpenRCT2
namespace OpenRCT2::Drawing
{
+136 -135
View File
@@ -22,161 +22,162 @@
#include "../world/tile_element/TrackElement.h"
#include "EntityRegistry.h"
using namespace OpenRCT2;
template<>
bool EntityBase::Is<Balloon>() const
namespace OpenRCT2
{
return Type == EntityType::balloon;
}
void Balloon::Update()
{
Invalidate();
if (popped == 1)
template<>
bool EntityBase::Is<Balloon>() const
{
frame++;
if (frame >= 5)
{
getGameState().entities.EntityRemove(this);
}
return Type == EntityType::balloon;
}
else
void Balloon::Update()
{
time_to_move++;
if (time_to_move >= 3)
Invalidate();
if (popped == 1)
{
time_to_move = 0;
frame++;
// NOTE: To keep S6 Compatibility this field needs to roll over after 1 byte
if (frame == 256)
if (frame >= 5)
{
frame = 0;
getGameState().entities.EntityRemove(this);
}
if (Collides())
{
Pop(false);
return;
}
MoveTo({ x, y, z + 1 });
int32_t maxZ = 1967 - ((x ^ y) & 31);
if (z >= maxZ)
{
Pop(true);
}
}
}
}
void Balloon::Press()
{
if (popped != 1)
{
// There is a random chance that pressing the balloon will not pop it
// and instead shift it slightly
uint32_t random = ScenarioRand();
if ((Id.ToUnderlying() & 7) || (random & 0xFFFF) < 0x2000)
{
Pop(true);
}
else
{
int16_t shift = ((random & 0x80000000) ? -6 : 6);
MoveTo({ x + shift, y, z });
}
}
}
void Balloon::Pop(bool playSound)
{
popped = 1;
frame = 0;
if (playSound)
{
Audio::Play3D(Audio::SoundId::balloonPop, { x, y, z });
}
}
void Balloon::Create(const CoordsXYZ& balloonPos, Drawing::Colour colour, bool isPopped)
{
auto* balloon = getGameState().entities.CreateEntity<Balloon>();
if (balloon == nullptr)
return;
balloon->SpriteData.Width = 13;
balloon->SpriteData.HeightMin = 22;
balloon->SpriteData.HeightMax = 11;
balloon->MoveTo(balloonPos);
balloon->time_to_move = 0;
balloon->frame = 0;
balloon->colour = colour;
balloon->popped = (isPopped ? 1 : 0);
}
void Balloon::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << popped;
stream << time_to_move;
stream << colour;
}
void Balloon::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = 22651 + (frame & 7);
if (popped != 0)
{
imageId += 8;
}
auto image = ImageId(imageId, colour);
PaintAddImageAsParent(session, image, { 0, 0, z }, { 1, 1, 0 });
}
bool Balloon::Collides() const
{
const TileElement* tileElement = MapGetFirstElementAt(CoordsXY({ x, y }));
if (tileElement == nullptr)
return false;
do
{
// the balloon has height so we add some padding to prevent it clipping through things.
int32_t balloon_top = z + kCoordsZStep * 2;
if (balloon_top == tileElement->GetBaseZ())
{
return true;
}
// check for situations where guests can drop a balloon inside a covered building
bool check_ceiling = tileElement->GetType() == TileElementType::Entrance;
if (tileElement->GetType() == TileElementType::Track)
{
const TrackElement* trackElement = tileElement->AsTrack();
const auto* ride = GetRide(trackElement->GetRideIndex());
if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::hasRoofOverWholeRide))
time_to_move++;
if (time_to_move >= 3)
{
check_ceiling = true;
time_to_move = 0;
frame++;
// NOTE: To keep S6 Compatibility this field needs to roll over after 1 byte
if (frame == 256)
{
frame = 0;
}
if (Collides())
{
Pop(false);
return;
}
MoveTo({ x, y, z + 1 });
int32_t maxZ = 1967 - ((x ^ y) & 31);
if (z >= maxZ)
{
Pop(true);
}
}
}
}
void Balloon::Press()
{
if (popped != 1)
{
// There is a random chance that pressing the balloon will not pop it
// and instead shift it slightly
uint32_t random = ScenarioRand();
if ((Id.ToUnderlying() & 7) || (random & 0xFFFF) < 0x2000)
{
Pop(true);
}
else
{
check_ceiling = (ride != nullptr) ? RideHasStationShelter(*ride) : false;
int16_t shift = ((random & 0x80000000) ? -6 : 6);
MoveTo({ x + shift, y, z });
}
}
}
if (check_ceiling)
void Balloon::Pop(bool playSound)
{
popped = 1;
frame = 0;
if (playSound)
{
if (balloon_top > tileElement->GetBaseZ() && z < tileElement->GetClearanceZ())
Audio::Play3D(Audio::SoundId::balloonPop, { x, y, z });
}
}
void Balloon::Create(const CoordsXYZ& balloonPos, Drawing::Colour colour, bool isPopped)
{
auto* balloon = getGameState().entities.CreateEntity<Balloon>();
if (balloon == nullptr)
return;
balloon->SpriteData.Width = 13;
balloon->SpriteData.HeightMin = 22;
balloon->SpriteData.HeightMax = 11;
balloon->MoveTo(balloonPos);
balloon->time_to_move = 0;
balloon->frame = 0;
balloon->colour = colour;
balloon->popped = (isPopped ? 1 : 0);
}
void Balloon::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << popped;
stream << time_to_move;
stream << colour;
}
void Balloon::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = 22651 + (frame & 7);
if (popped != 0)
{
imageId += 8;
}
auto image = ImageId(imageId, colour);
PaintAddImageAsParent(session, image, { 0, 0, z }, { 1, 1, 0 });
}
bool Balloon::Collides() const
{
const TileElement* tileElement = MapGetFirstElementAt(CoordsXY({ x, y }));
if (tileElement == nullptr)
return false;
do
{
// the balloon has height so we add some padding to prevent it clipping through things.
int32_t balloon_top = z + kCoordsZStep * 2;
if (balloon_top == tileElement->GetBaseZ())
{
return true;
}
}
} while (!(tileElement++)->IsLastForTile());
return false;
}
// check for situations where guests can drop a balloon inside a covered building
bool check_ceiling = tileElement->GetType() == TileElementType::Entrance;
if (tileElement->GetType() == TileElementType::Track)
{
const TrackElement* trackElement = tileElement->AsTrack();
const auto* ride = GetRide(trackElement->GetRideIndex());
if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::hasRoofOverWholeRide))
{
check_ceiling = true;
}
else
{
check_ceiling = (ride != nullptr) ? RideHasStationShelter(*ride) : false;
}
}
if (check_ceiling)
{
if (balloon_top > tileElement->GetBaseZ() && z < tileElement->GetClearanceZ())
{
return true;
}
}
} while (!(tileElement++)->IsLastForTile());
return false;
}
} // namespace OpenRCT2
+19 -19
View File
@@ -14,28 +14,28 @@
struct CoordsXYZ;
struct PaintSession;
namespace OpenRCT2
{
class DataSerialiser;
}
namespace OpenRCT2::Drawing
{
enum class Colour : uint8_t;
}
struct Balloon : EntityBase
namespace OpenRCT2
{
static constexpr auto cEntityType = EntityType::balloon;
uint16_t frame;
uint16_t popped;
uint8_t time_to_move;
OpenRCT2::Drawing::Colour colour;
static void Create(const CoordsXYZ& balloonPos, OpenRCT2::Drawing::Colour colour, bool isPopped);
void Update();
void Pop(bool playSound);
void Press();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
bool Collides() const;
};
class DataSerialiser;
struct Balloon : EntityBase
{
static constexpr auto cEntityType = EntityType::balloon;
uint16_t frame;
uint16_t popped;
uint8_t time_to_move;
Drawing::Colour colour;
static void Create(const CoordsXYZ& balloonPos, Drawing::Colour colour, bool isPopped);
void Update();
void Pop(bool playSound);
void Press();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
bool Collides() const;
};
} // namespace OpenRCT2
+276 -275
View File
@@ -25,11 +25,11 @@
#include <iterator>
#include <limits>
using namespace OpenRCT2;
namespace OpenRCT2
{
constexpr int32_t kDuckMaxStates = 5;
constexpr int32_t kDuckMaxStates = 5;
// clang-format off
// clang-format off
static constexpr CoordsXY kDuckMoveOffset[] =
{
{ -1, 0 },
@@ -63,327 +63,328 @@ static constexpr uint8_t kDuckAnimationFlyAway[] =
{
8, 9, 10, 11, 12, 13
};
// clang-format on
// clang-format on
static constexpr const uint8_t* kDuckAnimations[] = {
kDuckAnimationFlyToWater, // DuckState::FlyToWater,
kDuckAnimationSwim, // DuckState::Swim,
kDuckAnimationDrink, // DuckState::Drink,
kDuckAnimationDoubleDrink, // DuckState::DoubleDrink,
kDuckAnimationFlyAway, // DuckState::FlyAway,
};
static constexpr const uint8_t* kDuckAnimations[] = {
kDuckAnimationFlyToWater, // DuckState::FlyToWater,
kDuckAnimationSwim, // DuckState::Swim,
kDuckAnimationDrink, // DuckState::Drink,
kDuckAnimationDoubleDrink, // DuckState::DoubleDrink,
kDuckAnimationFlyAway, // DuckState::FlyAway,
};
template<>
bool EntityBase::Is<Duck>() const
{
return Type == EntityType::duck;
}
bool Duck::IsFlying()
{
return this->state == DuckState::FlyAway || this->state == DuckState::FlyToWater;
}
void Duck::Remove()
{
Invalidate();
getGameState().entities.EntityRemove(this);
}
void Duck::UpdateFlyToWater()
{
const auto currentTicks = getGameState().currentTicks;
if ((currentTicks & 3) != 0)
return;
frame++;
if (frame >= std::size(kDuckAnimationFlyToWater))
template<>
bool EntityBase::Is<Duck>() const
{
frame = 0;
return Type == EntityType::duck;
}
Invalidate();
int32_t manhattanDistance = abs(target_x - x) + abs(target_y - y);
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
int32_t manhattanDistanceN = abs(target_x - destination.x) + abs(target_y - destination.y);
auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ target_x, target_y });
int32_t waterHeight = surfaceElement != nullptr ? surfaceElement->GetWaterHeight() : 0;
if (waterHeight == 0)
bool Duck::IsFlying()
{
state = DuckState::FlyAway;
UpdateFlyAway();
return this->state == DuckState::FlyAway || this->state == DuckState::FlyToWater;
}
else
{
destination.z = abs(z - waterHeight);
if (manhattanDistanceN <= manhattanDistance)
{
if (destination.z > manhattanDistanceN)
{
destination.z = z - 2;
if (waterHeight >= z)
{
destination.z += 4;
}
frame = 1;
}
else
{
destination.z = z;
}
MoveTo(destination);
}
else
{
if (destination.z > 4)
{
state = DuckState::FlyAway;
UpdateFlyAway();
}
else
{
state = DuckState::Swim;
frame = 0;
UpdateSwim();
}
}
void Duck::Remove()
{
Invalidate();
getGameState().entities.EntityRemove(this);
}
}
void Duck::UpdateSwim()
{
const auto currentTicks = getGameState().currentTicks;
if (((currentTicks + Id.ToUnderlying()) & 3) != 0)
return;
uint32_t randomNumber = ScenarioRand();
if ((randomNumber & 0xFFFF) < 0x666)
void Duck::UpdateFlyToWater()
{
if (randomNumber & 0x80000000)
const auto currentTicks = getGameState().currentTicks;
if ((currentTicks & 3) != 0)
return;
frame++;
if (frame >= std::size(kDuckAnimationFlyToWater))
{
state = DuckState::DoubleDrink;
frame = std::numeric_limits<uint16_t>::max();
UpdateDoubleDrink();
frame = 0;
}
else
{
state = DuckState::Drink;
frame = std::numeric_limits<uint16_t>::max();
UpdateDrink();
}
}
else
{
int32_t currentMonth = GetDate().GetMonth();
if (currentMonth >= MONTH_SEPTEMBER && (randomNumber >> 16) < 218)
Invalidate();
int32_t manhattanDistance = abs(target_x - x) + abs(target_y - y);
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
int32_t manhattanDistanceN = abs(target_x - destination.x) + abs(target_y - destination.y);
auto surfaceElement = MapGetSurfaceElementAt(CoordsXY{ target_x, target_y });
int32_t waterHeight = surfaceElement != nullptr ? surfaceElement->GetWaterHeight() : 0;
if (waterHeight == 0)
{
state = DuckState::FlyAway;
UpdateFlyAway();
}
else
{
Invalidate();
int16_t landZ = TileElementHeight({ x, y });
int16_t waterZ = TileElementWaterHeight({ x, y });
destination.z = abs(z - waterHeight);
if (z < landZ || waterZ == 0)
if (manhattanDistanceN <= manhattanDistance)
{
if (destination.z > manhattanDistanceN)
{
destination.z = z - 2;
if (waterHeight >= z)
{
destination.z += 4;
}
frame = 1;
}
else
{
destination.z = z;
}
MoveTo(destination);
}
else
{
if (destination.z > 4)
{
state = DuckState::FlyAway;
UpdateFlyAway();
}
else
{
state = DuckState::Swim;
frame = 0;
UpdateSwim();
}
}
}
}
void Duck::UpdateSwim()
{
const auto currentTicks = getGameState().currentTicks;
if (((currentTicks + Id.ToUnderlying()) & 3) != 0)
return;
uint32_t randomNumber = ScenarioRand();
if ((randomNumber & 0xFFFF) < 0x666)
{
if (randomNumber & 0x80000000)
{
state = DuckState::DoubleDrink;
frame = std::numeric_limits<uint16_t>::max();
UpdateDoubleDrink();
}
else
{
state = DuckState::Drink;
frame = std::numeric_limits<uint16_t>::max();
UpdateDrink();
}
}
else
{
int32_t currentMonth = GetDate().GetMonth();
if (currentMonth >= MONTH_SEPTEMBER && (randomNumber >> 16) < 218)
{
state = DuckState::FlyAway;
UpdateFlyAway();
}
else
{
z = waterZ;
randomNumber = ScenarioRand();
if ((randomNumber & 0xFFFF) <= 0xAAA)
Invalidate();
int16_t landZ = TileElementHeight({ x, y });
int16_t waterZ = TileElementWaterHeight({ x, y });
if (z < landZ || waterZ == 0)
{
randomNumber >>= 16;
Orientation = randomNumber & 0x18;
state = DuckState::FlyAway;
UpdateFlyAway();
}
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
landZ = TileElementHeight(destination);
waterZ = TileElementWaterHeight(destination);
if (z > landZ && z == waterZ)
else
{
destination.z = waterZ;
MoveTo(destination);
Invalidate();
z = waterZ;
randomNumber = ScenarioRand();
if ((randomNumber & 0xFFFF) <= 0xAAA)
{
randomNumber >>= 16;
Orientation = randomNumber & 0x18;
}
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ CoordsXY{ x, y } + kDuckMoveOffset[direction], 0 };
landZ = TileElementHeight(destination);
waterZ = TileElementWaterHeight(destination);
if (z > landZ && z == waterZ)
{
destination.z = waterZ;
MoveTo(destination);
Invalidate();
}
}
}
}
}
}
void Duck::UpdateDrink()
{
frame++;
if (kDuckAnimationDrink[frame] == 0xFF)
{
state = DuckState::Swim;
frame = 0;
UpdateSwim();
}
else
{
Invalidate();
}
}
void Duck::UpdateDoubleDrink()
{
frame++;
if (kDuckAnimationDoubleDrink[frame] == 0xFF)
{
state = DuckState::Swim;
frame = 0;
UpdateSwim();
}
else
{
Invalidate();
}
}
void Duck::UpdateFlyAway()
{
if ((getGameState().currentTicks & 3) == 0)
void Duck::UpdateDrink()
{
frame++;
if (frame >= std::size(kDuckAnimationFlyAway))
if (kDuckAnimationDrink[frame] == 0xFF)
{
state = DuckState::Swim;
frame = 0;
}
Invalidate();
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ x + (kDuckMoveOffset[direction].x * 2), y + (kDuckMoveOffset[direction].y * 2),
std::min<int32_t>(z + 2, 496) };
if (MapIsLocationValid(destination))
{
MoveTo(destination);
UpdateSwim();
}
else
{
Remove();
Invalidate();
}
}
}
uint32_t Duck::GetFrameImage(int32_t direction) const
{
uint32_t imageId = 0;
if (EnumValue(state) < kDuckMaxStates)
void Duck::UpdateDoubleDrink()
{
// TODO: Check frame is in range
uint8_t imageOffset = kDuckAnimations[EnumValue(state)][frame];
imageId = SPR_DUCK + (imageOffset * 4) + (direction / 8);
}
return imageId;
}
void Duck::Create(const CoordsXY& pos)
{
auto* duck = getGameState().entities.CreateEntity<Duck>();
if (duck == nullptr)
return;
CoordsXY targetPos = pos;
int32_t offsetXY = ScenarioRand() & 0x1E;
targetPos.x += offsetXY;
targetPos.y += offsetXY;
duck->SpriteData.Width = 9;
duck->SpriteData.HeightMin = 12;
duck->SpriteData.HeightMax = 9;
duck->target_x = targetPos.x;
duck->target_y = targetPos.y;
uint8_t direction = ScenarioRand() & 3;
switch (direction)
{
case 0:
targetPos.x = GetMapSizeMaxXY().x - (ScenarioRand() & 0x3F);
break;
case 1:
targetPos.y = ScenarioRand() & 0x3F;
break;
case 2:
targetPos.x = ScenarioRand() & 0x3F;
break;
case 3:
targetPos.y = GetMapSizeMaxXY().y - (ScenarioRand() & 0x3F);
break;
}
duck->Orientation = direction << 3;
duck->MoveTo({ targetPos.x, targetPos.y, 496 });
duck->state = DuckState::FlyToWater;
duck->frame = 0;
}
void Duck::Update()
{
switch (state)
{
case DuckState::FlyToWater:
UpdateFlyToWater();
break;
case DuckState::Swim:
frame++;
if (kDuckAnimationDoubleDrink[frame] == 0xFF)
{
state = DuckState::Swim;
frame = 0;
UpdateSwim();
break;
case DuckState::Drink:
UpdateDrink();
break;
case DuckState::DoubleDrink:
UpdateDoubleDrink();
break;
case DuckState::FlyAway:
UpdateFlyAway();
break;
}
else
{
Invalidate();
}
}
}
void Duck::Press()
{
OpenRCT2::Audio::Play3D(Audio::SoundId::quack, { x, y, z });
}
void Duck::RemoveAll()
{
for (auto duck : EntityList<Duck>())
void Duck::UpdateFlyAway()
{
duck->Remove();
if ((getGameState().currentTicks & 3) == 0)
{
frame++;
if (frame >= std::size(kDuckAnimationFlyAway))
{
frame = 0;
}
Invalidate();
int32_t direction = Orientation >> 3;
auto destination = CoordsXYZ{ x + (kDuckMoveOffset[direction].x * 2), y + (kDuckMoveOffset[direction].y * 2),
std::min<int32_t>(z + 2, 496) };
if (MapIsLocationValid(destination))
{
MoveTo(destination);
}
else
{
Remove();
}
}
}
}
void Duck::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << target_x;
stream << target_y;
stream << state;
}
void Duck::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 1 })
return;
uint32_t imageId = GetFrameImage(imageDirection);
if (imageId != 0)
uint32_t Duck::GetFrameImage(int32_t direction) const
{
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
uint32_t imageId = 0;
if (EnumValue(state) < kDuckMaxStates)
{
// TODO: Check frame is in range
uint8_t imageOffset = kDuckAnimations[EnumValue(state)][frame];
imageId = SPR_DUCK + (imageOffset * 4) + (direction / 8);
}
return imageId;
}
}
void Duck::Create(const CoordsXY& pos)
{
auto* duck = getGameState().entities.CreateEntity<Duck>();
if (duck == nullptr)
return;
CoordsXY targetPos = pos;
int32_t offsetXY = ScenarioRand() & 0x1E;
targetPos.x += offsetXY;
targetPos.y += offsetXY;
duck->SpriteData.Width = 9;
duck->SpriteData.HeightMin = 12;
duck->SpriteData.HeightMax = 9;
duck->target_x = targetPos.x;
duck->target_y = targetPos.y;
uint8_t direction = ScenarioRand() & 3;
switch (direction)
{
case 0:
targetPos.x = GetMapSizeMaxXY().x - (ScenarioRand() & 0x3F);
break;
case 1:
targetPos.y = ScenarioRand() & 0x3F;
break;
case 2:
targetPos.x = ScenarioRand() & 0x3F;
break;
case 3:
targetPos.y = GetMapSizeMaxXY().y - (ScenarioRand() & 0x3F);
break;
}
duck->Orientation = direction << 3;
duck->MoveTo({ targetPos.x, targetPos.y, 496 });
duck->state = DuckState::FlyToWater;
duck->frame = 0;
}
void Duck::Update()
{
switch (state)
{
case DuckState::FlyToWater:
UpdateFlyToWater();
break;
case DuckState::Swim:
UpdateSwim();
break;
case DuckState::Drink:
UpdateDrink();
break;
case DuckState::DoubleDrink:
UpdateDoubleDrink();
break;
case DuckState::FlyAway:
UpdateFlyAway();
break;
}
}
void Duck::Press()
{
OpenRCT2::Audio::Play3D(Audio::SoundId::quack, { x, y, z });
}
void Duck::RemoveAll()
{
for (auto duck : EntityList<Duck>())
{
duck->Remove();
}
}
void Duck::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << target_x;
stream << target_y;
stream << state;
}
void Duck::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 1 })
return;
uint32_t imageId = GetFrameImage(imageDirection);
if (imageId != 0)
{
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
}
} // namespace OpenRCT2
+32 -32
View File
@@ -17,38 +17,38 @@ struct PaintSession;
namespace OpenRCT2
{
class DataSerialiser;
}
struct Duck : EntityBase
{
static constexpr auto cEntityType = EntityType::duck;
enum class DuckState : uint8_t
struct Duck : EntityBase
{
FlyToWater,
Swim,
Drink,
DoubleDrink,
FlyAway,
static constexpr auto cEntityType = EntityType::duck;
enum class DuckState : uint8_t
{
FlyToWater,
Swim,
Drink,
DoubleDrink,
FlyAway,
};
uint16_t frame;
int16_t target_x;
int16_t target_y;
DuckState state;
static void Create(const CoordsXY& pos);
static void RemoveAll();
void Press();
void Update();
uint32_t GetFrameImage(int32_t direction) const;
bool IsFlying();
void Remove();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
private:
void UpdateFlyToWater();
void UpdateSwim();
void UpdateDrink();
void UpdateDoubleDrink();
void UpdateFlyAway();
};
uint16_t frame;
int16_t target_x;
int16_t target_y;
DuckState state;
static void Create(const CoordsXY& pos);
static void RemoveAll();
void Press();
void Update();
uint32_t GetFrameImage(int32_t direction) const;
bool IsFlying();
void Remove();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
private:
void UpdateFlyToWater();
void UpdateSwim();
void UpdateDrink();
void UpdateDoubleDrink();
void UpdateFlyAway();
};
} // namespace OpenRCT2
+57 -56
View File
@@ -13,65 +13,66 @@
#include "../core/Guard.hpp"
#include "../interface/Viewport.h"
using namespace OpenRCT2;
// Required for GetEntity to return a default
template<>
bool EntityBase::Is<EntityBase>() const
namespace OpenRCT2
{
return true;
}
void EntityBase::Invalidate()
{
if (x == kLocationNull)
return;
ZoomLevel maxZoom{ 0 };
switch (Type)
// Required for GetEntity to return a default
template<>
bool EntityBase::Is<EntityBase>() const
{
case EntityType::vehicle:
case EntityType::guest:
case EntityType::staff:
maxZoom = ZoomLevel{ 2 };
break;
case EntityType::crashedVehicleParticle:
case EntityType::jumpingFountain:
maxZoom = ZoomLevel{ 0 };
break;
case EntityType::duck:
maxZoom = ZoomLevel{ 1 };
break;
case EntityType::steamParticle:
case EntityType::moneyEffect:
case EntityType::explosionCloud:
case EntityType::crashSplash:
case EntityType::explosionFlare:
case EntityType::balloon:
maxZoom = ZoomLevel{ 2 };
break;
case EntityType::litter:
maxZoom = ZoomLevel{ 0 };
break;
default:
break;
return true;
}
ViewportsInvalidate(GetLocation(), SpriteData.Width, SpriteData.HeightMin, SpriteData.HeightMax, maxZoom);
}
void EntityBase::Invalidate()
{
if (x == kLocationNull)
return;
void EntityBase::Serialise(DataSerialiser& stream)
{
stream << Type;
stream << Id;
stream << x;
stream << y;
stream << z;
stream << Orientation;
}
ZoomLevel maxZoom{ 0 };
switch (Type)
{
case EntityType::vehicle:
case EntityType::guest:
case EntityType::staff:
maxZoom = ZoomLevel{ 2 };
break;
case EntityType::crashedVehicleParticle:
case EntityType::jumpingFountain:
maxZoom = ZoomLevel{ 0 };
break;
case EntityType::duck:
maxZoom = ZoomLevel{ 1 };
break;
case EntityType::steamParticle:
case EntityType::moneyEffect:
case EntityType::explosionCloud:
case EntityType::crashSplash:
case EntityType::explosionFlare:
case EntityType::balloon:
maxZoom = ZoomLevel{ 2 };
break;
case EntityType::litter:
maxZoom = ZoomLevel{ 0 };
break;
default:
break;
}
// Exists only for signature
void EntityBase::Paint() const
{
Guard::Assert(false, "You are not supposed to call this");
}
ViewportsInvalidate(GetLocation(), SpriteData.Width, SpriteData.HeightMin, SpriteData.HeightMax, maxZoom);
}
void EntityBase::Serialise(DataSerialiser& stream)
{
stream << Type;
stream << Id;
stream << x;
stream << y;
stream << z;
stream << Orientation;
}
// Exists only for signature
void EntityBase::Paint() const
{
Guard::Assert(false, "You are not supposed to call this");
}
} // namespace OpenRCT2
+87 -87
View File
@@ -3,101 +3,101 @@
#include "../Identifiers.h"
#include "../world/Location.hpp"
enum class EntityType : uint8_t
{
vehicle,
guest,
staff,
litter,
steamParticle,
moneyEffect,
crashedVehicleParticle,
explosionCloud,
crashSplash,
explosionFlare,
jumpingFountain,
balloon,
duck,
count,
null = 255
};
struct EntitySpriteData
{
// Width from centre of sprite to edge
uint8_t Width;
// Height from centre of sprite to bottom
uint8_t HeightMin;
// Height from centre of sprite to top
uint8_t HeightMax;
// Screen Coordinates of sprite
ScreenRect SpriteRect;
};
namespace OpenRCT2
{
class DataSerialiser;
}
struct EntityBase
{
EntityType Type;
EntityId Id;
int32_t x;
int32_t y;
int32_t z;
EntitySpriteData SpriteData;
// Used as direction or rotation depending on the entity.
uint8_t Orientation;
uint32_t SpatialIndex;
/**
* Moves a sprite to a new location, invalidates the current position if valid
* and also the new position.
*
* rct2: 0x0069E9D3
*/
void MoveTo(const CoordsXYZ& newLocation);
void MoveToAndUpdateSpatialIndex(const CoordsXYZ& newLocation);
/**
* Sets the entity location without screen invalidation.
*/
void SetLocation(const CoordsXYZ& newLocation);
/**
* Gets the entity current location.
*/
CoordsXYZ GetLocation() const;
void Invalidate();
template<typename T>
bool Is() const;
template<typename T>
T* As()
enum class EntityType : uint8_t
{
return Is<T>() ? reinterpret_cast<T*>(this) : nullptr;
}
template<typename T>
const T* As() const
vehicle,
guest,
staff,
litter,
steamParticle,
moneyEffect,
crashedVehicleParticle,
explosionCloud,
crashSplash,
explosionFlare,
jumpingFountain,
balloon,
duck,
count,
null = 255
};
struct EntitySpriteData
{
return Is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
}
// Width from centre of sprite to edge
uint8_t Width;
// Height from centre of sprite to bottom
uint8_t HeightMin;
// Height from centre of sprite to top
uint8_t HeightMax;
// Screen Coordinates of sprite
ScreenRect SpriteRect;
};
template<typename T>
T* cast()
struct EntityBase
{
return reinterpret_cast<T*>(this);
}
EntityType Type;
EntityId Id;
int32_t x;
int32_t y;
int32_t z;
EntitySpriteData SpriteData;
// Used as direction or rotation depending on the entity.
uint8_t Orientation;
uint32_t SpatialIndex;
template<typename T>
const T* cast() const
{
return reinterpret_cast<const T*>(this);
}
/**
* Moves a sprite to a new location, invalidates the current position if valid
* and also the new position.
*
* rct2: 0x0069E9D3
*/
void MoveTo(const CoordsXYZ& newLocation);
void Serialise(class OpenRCT2::DataSerialiser& stream);
void MoveToAndUpdateSpatialIndex(const CoordsXYZ& newLocation);
void Paint() const;
};
/**
* Sets the entity location without screen invalidation.
*/
void SetLocation(const CoordsXYZ& newLocation);
/**
* Gets the entity current location.
*/
CoordsXYZ GetLocation() const;
void Invalidate();
template<typename T>
bool Is() const;
template<typename T>
T* As()
{
return Is<T>() ? reinterpret_cast<T*>(this) : nullptr;
}
template<typename T>
const T* As() const
{
return Is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
}
template<typename T>
T* cast()
{
return reinterpret_cast<T*>(this);
}
template<typename T>
const T* cast() const
{
return reinterpret_cast<const T*>(this);
}
void Serialise(class DataSerialiser& stream);
void Paint() const;
};
} // namespace OpenRCT2
+369 -367
View File
@@ -23,429 +23,431 @@
#include "../world/tile_element/PathElement.h"
#include "EntityRegistry.h"
using namespace OpenRCT2;
enum class Pattern
namespace OpenRCT2
{
cyclicSquares,
continuousChasers,
bouncingPairs,
sproutingBlooms,
racingPairs,
splittingChasers,
dopeyJumpers,
fastRandomChasers,
};
static constexpr std::array _fountainDirectionsNegative = {
CoordsXY{ -kCoordsXYStep, 0 },
CoordsXY{ -kCoordsXYStep, -kCoordsXYStep },
CoordsXY{ 0, 0 },
CoordsXY{ -kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, -kCoordsXYStep },
CoordsXY{ 0, -kCoordsXYStep },
CoordsXY{ -kCoordsXYStep, -kCoordsXYStep },
};
static constexpr std::array _fountainDirectionsPositive = {
CoordsXY{ kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, kCoordsXYStep },
};
static constexpr auto kFountainChanceOfStoppingEdgeMode = 0x3333; // 0.200
static constexpr auto kFountainChanceOfStoppingRandomMode = 0x2000; // 0.125
// rct2: 0x0097F040
const uint8_t _fountainDirections[] = {
0, 1, 2, 3, 0, 1, 2, 3,
};
// rct2: 0x0097F048
const FountainFlags _fountainDirectionFlags[] = {
{}, {}, FountainFlag::direction, FountainFlag::direction, FountainFlag::direction, FountainFlag::direction, {}, {},
};
// rct2: 0x0097F050
const FountainFlags _fountainPatternFlags[] = {
{ FountainFlag::terminate }, // cyclicSquares
{ FountainFlag::fast, FountainFlag::goToEdge }, // continuousChasers
{ FountainFlag::bounce }, // bouncingPairs
{ FountainFlag::fast, FountainFlag::split }, // sproutingBlooms
{ FountainFlag::goToEdge }, // racingPairs
{ FountainFlag::fast, FountainFlag::goToEdge, FountainFlag::split }, // splittingChasers
{}, // dopeyJumpers
{ FountainFlag::fast }, // fastRandomChasers
};
template<>
bool EntityBase::Is<JumpingFountain>() const
{
return Type == EntityType::jumpingFountain;
}
void JumpingFountain::StartAnimation(const JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement)
{
const auto currentTicks = getGameState().currentTicks;
int32_t randomIndex;
auto newZ = tileElement->GetBaseZ();
// Change pattern approximately every 51 seconds
uint32_t pattern = (currentTicks >> 11) & 7;
switch (static_cast<Pattern>(pattern))
enum class Pattern
{
case Pattern::cyclicSquares:
// 0, 1, 2, 3
for (int32_t i = 0; i < kNumOrthogonalDirections; i++)
{
Create(
newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i],
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
}
break;
case Pattern::bouncingPairs:
// random [0, 2 or 1, 3]
randomIndex = ScenarioRand() & 1;
for (int32_t i = randomIndex; i < kNumOrthogonalDirections; i += 2)
{
Create(
newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i],
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
}
break;
case Pattern::racingPairs:
// random [0 - 3 and 4 - 7]
randomIndex = ScenarioRand() & 3;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
randomIndex += 4;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
break;
default:
// random [0 - 7]
randomIndex = ScenarioRand() & 7;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
break;
}
}
cyclicSquares,
continuousChasers,
bouncingPairs,
sproutingBlooms,
racingPairs,
splittingChasers,
dopeyJumpers,
fastRandomChasers,
};
void JumpingFountain::Create(
const JumpingFountainType newType, const CoordsXYZ& newLoc, const int32_t direction, const FountainFlags newFlags,
const int32_t iteration)
{
auto* jumpingFountain = getGameState().entities.CreateEntity<JumpingFountain>();
if (jumpingFountain != nullptr)
{
jumpingFountain->Iteration = iteration;
jumpingFountain->fountainFlags = newFlags;
jumpingFountain->Orientation = direction << 3;
jumpingFountain->SpriteData.Width = 33;
jumpingFountain->SpriteData.HeightMin = 36;
jumpingFountain->SpriteData.HeightMax = 12;
jumpingFountain->MoveTo(newLoc);
jumpingFountain->FountainType = newType;
jumpingFountain->NumTicksAlive = 0;
jumpingFountain->frame = 0;
}
}
static constexpr std::array _fountainDirectionsNegative = {
CoordsXY{ -kCoordsXYStep, 0 },
CoordsXY{ -kCoordsXYStep, -kCoordsXYStep },
CoordsXY{ 0, 0 },
CoordsXY{ -kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, -kCoordsXYStep },
CoordsXY{ 0, -kCoordsXYStep },
CoordsXY{ -kCoordsXYStep, -kCoordsXYStep },
};
void JumpingFountain::Update()
{
NumTicksAlive++;
// Originally this would not update the frame on the following
// ticks: 1, 3, 6, 9, 11, 14, 17, 19, 22, 25
// This change was to simplify the code base. There is a small increase
// in speed of the fountain jump because of this change.
if (NumTicksAlive % 3 == 0)
static constexpr std::array _fountainDirectionsPositive = {
CoordsXY{ kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, kCoordsXYStep },
CoordsXY{ kCoordsXYStep, 0 },
CoordsXY{ 0, 0 },
CoordsXY{ 0, kCoordsXYStep },
};
static constexpr auto kFountainChanceOfStoppingEdgeMode = 0x3333; // 0.200
static constexpr auto kFountainChanceOfStoppingRandomMode = 0x2000; // 0.125
// rct2: 0x0097F040
const uint8_t _fountainDirections[] = {
0, 1, 2, 3, 0, 1, 2, 3,
};
// rct2: 0x0097F048
const FountainFlags _fountainDirectionFlags[] = {
{}, {}, FountainFlag::direction, FountainFlag::direction, FountainFlag::direction, FountainFlag::direction, {}, {},
};
// rct2: 0x0097F050
const FountainFlags _fountainPatternFlags[] = {
{ FountainFlag::terminate }, // cyclicSquares
{ FountainFlag::fast, FountainFlag::goToEdge }, // continuousChasers
{ FountainFlag::bounce }, // bouncingPairs
{ FountainFlag::fast, FountainFlag::split }, // sproutingBlooms
{ FountainFlag::goToEdge }, // racingPairs
{ FountainFlag::fast, FountainFlag::goToEdge, FountainFlag::split }, // splittingChasers
{}, // dopeyJumpers
{ FountainFlag::fast }, // fastRandomChasers
};
template<>
bool EntityBase::Is<JumpingFountain>() const
{
return;
return Type == EntityType::jumpingFountain;
}
Invalidate();
frame++;
switch (FountainType)
void JumpingFountain::StartAnimation(
const JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement)
{
case JumpingFountainType::Water:
if (frame == 11 && fountainFlags.has(FountainFlag::fast))
{
AdvanceAnimation();
}
if (frame == 16 && !fountainFlags.has(FountainFlag::fast))
{
AdvanceAnimation();
}
break;
case JumpingFountainType::Snow:
if (frame == 16)
{
AdvanceAnimation();
}
break;
default:
break;
}
const auto currentTicks = getGameState().currentTicks;
if (frame == 16)
{
getGameState().entities.EntityRemove(this);
}
}
int32_t randomIndex;
auto newZ = tileElement->GetBaseZ();
JumpingFountainType JumpingFountain::GetType() const
{
return FountainType;
}
void JumpingFountain::AdvanceAnimation()
{
const JumpingFountainType newType = GetType();
const int32_t direction = (Orientation >> 3) & 7;
const CoordsXY newLoc = CoordsXY{ x, y } + CoordsDirectionDelta[direction];
int32_t availableDirections = 0;
for (uint32_t i = 0; i < _fountainDirectionsNegative.size(); i++)
{
if (IsJumpingFountain(newType, { newLoc + _fountainDirectionsNegative[i], z }))
// Change pattern approximately every 51 seconds
uint32_t pattern = (currentTicks >> 11) & 7;
switch (static_cast<Pattern>(pattern))
{
availableDirections |= 1 << i;
case Pattern::cyclicSquares:
// 0, 1, 2, 3
for (int32_t i = 0; i < kNumOrthogonalDirections; i++)
{
Create(
newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i],
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
}
break;
case Pattern::bouncingPairs:
// random [0, 2 or 1, 3]
randomIndex = ScenarioRand() & 1;
for (int32_t i = randomIndex; i < kNumOrthogonalDirections; i += 2)
{
Create(
newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i],
_fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0);
}
break;
case Pattern::racingPairs:
// random [0 - 3 and 4 - 7]
randomIndex = ScenarioRand() & 3;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
randomIndex += 4;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
break;
default:
// random [0 - 7]
randomIndex = ScenarioRand() & 7;
Create(
newType, { newLoc + _fountainDirectionsPositive[randomIndex], newZ }, _fountainDirections[randomIndex],
_fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0);
break;
}
}
if (availableDirections == 0)
void JumpingFountain::Create(
const JumpingFountainType newType, const CoordsXYZ& newLoc, const int32_t direction, const FountainFlags newFlags,
const int32_t iteration)
{
return;
auto* jumpingFountain = getGameState().entities.CreateEntity<JumpingFountain>();
if (jumpingFountain != nullptr)
{
jumpingFountain->Iteration = iteration;
jumpingFountain->fountainFlags = newFlags;
jumpingFountain->Orientation = direction << 3;
jumpingFountain->SpriteData.Width = 33;
jumpingFountain->SpriteData.HeightMin = 36;
jumpingFountain->SpriteData.HeightMax = 12;
jumpingFountain->MoveTo(newLoc);
jumpingFountain->FountainType = newType;
jumpingFountain->NumTicksAlive = 0;
jumpingFountain->frame = 0;
}
}
if (fountainFlags.has(FountainFlag::terminate))
void JumpingFountain::Update()
{
return;
NumTicksAlive++;
// Originally this would not update the frame on the following
// ticks: 1, 3, 6, 9, 11, 14, 17, 19, 22, 25
// This change was to simplify the code base. There is a small increase
// in speed of the fountain jump because of this change.
if (NumTicksAlive % 3 == 0)
{
return;
}
Invalidate();
frame++;
switch (FountainType)
{
case JumpingFountainType::Water:
if (frame == 11 && fountainFlags.has(FountainFlag::fast))
{
AdvanceAnimation();
}
if (frame == 16 && !fountainFlags.has(FountainFlag::fast))
{
AdvanceAnimation();
}
break;
case JumpingFountainType::Snow:
if (frame == 16)
{
AdvanceAnimation();
}
break;
default:
break;
}
if (frame == 16)
{
getGameState().entities.EntityRemove(this);
}
}
if (fountainFlags.has(FountainFlag::goToEdge))
JumpingFountainType JumpingFountain::GetType() const
{
GoToEdge({ newLoc, z }, availableDirections);
return;
return FountainType;
}
if (fountainFlags.has(FountainFlag::bounce))
void JumpingFountain::AdvanceAnimation()
{
Bounce({ newLoc, z }, availableDirections);
return;
const JumpingFountainType newType = GetType();
const int32_t direction = (Orientation >> 3) & 7;
const CoordsXY newLoc = CoordsXY{ x, y } + CoordsDirectionDelta[direction];
int32_t availableDirections = 0;
for (uint32_t i = 0; i < _fountainDirectionsNegative.size(); i++)
{
if (IsJumpingFountain(newType, { newLoc + _fountainDirectionsNegative[i], z }))
{
availableDirections |= 1 << i;
}
}
if (availableDirections == 0)
{
return;
}
if (fountainFlags.has(FountainFlag::terminate))
{
return;
}
if (fountainFlags.has(FountainFlag::goToEdge))
{
GoToEdge({ newLoc, z }, availableDirections);
return;
}
if (fountainFlags.has(FountainFlag::bounce))
{
Bounce({ newLoc, z }, availableDirections);
return;
}
if (fountainFlags.has(FountainFlag::split))
{
Split({ newLoc, z }, availableDirections);
return;
}
Random({ newLoc, z }, availableDirections);
}
if (fountainFlags.has(FountainFlag::split))
bool JumpingFountain::IsJumpingFountain(const JumpingFountainType newType, const CoordsXYZ& newLoc)
{
Split({ newLoc, z }, availableDirections);
return;
}
const int32_t pathAdditionFlagMask = newType == JumpingFountainType::Snow ? PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW
: PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER;
Random({ newLoc, z }, availableDirections);
}
TileElement* tileElement = MapGetFirstElementAt(newLoc);
if (tileElement == nullptr)
return false;
do
{
if (tileElement->GetType() != TileElementType::Path)
continue;
if (tileElement->GetBaseZ() != newLoc.z)
continue;
if (tileElement->AsPath()->AdditionIsGhost())
continue;
if (!tileElement->AsPath()->HasAddition())
continue;
bool JumpingFountain::IsJumpingFountain(const JumpingFountainType newType, const CoordsXYZ& newLoc)
{
const int32_t pathAdditionFlagMask = newType == JumpingFountainType::Snow ? PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_SNOW
: PATH_ADDITION_FLAG_JUMPING_FOUNTAIN_WATER;
auto* pathAdditionEntry = tileElement->AsPath()->GetAdditionEntry();
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & pathAdditionFlagMask)
{
return true;
}
} while (!(tileElement++)->IsLastForTile());
TileElement* tileElement = MapGetFirstElementAt(newLoc);
if (tileElement == nullptr)
return false;
do
{
if (tileElement->GetType() != TileElementType::Path)
continue;
if (tileElement->GetBaseZ() != newLoc.z)
continue;
if (tileElement->AsPath()->AdditionIsGhost())
continue;
if (!tileElement->AsPath()->HasAddition())
continue;
auto* pathAdditionEntry = tileElement->AsPath()->GetAdditionEntry();
if (pathAdditionEntry != nullptr && pathAdditionEntry->flags & pathAdditionFlagMask)
{
return true;
}
} while (!(tileElement++)->IsLastForTile());
return false;
}
void JumpingFountain::GoToEdge(const CoordsXYZ& newLoc, const int32_t availableDirections) const
{
int32_t direction = (Orientation >> 3) << 1;
if (availableDirections & (1 << direction))
{
CreateNext(newLoc, direction);
return;
}
direction++;
if (availableDirections & (1 << direction))
void JumpingFountain::GoToEdge(const CoordsXYZ& newLoc, const int32_t availableDirections) const
{
CreateNext(newLoc, direction);
return;
}
const uint32_t randomIndex = ScenarioRand();
if ((randomIndex & 0xFFFF) < kFountainChanceOfStoppingEdgeMode)
{
return;
}
if (fountainFlags.has(FountainFlag::split))
{
Split(newLoc, availableDirections);
return;
}
direction = randomIndex & 7;
while (!(availableDirections & (1 << direction)))
{
direction = (direction + 1) & 7;
}
CreateNext(newLoc, direction);
}
void JumpingFountain::Bounce(const CoordsXYZ& newLoc, const int32_t availableDirections)
{
Iteration++;
if (Iteration < 8)
{
int32_t direction = ((Orientation >> 3) ^ 2) << 1;
int32_t direction = (Orientation >> 3) << 1;
if (availableDirections & (1 << direction))
{
CreateNext(newLoc, direction);
return;
}
else
direction++;
if (availableDirections & (1 << direction))
{
direction++;
if (availableDirections & (1 << direction))
{
CreateNext(newLoc, direction);
}
CreateNext(newLoc, direction);
return;
}
}
}
void JumpingFountain::Split(const CoordsXYZ& newLoc, int32_t availableDirections) const
{
if (Iteration < 3)
{
const auto newType = GetType();
int32_t direction = ((Orientation >> 3) ^ 2) << 1;
availableDirections &= ~(1 << direction);
availableDirections &= ~(1 << (direction + 1));
for (direction = 0; direction < 8; direction++)
const uint32_t randomIndex = ScenarioRand();
if ((randomIndex & 0xFFFF) < kFountainChanceOfStoppingEdgeMode)
{
if (availableDirections & (1 << direction))
{
auto copiedFlags = fountainFlags;
copiedFlags.unset(FountainFlag::direction);
Create(newType, newLoc, direction >> 1, copiedFlags, Iteration + 1);
}
direction++;
if (availableDirections & (1 << direction))
{
auto copiedFlags = fountainFlags;
copiedFlags.set(FountainFlag::direction);
Create(newType, newLoc, direction >> 1, copiedFlags, Iteration + 1);
}
return;
}
}
}
void JumpingFountain::Random(const CoordsXYZ& newLoc, int32_t availableDirections) const
{
const uint32_t randomIndex = ScenarioRand();
if ((randomIndex & 0xFFFF) >= kFountainChanceOfStoppingRandomMode)
{
int32_t direction = randomIndex & 7;
if (fountainFlags.has(FountainFlag::split))
{
Split(newLoc, availableDirections);
return;
}
direction = randomIndex & 7;
while (!(availableDirections & (1 << direction)))
{
direction = (direction + 1) & 7;
}
CreateNext(newLoc, direction);
}
}
void JumpingFountain::CreateNext(const CoordsXYZ& newLoc, int32_t direction) const
{
const auto newType = GetType();
auto newFlags = fountainFlags;
newFlags.set(FountainFlag::direction, !!(direction & 1));
Create(newType, newLoc, direction >> 1, newFlags, Iteration);
}
void JumpingFountain::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << FountainType;
stream << NumTicksAlive;
stream << fountainFlags.holder;
stream << TargetX;
stream << TargetY;
stream << Iteration;
}
void JumpingFountain::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Move into SpriteIds.h
constexpr uint32_t kJumpingFountainSnowBaseImage = 23037;
constexpr uint32_t kJumpingFountainWaterBaseImage = 22973;
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
void JumpingFountain::Bounce(const CoordsXYZ& newLoc, const int32_t availableDirections)
{
return;
Iteration++;
if (Iteration < 8)
{
int32_t direction = ((Orientation >> 3) ^ 2) << 1;
if (availableDirections & (1 << direction))
{
CreateNext(newLoc, direction);
}
else
{
direction++;
if (availableDirections & (1 << direction))
{
CreateNext(newLoc, direction);
}
}
}
}
uint16_t height = z + 6;
imageDirection = imageDirection / 8;
// Fountain is firing anti clockwise
bool reversed = fountainFlags.has(FountainFlag::direction);
// Fountain rotation
bool rotated = (Orientation / 16) & 1;
bool isAntiClockwise = (imageDirection / 2) & 1; // Clockwise or Anti-clockwise
// These cancel each other out
if (reversed != rotated)
void JumpingFountain::Split(const CoordsXYZ& newLoc, int32_t availableDirections) const
{
isAntiClockwise = !isAntiClockwise;
if (Iteration < 3)
{
const auto newType = GetType();
int32_t direction = ((Orientation >> 3) ^ 2) << 1;
availableDirections &= ~(1 << direction);
availableDirections &= ~(1 << (direction + 1));
for (direction = 0; direction < 8; direction++)
{
if (availableDirections & (1 << direction))
{
auto copiedFlags = fountainFlags;
copiedFlags.unset(FountainFlag::direction);
Create(newType, newLoc, direction >> 1, copiedFlags, Iteration + 1);
}
direction++;
if (availableDirections & (1 << direction))
{
auto copiedFlags = fountainFlags;
copiedFlags.set(FountainFlag::direction);
Create(newType, newLoc, direction >> 1, copiedFlags, Iteration + 1);
}
}
}
}
uint32_t baseImageId = (FountainType == JumpingFountainType::Snow) ? kJumpingFountainSnowBaseImage
: kJumpingFountainWaterBaseImage;
auto imageId = ImageId(baseImageId + imageDirection * 16 + frame);
constexpr std::array antiClockWiseBoundingBoxes = {
CoordsXY{ -kCoordsXYStep, -3 },
CoordsXY{ 0, -3 },
};
constexpr std::array clockWiseBoundingBoxes = {
CoordsXY{ -kCoordsXYStep, 3 },
CoordsXY{ 0, 3 },
};
void JumpingFountain::Random(const CoordsXYZ& newLoc, int32_t availableDirections) const
{
const uint32_t randomIndex = ScenarioRand();
if ((randomIndex & 0xFFFF) >= kFountainChanceOfStoppingRandomMode)
{
int32_t direction = randomIndex & 7;
while (!(availableDirections & (1 << direction)))
{
direction = (direction + 1) & 7;
}
CreateNext(newLoc, direction);
}
}
auto bb = isAntiClockwise ? antiClockWiseBoundingBoxes : clockWiseBoundingBoxes;
void JumpingFountain::CreateNext(const CoordsXYZ& newLoc, int32_t direction) const
{
const auto newType = GetType();
auto newFlags = fountainFlags;
newFlags.set(FountainFlag::direction, !!(direction & 1));
Create(newType, newLoc, direction >> 1, newFlags, Iteration);
}
PaintAddImageAsParentRotated(
session, imageDirection, imageId, { 0, 0, height }, { { bb[imageDirection & 1], height }, { 32, 1, 3 } });
}
void JumpingFountain::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << FountainType;
stream << NumTicksAlive;
stream << fountainFlags.holder;
stream << TargetX;
stream << TargetY;
stream << Iteration;
}
void JumpingFountain::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// TODO: Move into SpriteIds.h
constexpr uint32_t kJumpingFountainSnowBaseImage = 23037;
constexpr uint32_t kJumpingFountainWaterBaseImage = 22973;
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
{
return;
}
uint16_t height = z + 6;
imageDirection = imageDirection / 8;
// Fountain is firing anti clockwise
bool reversed = fountainFlags.has(FountainFlag::direction);
// Fountain rotation
bool rotated = (Orientation / 16) & 1;
bool isAntiClockwise = (imageDirection / 2) & 1; // Clockwise or Anti-clockwise
// These cancel each other out
if (reversed != rotated)
{
isAntiClockwise = !isAntiClockwise;
}
uint32_t baseImageId = (FountainType == JumpingFountainType::Snow) ? kJumpingFountainSnowBaseImage
: kJumpingFountainWaterBaseImage;
auto imageId = ImageId(baseImageId + imageDirection * 16 + frame);
constexpr std::array antiClockWiseBoundingBoxes = {
CoordsXY{ -kCoordsXYStep, -3 },
CoordsXY{ 0, -3 },
};
constexpr std::array clockWiseBoundingBoxes = {
CoordsXY{ -kCoordsXYStep, 3 },
CoordsXY{ 0, 3 },
};
auto bb = isAntiClockwise ? antiClockWiseBoundingBoxes : clockWiseBoundingBoxes;
PaintAddImageAsParentRotated(
session, imageDirection, imageId, { 0, 0, height }, { { bb[imageDirection & 1], height }, { 32, 1, 3 } });
}
} // namespace OpenRCT2
+35 -36
View File
@@ -31,40 +31,39 @@ namespace OpenRCT2
using FountainFlags = FlagHolder<uint8_t, FountainFlag>;
struct TileElement;
enum class JumpingFountainType : uint8_t
{
Water,
Snow
};
struct JumpingFountain : EntityBase
{
static constexpr auto cEntityType = EntityType::jumpingFountain;
uint16_t frame;
JumpingFountainType FountainType;
uint8_t NumTicksAlive;
FountainFlags fountainFlags;
int16_t TargetX;
int16_t TargetY;
uint16_t Iteration;
void Update();
static void StartAnimation(JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement);
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
private:
JumpingFountainType GetType() const;
void AdvanceAnimation();
void GoToEdge(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void Bounce(const CoordsXYZ& newLoc, int32_t availableDirections);
void Split(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void Random(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void CreateNext(const CoordsXYZ& newLoc, int32_t direction) const;
static void Create(
JumpingFountainType newType, const CoordsXYZ& newLoc, int32_t direction, FountainFlags newFlags, int32_t iteration);
static bool IsJumpingFountain(JumpingFountainType newType, const CoordsXYZ& newLoc);
};
} // namespace OpenRCT2
enum class JumpingFountainType : uint8_t
{
Water,
Snow
};
struct JumpingFountain : EntityBase
{
static constexpr auto cEntityType = EntityType::jumpingFountain;
uint16_t frame;
JumpingFountainType FountainType;
uint8_t NumTicksAlive;
OpenRCT2::FountainFlags fountainFlags;
int16_t TargetX;
int16_t TargetY;
uint16_t Iteration;
void Update();
static void StartAnimation(JumpingFountainType newType, const CoordsXY& newLoc, const OpenRCT2::TileElement* tileElement);
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
private:
JumpingFountainType GetType() const;
void AdvanceAnimation();
void GoToEdge(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void Bounce(const CoordsXYZ& newLoc, int32_t availableDirections);
void Split(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void Random(const CoordsXYZ& newLoc, int32_t availableDirections) const;
void CreateNext(const CoordsXYZ& newLoc, int32_t direction) const;
static void Create(
JumpingFountainType newType, const CoordsXYZ& newLoc, int32_t direction, OpenRCT2::FountainFlags newFlags,
int32_t iteration);
static bool IsJumpingFountain(JumpingFountainType newType, const CoordsXYZ& newLoc);
};
+7357 -7346
View File
File diff suppressed because it is too large. Load diff
+424 -419
View File
@@ -15,452 +15,457 @@
#include "../ride/ShopItem.h"
#include "Peep.h"
constexpr int8_t kPeepMaxThoughts = 5;
constexpr int8_t kPeepHungerWarningThreshold = 25;
constexpr int8_t kPeepThirstWarningThreshold = 25;
constexpr int8_t kPeepToiletWarningThreshold = 28;
constexpr int8_t kPeepLitterWarningThreshold = 23;
constexpr int8_t kPeepDisgustWarningThreshold = 22;
constexpr int8_t kPeepVandalismWarningThreshold = 15;
constexpr int8_t kPeepNoExitWarningThreshold = 8;
constexpr int8_t kPeepLostWarningThreshold = 8;
constexpr int8_t kPeepTooLongQueueThreshold = 25;
constexpr int kPeepMaxHappiness = 255;
constexpr int kPeepMaxHunger = 255;
constexpr int16_t kPeepMaxToilet = 255;
constexpr int16_t kPeepMaxNausea = 255;
constexpr int kPeepMaxThirst = 255;
enum class PeepThoughtType : uint8_t
{
CantAffordRide = 0, // "I can't afford"
SpentMoney = 1, // "I've spent all my money"
Sick = 2, // "I feel sick"
VerySick = 3, // "I feel very sick"
MoreThrilling = 4, // "I want to go on something more thrilling than X"
Intense = 5, // "X looks too intense for me"
HaventFinished = 6, // "I haven't finished my X yet"
Sickening = 7, // "Just looking at X makes me feel sick"
BadValue = 8, // "I'm not paying that much to go on X"
GoHome = 9, // "I want to go home"
GoodValue = 10, // "X is really good value"
AlreadyGot = 11, // "I've already got"
CantAffordItem = 12, // "I can't afford"
NotHungry = 13, // "I'm not hungry"
NotThirsty = 14, // "I'm not thirsty"
Drowning = 15, // "Help! I'm drowning!"
Lost = 16, // "I'm lost!"
WasGreat = 17, // "X was great"
QueuingAges = 18, // "I've been queuing for X for ages"
Tired = 19, // "I'm tired"
Hungry = 20, // "I'm hungry"
Thirsty = 21, // "I'm thirsty"
Toilet = 22, // "I need to go to the toilet"
CantFind = 23, // "I can't find X"
NotPaying = 24, // "I'm not paying that much to use X"
NotWhileRaining = 25, // "I'm not going on X while it's raining"
BadLitter = 26, // "The litter here is really bad"
CantFindExit = 27, // "I can't find the exit"
GetOff = 28, // "I want to get off X"
GetOut = 29, // "I want to get out of X"
NotSafe = 30, // "I'm not going on X - it isn't safe"
PathDisgusting = 31, // "This path is disgusting"
Crowded = 32, // "It's too crowded here"
Vandalism = 33, // "The vandalism here is really bad"
Scenery = 34, // "Great scenery!"
VeryClean = 35, // "This park is very clean and tidy"
Fountains = 36, // "The jumping fountains are great"
Music = 37, // "The music is nice here"
Balloon = 38, // "This balloon from X is really good value"
Toy = 39, // "This cuddly toy from X is really good value"
Map = 40,
Photo = 41, // "This on ride photo from X is really good value"
Umbrella = 42,
Drink = 43,
Burger = 44,
Chips = 45,
IceCream = 46,
Candyfloss = 47,
Pizza = 51,
Popcorn = 53,
HotDog = 54,
Tentacle = 55,
Hat = 56,
ToffeeApple = 57,
Tshirt = 58,
Doughnut = 59,
Coffee = 60,
Chicken = 62,
Lemonade = 63,
Wow = 67, // "Wow!"
Wow2 = 70, // "Wow!"
Watched = 71, // "I have the strangest feeling someone is watching me"
BalloonMuch = 72, // "I'm not paying that much to get a balloon from X"
ToyMuch = 73,
MapMuch = 74,
PhotoMuch = 75,
UmbrellaMuch = 76,
DrinkMuch = 77,
BurgerMuch = 78,
ChipsMuch = 79,
IceCreamMuch = 80,
CandyflossMuch = 81,
PizzaMuch = 85,
PopcornMuch = 87,
HotDogMuch = 88,
TentacleMuch = 89,
HatMuch = 90,
ToffeeAppleMuch = 91,
TshirtMuch = 92,
DoughnutMuch = 93,
CoffeeMuch = 94,
ChickenMuch = 96,
LemonadeMuch = 97,
Photo2 = 104, // "This on-ride photo from X is really good value"
Photo3 = 105,
Photo4 = 106,
Pretzel = 107,
HotChocolate = 108,
IcedTea = 109,
FunnelCake = 110,
Sunglasses = 111,
BeefNoodles = 112,
FriedRiceNoodles = 113,
WontonSoup = 114,
MeatballSoup = 115,
FruitJuice = 116,
SoybeanMilk = 117,
Sujongkwa = 118,
SubSandwich = 119,
Cookie = 120,
RoastSausage = 124,
Photo2Much = 136,
Photo3Much = 137,
Photo4Much = 138,
PretzelMuch = 139,
HotChocolateMuch = 140,
IcedTeaMuch = 141,
FunnelCakeMuch = 142,
SunglassesMuch = 143,
BeefNoodlesMuch = 144,
FriedRiceNoodlesMuch = 145,
WontonSoupMuch = 146,
MeatballSoupMuch = 147,
FruitJuiceMuch = 148,
SoybeanMilkMuch = 149,
SujongkwaMuch = 150,
SubSandwichMuch = 151,
CookieMuch = 152,
RoastSausageMuch = 156,
Help = 168, // "Help! Put me down!"
RunningOut = 169, // "I'm running out of cash!"
NewRide = 170, // "Wow! A new ride being built!"
NiceRideDeprecated = 171, // "Nice ride! But not as good as the Phoenix..."
ExcitedDeprecated = 172, // "I'm so excited - It's an Intamin ride!"
HereWeAre = 173, // "...and here we are on X!"
None = 255
};
enum class PeepNauseaTolerance : uint8_t
{
None,
Low,
Average,
High
};
static constexpr uint16_t kPeepThoughtItemNone = std::numeric_limits<uint16_t>::max();
struct PeepThought
{
PeepThoughtType type;
union
{
RideId rideId;
ShopItem shopItem;
uint16_t item;
};
uint8_t freshness; // larger is less fresh
uint8_t fresh_timeout; // updates every tick
};
struct Guest;
struct Staff;
struct CarEntry;
struct IntensityRange
namespace OpenRCT2
{
private:
uint8_t _value{};
constexpr int8_t kPeepMaxThoughts = 5;
public:
explicit IntensityRange(uint8_t value)
: _value(value)
constexpr int8_t kPeepHungerWarningThreshold = 25;
constexpr int8_t kPeepThirstWarningThreshold = 25;
constexpr int8_t kPeepToiletWarningThreshold = 28;
constexpr int8_t kPeepLitterWarningThreshold = 23;
constexpr int8_t kPeepDisgustWarningThreshold = 22;
constexpr int8_t kPeepVandalismWarningThreshold = 15;
constexpr int8_t kPeepNoExitWarningThreshold = 8;
constexpr int8_t kPeepLostWarningThreshold = 8;
constexpr int8_t kPeepTooLongQueueThreshold = 25;
constexpr int kPeepMaxHappiness = 255;
constexpr int kPeepMaxHunger = 255;
constexpr int16_t kPeepMaxToilet = 255;
constexpr int16_t kPeepMaxNausea = 255;
constexpr int kPeepMaxThirst = 255;
enum class PeepThoughtType : uint8_t
{
}
CantAffordRide = 0, // "I can't afford"
SpentMoney = 1, // "I've spent all my money"
Sick = 2, // "I feel sick"
VerySick = 3, // "I feel very sick"
MoreThrilling = 4, // "I want to go on something more thrilling than X"
Intense = 5, // "X looks too intense for me"
HaventFinished = 6, // "I haven't finished my X yet"
Sickening = 7, // "Just looking at X makes me feel sick"
BadValue = 8, // "I'm not paying that much to go on X"
GoHome = 9, // "I want to go home"
GoodValue = 10, // "X is really good value"
AlreadyGot = 11, // "I've already got"
CantAffordItem = 12, // "I can't afford"
NotHungry = 13, // "I'm not hungry"
NotThirsty = 14, // "I'm not thirsty"
Drowning = 15, // "Help! I'm drowning!"
Lost = 16, // "I'm lost!"
WasGreat = 17, // "X was great"
QueuingAges = 18, // "I've been queuing for X for ages"
Tired = 19, // "I'm tired"
Hungry = 20, // "I'm hungry"
Thirsty = 21, // "I'm thirsty"
Toilet = 22, // "I need to go to the toilet"
CantFind = 23, // "I can't find X"
NotPaying = 24, // "I'm not paying that much to use X"
NotWhileRaining = 25, // "I'm not going on X while it's raining"
BadLitter = 26, // "The litter here is really bad"
CantFindExit = 27, // "I can't find the exit"
GetOff = 28, // "I want to get off X"
GetOut = 29, // "I want to get out of X"
NotSafe = 30, // "I'm not going on X - it isn't safe"
PathDisgusting = 31, // "This path is disgusting"
Crowded = 32, // "It's too crowded here"
Vandalism = 33, // "The vandalism here is really bad"
Scenery = 34, // "Great scenery!"
VeryClean = 35, // "This park is very clean and tidy"
Fountains = 36, // "The jumping fountains are great"
Music = 37, // "The music is nice here"
Balloon = 38, // "This balloon from X is really good value"
Toy = 39, // "This cuddly toy from X is really good value"
Map = 40,
Photo = 41, // "This on ride photo from X is really good value"
Umbrella = 42,
Drink = 43,
Burger = 44,
Chips = 45,
IceCream = 46,
Candyfloss = 47,
IntensityRange(uint8_t min, uint8_t max)
: _value(std::min<uint8_t>(min, 15) | (std::min<uint8_t>(max, 15) << 4))
{
}
Pizza = 51,
uint8_t GetMinimum() const
{
return _value & 0x0F;
}
Popcorn = 53,
HotDog = 54,
Tentacle = 55,
Hat = 56,
ToffeeApple = 57,
Tshirt = 58,
Doughnut = 59,
Coffee = 60,
uint8_t GetMaximum() const
{
return _value >> 4;
}
Chicken = 62,
Lemonade = 63,
IntensityRange WithMinimum(uint8_t value) const
{
return IntensityRange(value, GetMaximum());
}
Wow = 67, // "Wow!"
IntensityRange WithMaximum(uint8_t value) const
{
return IntensityRange(GetMinimum(), value);
}
Wow2 = 70, // "Wow!"
Watched = 71, // "I have the strangest feeling someone is watching me"
BalloonMuch = 72, // "I'm not paying that much to get a balloon from X"
ToyMuch = 73,
MapMuch = 74,
PhotoMuch = 75,
UmbrellaMuch = 76,
DrinkMuch = 77,
BurgerMuch = 78,
ChipsMuch = 79,
IceCreamMuch = 80,
CandyflossMuch = 81,
explicit operator uint8_t() const
{
return _value;
}
PizzaMuch = 85,
friend bool operator==(const IntensityRange& lhs, const IntensityRange& rhs)
{
return lhs._value == rhs._value;
}
PopcornMuch = 87,
HotDogMuch = 88,
TentacleMuch = 89,
HatMuch = 90,
ToffeeAppleMuch = 91,
TshirtMuch = 92,
DoughnutMuch = 93,
CoffeeMuch = 94,
friend bool operator!=(const IntensityRange& lhs, const IntensityRange& rhs)
{
return lhs._value != rhs._value;
}
};
ChickenMuch = 96,
LemonadeMuch = 97,
struct Guest : Peep
{
static constexpr auto cEntityType = EntityType::guest;
Photo2 = 104, // "This on-ride photo from X is really good value"
Photo3 = 105,
Photo4 = 106,
Pretzel = 107,
HotChocolate = 108,
IcedTea = 109,
FunnelCake = 110,
Sunglasses = 111,
BeefNoodles = 112,
FriedRiceNoodles = 113,
WontonSoup = 114,
MeatballSoup = 115,
FruitJuice = 116,
SoybeanMilk = 117,
Sujongkwa = 118,
SubSandwich = 119,
Cookie = 120,
public:
uint8_t GuestNumRides;
EntityId GuestNextInQueue;
int32_t ParkEntryTime;
RideId GuestHeadingToRideId;
uint8_t GuestIsLostCountdown;
uint8_t GuestTimeOnRide;
money64 PaidToEnter;
money64 PaidOnRides;
money64 PaidOnFood;
money64 PaidOnDrink;
money64 PaidOnSouvenirs;
bool OutsideOfPark;
uint8_t Happiness;
uint8_t HappinessTarget;
uint8_t Nausea;
uint8_t NauseaTarget;
uint8_t Hunger;
uint8_t Thirst;
uint8_t Toilet;
uint8_t TimeToConsume;
IntensityRange Intensity{ 0 };
PeepNauseaTolerance NauseaTolerance;
uint16_t TimeInQueue;
money64 CashInPocket;
money64 CashSpent;
RideId Photo1RideRef;
RideId Photo2RideRef;
RideId Photo3RideRef;
RideId Photo4RideRef;
RoastSausage = 124,
int8_t RejoinQueueTimeout; // whilst waiting for a free vehicle (or pair) in the entrance
RideId PreviousRide;
uint16_t PreviousRideTimeOut;
std::array<PeepThought, kPeepMaxThoughts> Thoughts;
// 0x3F Litter Count split into lots of 3 with time, 0xC0 Time since last recalc
uint8_t LitterCount;
// 0x3F Sick Count split into lots of 3 with time, 0xC0 Time since last recalc
uint8_t DisgustingCount;
uint8_t AmountOfFood;
uint8_t AmountOfDrinks;
uint8_t AmountOfSouvenirs;
uint8_t VandalismSeen; // 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen
uint8_t VoucherType;
union
{
RideId VoucherRideId;
ShopItemIndex VoucherShopItem;
Photo2Much = 136,
Photo3Much = 137,
Photo4Much = 138,
PretzelMuch = 139,
HotChocolateMuch = 140,
IcedTeaMuch = 141,
FunnelCakeMuch = 142,
SunglassesMuch = 143,
BeefNoodlesMuch = 144,
FriedRiceNoodlesMuch = 145,
WontonSoupMuch = 146,
MeatballSoupMuch = 147,
FruitJuiceMuch = 148,
SoybeanMilkMuch = 149,
SujongkwaMuch = 150,
SubSandwichMuch = 151,
CookieMuch = 152,
RoastSausageMuch = 156,
Help = 168, // "Help! Put me down!"
RunningOut = 169, // "I'm running out of cash!"
NewRide = 170, // "Wow! A new ride being built!"
NiceRideDeprecated = 171, // "Nice ride! But not as good as the Phoenix..."
ExcitedDeprecated = 172, // "I'm so excited - It's an Intamin ride!"
HereWeAre = 173, // "...and here we are on X!"
None = 255
};
uint8_t SurroundingsThoughtTimeout;
uint8_t Angriness;
uint8_t TimeLost; // the time the peep has been lost when it reaches 254 generates the lost thought
uint8_t DaysInQueue;
OpenRCT2::Drawing::Colour BalloonColour;
OpenRCT2::Drawing::Colour UmbrellaColour;
OpenRCT2::Drawing::Colour HatColour;
RideId FavouriteRide;
uint8_t FavouriteRideRating;
uint64_t ItemFlags;
void Update();
void Tick128UpdateGuest(uint32_t index);
uint64_t GetFoodOrDrinkFlags() const;
uint64_t GetEmptyContainerFlags() const;
bool HasDrink() const;
bool HasFoodOrDrink() const;
bool HasEmptyContainer() const;
void UpdateAnimationGroup();
bool HeadingForRideOrParkExit() const;
void ReadMap();
bool ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, bool thinking);
void SpendMoney(money64& peep_expend_type, money64 amount, ExpenditureType type);
void SpendMoney(money64 amount, ExpenditureType type);
void SetHasRidden(const Ride& ride);
bool HasRidden(const Ride& ride) const;
void SetHasRiddenRideType(ride_type_t rideType);
bool HasRiddenRideType(ride_type_t rideType) const;
void SetParkEntryTime(int32_t entryTime);
int32_t GetParkEntryTime() const;
void CheckIfLost();
void CheckCantFindRide();
void CheckCantFindExit();
void SetAnimationGroup(PeepAnimationGroup new_sprite_type);
int32_t GetEasterEggNameId() const;
void UpdateEasterEggInteractions();
void InsertNewThought(PeepThoughtType thought_type);
void InsertNewThought(PeepThoughtType thought_type, ShopItem thought_arguments);
void InsertNewThought(PeepThoughtType thought_type, RideId rideId);
void InsertNewThought(PeepThoughtType thought_type, uint16_t thought_arguments);
static Guest* Generate(const CoordsXYZ& coords);
bool UpdateQueuePosition(PeepActionType previous_action);
void RemoveFromQueue();
enum class PeepNauseaTolerance : uint8_t
{
None,
Low,
Average,
High
};
uint64_t GetItemFlags() const;
void SetItemFlags(uint64_t itemFlags);
void RemoveAllItems();
void RemoveItem(ShopItem item);
void GiveItem(ShopItem item);
bool HasItem(ShopItem peepItem) const;
void Serialise(OpenRCT2::DataSerialiser& stream);
static constexpr uint16_t kPeepThoughtItemNone = std::numeric_limits<uint16_t>::max();
// Removes the ride from the guests memory, this includes
// the history, thoughts, etc.
void RemoveRideFromMemory(RideId rideId);
void HandleEasterEggName();
void ChoseNotToGoOnRide(const Ride& ride, bool peepAtRide, bool updateLastRide);
void OnEnterRide(Ride& ride);
void OnExitRide(Ride& ride);
void ThrowUp();
struct PeepThought
{
PeepThoughtType type;
union
{
RideId rideId;
ShopItem shopItem;
uint16_t item;
};
uint8_t freshness; // larger is less fresh
uint8_t fresh_timeout; // updates every tick
};
private:
bool ShouldFindBench();
bool UpdateWalkingFindBin();
bool UpdateWalkingFindBench();
void UpdateRide();
void UpdateOnRide() {}; // TODO
void UpdateWalking();
void UpdateQueuing();
void UpdateSitting();
void UpdateEnteringPark();
void UpdateLeavingPark();
void UpdateBuying();
void UpdateWatching();
void UpdateUsingBin();
void UpdateRideAtEntrance();
void UpdateRideAdvanceThroughEntrance();
void UpdateRideLeaveEntranceWaypoints(const Ride& ride);
uint8_t GetWaypointedSeatLocation(const Ride& ride, const CarEntry* vehicle_type, uint8_t track_direction) const;
void UpdateRideFreeVehicleCheck();
void UpdateRideFreeVehicleEnterRide(Ride& ride);
void UpdateRideApproachVehicle();
void UpdateRideEnterVehicle();
void UpdateRideLeaveVehicle();
void UpdateRideApproachExit();
void UpdateRideInExit();
struct Guest;
struct Staff;
void UpdateRideApproachVehicleWaypoints();
struct IntensityRange
{
private:
uint8_t _value{};
void UpdateRideApproachExitWaypoints();
void UpdateRideApproachSpiralSlide();
void UpdateRideOnSpiralSlide();
void UpdateRideLeaveSpiralSlide();
void UpdateRideMazePathfinding();
void UpdateRideLeaveExit();
void UpdateRideShopApproach();
void UpdateRideShopInteract();
void UpdateRideShopLeave();
void UpdateRidePrepareForExit();
void UpdateMotivesIdle();
void UpdateConsumptionMotives();
int32_t CheckEasterEggName(int32_t index) const;
void GivePassingGuestPurpleClothes(Guest& passingPeep);
void GivePassingGuestPizza(Guest& passingPeep);
void MakePassingGuestSick(Guest& passingPeep);
void GivePassingPeepsIceCream(Guest& passingPeep);
void GoToRideEntrance(const Ride& ride);
};
public:
explicit IntensityRange(uint8_t value)
: _value(value)
{
}
void UpdateRideApproachVehicleWaypointsMotionSimulator(Guest&, const CoordsXY&, int16_t&);
void UpdateRideApproachVehicleWaypointsDefault(Guest&, const CoordsXY&, int16_t&);
IntensityRange(uint8_t min, uint8_t max)
: _value(std::min<uint8_t>(min, 15) | (std::min<uint8_t>(max, 15) << 4))
{
}
static_assert(sizeof(Guest) <= 512);
uint8_t GetMinimum() const
{
return _value & 0x0F;
}
enum
{
EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER,
EASTEREGG_PEEP_NAME_JACQUES_VILLENEUVE,
EASTEREGG_PEEP_NAME_DAMON_HILL,
EASTEREGG_PEEP_NAME_MR_BEAN,
EASTEREGG_PEEP_NAME_CHRIS_SAWYER,
EASTEREGG_PEEP_NAME_KATIE_BRAYSHAW,
EASTEREGG_PEEP_NAME_MELANIE_WARN,
EASTEREGG_PEEP_NAME_SIMON_FOSTER,
EASTEREGG_PEEP_NAME_JOHN_WARDLEY,
EASTEREGG_PEEP_NAME_LISA_STIRLING,
EASTEREGG_PEEP_NAME_DONALD_MACRAE,
EASTEREGG_PEEP_NAME_KATHERINE_MCGOWAN,
EASTEREGG_PEEP_NAME_FRANCES_MCGOWAN,
EASTEREGG_PEEP_NAME_CORINA_MASSOURA,
EASTEREGG_PEEP_NAME_CAROL_YOUNG,
EASTEREGG_PEEP_NAME_MIA_SHERIDAN,
EASTEREGG_PEEP_NAME_KATIE_RODGER,
EASTEREGG_PEEP_NAME_EMMA_GARRELL,
EASTEREGG_PEEP_NAME_JOANNE_BARTON,
EASTEREGG_PEEP_NAME_FELICITY_ANDERSON,
EASTEREGG_PEEP_NAME_KATIE_SMITH,
EASTEREGG_PEEP_NAME_EILIDH_BELL,
EASTEREGG_PEEP_NAME_NANCY_STILLWAGON,
EASTEREGG_PEEP_NAME_DAVID_ELLIS
};
uint8_t GetMaximum() const
{
return _value >> 4;
}
void PeepThoughtSetFormatArgs(const PeepThought* thought, OpenRCT2::Formatter& ft);
IntensityRange WithMinimum(uint8_t value) const
{
return IntensityRange(value, GetMaximum());
}
void IncrementGuestsInPark();
void IncrementGuestsHeadingForPark();
void DecrementGuestsInPark();
void DecrementGuestsHeadingForPark();
IntensityRange WithMaximum(uint8_t value) const
{
return IntensityRange(GetMinimum(), value);
}
void PeepUpdateRideLeaveEntranceMaze(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceSpiralSlide(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceDefault(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
explicit operator uint8_t() const
{
return _value;
}
CoordsXY GetGuestWaypointLocationDefault(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
CoordsXY GetGuestWaypointLocationEnterprise(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
friend bool operator==(const IntensityRange& lhs, const IntensityRange& rhs)
{
return lhs._value == rhs._value;
}
friend bool operator!=(const IntensityRange& lhs, const IntensityRange& rhs)
{
return lhs._value != rhs._value;
}
};
struct Guest : Peep
{
static constexpr auto cEntityType = EntityType::guest;
public:
uint8_t GuestNumRides;
EntityId GuestNextInQueue;
int32_t ParkEntryTime;
RideId GuestHeadingToRideId;
uint8_t GuestIsLostCountdown;
uint8_t GuestTimeOnRide;
money64 PaidToEnter;
money64 PaidOnRides;
money64 PaidOnFood;
money64 PaidOnDrink;
money64 PaidOnSouvenirs;
bool OutsideOfPark;
uint8_t Happiness;
uint8_t HappinessTarget;
uint8_t Nausea;
uint8_t NauseaTarget;
uint8_t Hunger;
uint8_t Thirst;
uint8_t Toilet;
uint8_t TimeToConsume;
IntensityRange Intensity{ 0 };
PeepNauseaTolerance NauseaTolerance;
uint16_t TimeInQueue;
money64 CashInPocket;
money64 CashSpent;
RideId Photo1RideRef;
RideId Photo2RideRef;
RideId Photo3RideRef;
RideId Photo4RideRef;
int8_t RejoinQueueTimeout; // whilst waiting for a free vehicle (or pair) in the entrance
RideId PreviousRide;
uint16_t PreviousRideTimeOut;
std::array<PeepThought, kPeepMaxThoughts> Thoughts;
// 0x3F Litter Count split into lots of 3 with time, 0xC0 Time since last recalc
uint8_t LitterCount;
// 0x3F Sick Count split into lots of 3 with time, 0xC0 Time since last recalc
uint8_t DisgustingCount;
uint8_t AmountOfFood;
uint8_t AmountOfDrinks;
uint8_t AmountOfSouvenirs;
uint8_t VandalismSeen; // 0xC0 vandalism thought timeout, 0x3F vandalism tiles seen
uint8_t VoucherType;
union
{
RideId VoucherRideId;
ShopItemIndex VoucherShopItem;
};
uint8_t SurroundingsThoughtTimeout;
uint8_t Angriness;
uint8_t TimeLost; // the time the peep has been lost when it reaches 254 generates the lost thought
uint8_t DaysInQueue;
Drawing::Colour BalloonColour;
Drawing::Colour UmbrellaColour;
Drawing::Colour HatColour;
RideId FavouriteRide;
uint8_t FavouriteRideRating;
uint64_t ItemFlags;
void Update();
void Tick128UpdateGuest(uint32_t index);
uint64_t GetFoodOrDrinkFlags() const;
uint64_t GetEmptyContainerFlags() const;
bool HasDrink() const;
bool HasFoodOrDrink() const;
bool HasEmptyContainer() const;
void UpdateAnimationGroup();
bool HeadingForRideOrParkExit() const;
void ReadMap();
bool ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, bool thinking);
void SpendMoney(money64& peep_expend_type, money64 amount, ExpenditureType type);
void SpendMoney(money64 amount, ExpenditureType type);
void SetHasRidden(const Ride& ride);
bool HasRidden(const Ride& ride) const;
void SetHasRiddenRideType(ride_type_t rideType);
bool HasRiddenRideType(ride_type_t rideType) const;
void SetParkEntryTime(int32_t entryTime);
int32_t GetParkEntryTime() const;
void CheckIfLost();
void CheckCantFindRide();
void CheckCantFindExit();
void SetAnimationGroup(PeepAnimationGroup new_sprite_type);
int32_t GetEasterEggNameId() const;
void UpdateEasterEggInteractions();
void InsertNewThought(PeepThoughtType thought_type);
void InsertNewThought(PeepThoughtType thought_type, ShopItem thought_arguments);
void InsertNewThought(PeepThoughtType thought_type, RideId rideId);
void InsertNewThought(PeepThoughtType thought_type, uint16_t thought_arguments);
static Guest* Generate(const CoordsXYZ& coords);
bool UpdateQueuePosition(PeepActionType previous_action);
void RemoveFromQueue();
uint64_t GetItemFlags() const;
void SetItemFlags(uint64_t itemFlags);
void RemoveAllItems();
void RemoveItem(ShopItem item);
void GiveItem(ShopItem item);
bool HasItem(ShopItem peepItem) const;
void Serialise(DataSerialiser& stream);
// Removes the ride from the guests memory, this includes
// the history, thoughts, etc.
void RemoveRideFromMemory(RideId rideId);
void HandleEasterEggName();
void ChoseNotToGoOnRide(const Ride& ride, bool peepAtRide, bool updateLastRide);
void OnEnterRide(Ride& ride);
void OnExitRide(Ride& ride);
void ThrowUp();
private:
bool ShouldFindBench();
bool UpdateWalkingFindBin();
bool UpdateWalkingFindBench();
void UpdateRide();
void UpdateOnRide() {}; // TODO
void UpdateWalking();
void UpdateQueuing();
void UpdateSitting();
void UpdateEnteringPark();
void UpdateLeavingPark();
void UpdateBuying();
void UpdateWatching();
void UpdateUsingBin();
void UpdateRideAtEntrance();
void UpdateRideAdvanceThroughEntrance();
void UpdateRideLeaveEntranceWaypoints(const Ride& ride);
uint8_t GetWaypointedSeatLocation(const Ride& ride, const CarEntry* vehicle_type, uint8_t track_direction) const;
void UpdateRideFreeVehicleCheck();
void UpdateRideFreeVehicleEnterRide(Ride& ride);
void UpdateRideApproachVehicle();
void UpdateRideEnterVehicle();
void UpdateRideLeaveVehicle();
void UpdateRideApproachExit();
void UpdateRideInExit();
void UpdateRideApproachVehicleWaypoints();
void UpdateRideApproachExitWaypoints();
void UpdateRideApproachSpiralSlide();
void UpdateRideOnSpiralSlide();
void UpdateRideLeaveSpiralSlide();
void UpdateRideMazePathfinding();
void UpdateRideLeaveExit();
void UpdateRideShopApproach();
void UpdateRideShopInteract();
void UpdateRideShopLeave();
void UpdateRidePrepareForExit();
void UpdateMotivesIdle();
void UpdateConsumptionMotives();
int32_t CheckEasterEggName(int32_t index) const;
void GivePassingGuestPurpleClothes(Guest& passingPeep);
void GivePassingGuestPizza(Guest& passingPeep);
void MakePassingGuestSick(Guest& passingPeep);
void GivePassingPeepsIceCream(Guest& passingPeep);
void GoToRideEntrance(const Ride& ride);
};
void UpdateRideApproachVehicleWaypointsMotionSimulator(Guest&, const CoordsXY&, int16_t&);
void UpdateRideApproachVehicleWaypointsDefault(Guest&, const CoordsXY&, int16_t&);
static_assert(sizeof(Guest) <= 512);
enum
{
EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER,
EASTEREGG_PEEP_NAME_JACQUES_VILLENEUVE,
EASTEREGG_PEEP_NAME_DAMON_HILL,
EASTEREGG_PEEP_NAME_MR_BEAN,
EASTEREGG_PEEP_NAME_CHRIS_SAWYER,
EASTEREGG_PEEP_NAME_KATIE_BRAYSHAW,
EASTEREGG_PEEP_NAME_MELANIE_WARN,
EASTEREGG_PEEP_NAME_SIMON_FOSTER,
EASTEREGG_PEEP_NAME_JOHN_WARDLEY,
EASTEREGG_PEEP_NAME_LISA_STIRLING,
EASTEREGG_PEEP_NAME_DONALD_MACRAE,
EASTEREGG_PEEP_NAME_KATHERINE_MCGOWAN,
EASTEREGG_PEEP_NAME_FRANCES_MCGOWAN,
EASTEREGG_PEEP_NAME_CORINA_MASSOURA,
EASTEREGG_PEEP_NAME_CAROL_YOUNG,
EASTEREGG_PEEP_NAME_MIA_SHERIDAN,
EASTEREGG_PEEP_NAME_KATIE_RODGER,
EASTEREGG_PEEP_NAME_EMMA_GARRELL,
EASTEREGG_PEEP_NAME_JOANNE_BARTON,
EASTEREGG_PEEP_NAME_FELICITY_ANDERSON,
EASTEREGG_PEEP_NAME_KATIE_SMITH,
EASTEREGG_PEEP_NAME_EILIDH_BELL,
EASTEREGG_PEEP_NAME_NANCY_STILLWAGON,
EASTEREGG_PEEP_NAME_DAVID_ELLIS
};
void PeepThoughtSetFormatArgs(const PeepThought* thought, Formatter& ft);
void IncrementGuestsInPark();
void IncrementGuestsHeadingForPark();
void DecrementGuestsInPark();
void DecrementGuestsHeadingForPark();
void PeepUpdateRideLeaveEntranceMaze(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceSpiralSlide(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceDefault(Guest& peep, Ride& ride, CoordsXYZD& entrance_loc);
CoordsXY GetGuestWaypointLocationDefault(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
CoordsXY GetGuestWaypointLocationEnterprise(
const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
} // namespace OpenRCT2
+155 -154
View File
@@ -15,186 +15,187 @@
#include <sfl/small_vector.hpp>
using namespace OpenRCT2;
template<>
bool EntityBase::Is<Litter>() const
namespace OpenRCT2
{
return Type == EntityType::litter;
}
static bool IsLocationLitterable(const CoordsXYZ& mapPos)
{
if (!MapIsLocationOwned(mapPos))
return false;
TileElement* tileElement = MapGetFirstElementAt(mapPos);
if (tileElement == nullptr)
return false;
do
template<>
bool EntityBase::Is<Litter>() const
{
if (tileElement->GetType() != TileElementType::Path)
continue;
return Type == EntityType::litter;
}
int32_t pathZ = tileElement->GetBaseZ();
if (pathZ < mapPos.z || pathZ >= mapPos.z + kPathClearance)
continue;
return !TileElementIsUnderground(tileElement);
} while (!(tileElement++)->IsLastForTile());
return false;
}
/**
*
* rct2: 0x0067375D
*/
void Litter::Create(const CoordsXYZD& litterPos, Type type)
{
auto& gameState = getGameState();
if (gameState.cheats.disableLittering)
return;
auto offsetLitterPos = litterPos
+ CoordsXY{ CoordsDirectionDelta[litterPos.direction >> 3].x / 8,
CoordsDirectionDelta[litterPos.direction >> 3].y / 8 };
if (!IsLocationLitterable(offsetLitterPos))
return;
if (gameState.entities.GetEntityListCount(EntityType::litter) >= 500)
static bool IsLocationLitterable(const CoordsXYZ& mapPos)
{
Litter* newestLitter = nullptr;
uint32_t newestLitterCreationTick = 0;
for (auto litter : EntityList<Litter>())
if (!MapIsLocationOwned(mapPos))
return false;
TileElement* tileElement = MapGetFirstElementAt(mapPos);
if (tileElement == nullptr)
return false;
do
{
if (newestLitterCreationTick <= litter->creationTick)
if (tileElement->GetType() != TileElementType::Path)
continue;
int32_t pathZ = tileElement->GetBaseZ();
if (pathZ < mapPos.z || pathZ >= mapPos.z + kPathClearance)
continue;
return !TileElementIsUnderground(tileElement);
} while (!(tileElement++)->IsLastForTile());
return false;
}
/**
*
* rct2: 0x0067375D
*/
void Litter::Create(const CoordsXYZD& litterPos, Type type)
{
auto& gameState = getGameState();
if (gameState.cheats.disableLittering)
return;
auto offsetLitterPos = litterPos
+ CoordsXY{ CoordsDirectionDelta[litterPos.direction >> 3].x / 8,
CoordsDirectionDelta[litterPos.direction >> 3].y / 8 };
if (!IsLocationLitterable(offsetLitterPos))
return;
if (gameState.entities.GetEntityListCount(EntityType::litter) >= 500)
{
Litter* newestLitter = nullptr;
uint32_t newestLitterCreationTick = 0;
for (auto litter : EntityList<Litter>())
{
newestLitterCreationTick = litter->creationTick;
newestLitter = litter;
if (newestLitterCreationTick <= litter->creationTick)
{
newestLitterCreationTick = litter->creationTick;
newestLitter = litter;
}
}
if (newestLitter != nullptr)
{
newestLitter->Invalidate();
gameState.entities.EntityRemove(newestLitter);
}
}
if (newestLitter != nullptr)
{
newestLitter->Invalidate();
gameState.entities.EntityRemove(newestLitter);
}
Litter* litter = gameState.entities.CreateEntity<Litter>();
if (litter == nullptr)
return;
litter->Orientation = offsetLitterPos.direction;
litter->SpriteData.Width = 6;
litter->SpriteData.HeightMin = 6;
litter->SpriteData.HeightMax = 3;
litter->SubType = type;
litter->MoveTo(offsetLitterPos);
litter->creationTick = gameState.currentTicks;
}
Litter* litter = gameState.entities.CreateEntity<Litter>();
if (litter == nullptr)
return;
litter->Orientation = offsetLitterPos.direction;
litter->SpriteData.Width = 6;
litter->SpriteData.HeightMin = 6;
litter->SpriteData.HeightMax = 3;
litter->SubType = type;
litter->MoveTo(offsetLitterPos);
litter->creationTick = gameState.currentTicks;
}
/**
*
* rct2: 0x006738E1
*/
void Litter::RemoveAt(const CoordsXYZ& litterPos)
{
// There can be a lot of litter entities on the same tile, avoid heap allocations
// by having the first 512 stored in a small_vector which is on the stack.
sfl::small_vector<Litter*, 512> removals;
for (auto litter : EntityTileList<Litter>(litterPos))
/**
*
* rct2: 0x006738E1
*/
void Litter::RemoveAt(const CoordsXYZ& litterPos)
{
if (abs(litter->z - litterPos.z) <= 16)
// There can be a lot of litter entities on the same tile, avoid heap allocations
// by having the first 512 stored in a small_vector which is on the stack.
sfl::small_vector<Litter*, 512> removals;
for (auto litter : EntityTileList<Litter>(litterPos))
{
if (abs(litter->x - litterPos.x) <= 8 && abs(litter->y - litterPos.y) <= 8)
if (abs(litter->z - litterPos.z) <= 16)
{
removals.push_back(litter);
if (abs(litter->x - litterPos.x) <= 8 && abs(litter->y - litterPos.y) <= 8)
{
removals.push_back(litter);
}
}
}
for (auto* litter : removals)
{
litter->Invalidate();
getGameState().entities.EntityRemove(litter);
}
}
for (auto* litter : removals)
static const StringId litterNames[12] = {
STR_LITTER_VOMIT,
STR_LITTER_VOMIT,
STR_SHOP_ITEM_SINGULAR_EMPTY_CAN,
STR_SHOP_ITEM_SINGULAR_RUBBISH,
STR_SHOP_ITEM_SINGULAR_EMPTY_BURGER_BOX,
STR_SHOP_ITEM_SINGULAR_EMPTY_CUP,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOX,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOTTLE,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOWL_RED,
STR_SHOP_ITEM_SINGULAR_EMPTY_DRINK_CARTON,
STR_SHOP_ITEM_SINGULAR_EMPTY_JUICE_CUP,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOWL_BLUE,
};
StringId Litter::GetName() const
{
litter->Invalidate();
getGameState().entities.EntityRemove(litter);
if (EnumValue(SubType) >= std::size(litterNames))
return kStringIdNone;
return litterNames[EnumValue(SubType)];
}
}
static const StringId litterNames[12] = {
STR_LITTER_VOMIT,
STR_LITTER_VOMIT,
STR_SHOP_ITEM_SINGULAR_EMPTY_CAN,
STR_SHOP_ITEM_SINGULAR_RUBBISH,
STR_SHOP_ITEM_SINGULAR_EMPTY_BURGER_BOX,
STR_SHOP_ITEM_SINGULAR_EMPTY_CUP,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOX,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOTTLE,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOWL_RED,
STR_SHOP_ITEM_SINGULAR_EMPTY_DRINK_CARTON,
STR_SHOP_ITEM_SINGULAR_EMPTY_JUICE_CUP,
STR_SHOP_ITEM_SINGULAR_EMPTY_BOWL_BLUE,
};
uint32_t Litter::GetAge() const
{
return getGameState().currentTicks - creationTick;
}
StringId Litter::GetName() const
{
if (EnumValue(SubType) >= std::size(litterNames))
return kStringIdNone;
return litterNames[EnumValue(SubType)];
}
void Litter::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
uint32_t Litter::GetAge() const
{
return getGameState().currentTicks - creationTick;
}
stream << SubType;
stream << creationTick;
}
void Litter::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
struct LitterSprite
{
uint16_t base_id;
uint8_t direction_mask;
};
stream << SubType;
stream << creationTick;
}
/** rct2: 0x0097EF6C */
static constexpr LitterSprite kLitterSprites[] = {
{ SPR_LITTER_SICK, 0x1 },
{ SPR_LITTER_SICK_ALT, 0x1 },
{ SPR_LITTER_EMPTY_CAN, 0x1 },
{ SPR_LITTER_RUBBISH, 0x1 },
{ SPR_LITTER_EMPTY_BURGER_BOX, 0x1 },
{ SPR_LITTER_EMPTY_CUP, 0x1 },
{ SPR_LITTER_EMPTY_BOX, 0x1 },
{ SPR_LITTER_EMPTY_BOTTLE, 0x1 },
{ SPR_LITTER_EMPTY_BOWL_RED, 0x3 },
{ SPR_LITTER_EMPTY_DRINK_CART, 0x3 },
{ SPR_LITTER_EMPTY_JUICE_CUP, 0x3 },
{ SPR_LITTER_EMPTY_BOWL_BLUE, 0x3 },
};
struct LitterSprite
{
uint16_t base_id;
uint8_t direction_mask;
};
void Litter::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
/** rct2: 0x0097EF6C */
static constexpr LitterSprite kLitterSprites[] = {
{ SPR_LITTER_SICK, 0x1 },
{ SPR_LITTER_SICK_ALT, 0x1 },
{ SPR_LITTER_EMPTY_CAN, 0x1 },
{ SPR_LITTER_RUBBISH, 0x1 },
{ SPR_LITTER_EMPTY_BURGER_BOX, 0x1 },
{ SPR_LITTER_EMPTY_CUP, 0x1 },
{ SPR_LITTER_EMPTY_BOX, 0x1 },
{ SPR_LITTER_EMPTY_BOTTLE, 0x1 },
{ SPR_LITTER_EMPTY_BOWL_RED, 0x3 },
{ SPR_LITTER_EMPTY_DRINK_CART, 0x3 },
{ SPR_LITTER_EMPTY_JUICE_CUP, 0x3 },
{ SPR_LITTER_EMPTY_BOWL_BLUE, 0x3 },
};
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
return; // If zoomed at all no litter drawn
void Litter::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
// litter has no sprite direction so remove that
imageDirection >>= 3;
// Some litter types have only 1 direction so remove
// anything that isn't required.
imageDirection &= kLitterSprites[EnumValue(SubType)].direction_mask;
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
return; // If zoomed at all no litter drawn
uint32_t image_id = imageDirection + kLitterSprites[EnumValue(SubType)].base_id;
// litter has no sprite direction so remove that
imageDirection >>= 3;
// Some litter types have only 1 direction so remove
// anything that isn't required.
imageDirection &= kLitterSprites[EnumValue(SubType)].direction_mask;
uint32_t image_id = imageDirection + kLitterSprites[EnumValue(SubType)].base_id;
// In the following call to PaintAddImageAsParent, we add 4 (instead of 2) to the
// bound_box_offset_z to make sure litter is drawn on top of railways
PaintAddImageAsParent(session, ImageId(image_id), { 0, 0, z }, { { -4, -4, z + 4 }, { 5, 5, -1 } });
}
// In the following call to PaintAddImageAsParent, we add 4 (instead of 2) to the
// bound_box_offset_z to make sure litter is drawn on top of railways
PaintAddImageAsParent(session, ImageId(image_id), { 0, 0, z }, { { -4, -4, z + 4 }, { 5, 5, -1 } });
}
} // namespace OpenRCT2
+27 -27
View File
@@ -19,33 +19,33 @@ struct PaintSession;
namespace OpenRCT2
{
class DataSerialiser;
}
struct Litter : EntityBase
{
enum class Type : uint8_t
struct Litter : EntityBase
{
vomit,
vomitAlt,
emptyCan,
rubbish,
burgerBox,
emptyCup,
emptyBox,
emptyBottle,
emptyBowlRed,
emptyDrinkCarton,
emptyJuiceCup,
emptyBowlBlue,
};
enum class Type : uint8_t
{
vomit,
vomitAlt,
emptyCan,
rubbish,
burgerBox,
emptyCup,
emptyBox,
emptyBottle,
emptyBowlRed,
emptyDrinkCarton,
emptyJuiceCup,
emptyBowlBlue,
};
static constexpr auto cEntityType = EntityType::litter;
Type SubType;
uint32_t creationTick;
static void Create(const CoordsXYZD& litterPos, Type type);
static void RemoveAt(const CoordsXYZ& litterPos);
void Serialise(OpenRCT2::DataSerialiser& stream);
StringId GetName() const;
uint32_t GetAge() const;
void Paint(PaintSession& session, int32_t imageDirection) const;
};
static constexpr auto cEntityType = EntityType::litter;
Type SubType;
uint32_t creationTick;
static void Create(const CoordsXYZD& litterPos, Type type);
static void RemoveAt(const CoordsXYZ& litterPos);
void Serialise(DataSerialiser& stream);
StringId GetName() const;
uint32_t GetAge() const;
void Paint(PaintSession& session, int32_t imageDirection) const;
};
} // namespace OpenRCT2
+167 -166
View File
@@ -24,193 +24,194 @@
#include "../world/Map.h"
#include "EntityRegistry.h"
using namespace OpenRCT2;
static constexpr CoordsXY kMoneyEffectMoveOffset[] = {
{ 1, -1 },
{ 1, 1 },
{ -1, 1 },
{ -1, -1 },
};
template<>
bool EntityBase::Is<MoneyEffect>() const
namespace OpenRCT2
{
return Type == EntityType::moneyEffect;
}
static constexpr CoordsXY kMoneyEffectMoveOffset[] = {
{ 1, -1 },
{ 1, 1 },
{ -1, 1 },
{ -1, -1 },
};
/**
*
* rct2: 0x0067351F
*/
void MoneyEffect::CreateAt(money64 value, const CoordsXYZ& effectPos, bool guestPurchase)
{
if (value == 0.00_GBP)
return;
MoneyEffect* moneyEffect = getGameState().entities.CreateEntity<MoneyEffect>();
if (moneyEffect == nullptr)
return;
moneyEffect->GuestPurchase = (guestPurchase ? 1 : 0);
moneyEffect->MoveTo(effectPos);
moneyEffect->SetValue(value);
}
/**
*
* rct2: 0x0069C5D0
*/
void MoneyEffect::Create(money64 value, const CoordsXYZ& loc)
{
auto offsetLoc = loc;
if (loc.IsNull())
template<>
bool EntityBase::Is<MoneyEffect>() const
{
// If game actions return no valid location of the action we can not use the screen
// coordinates as every client will have different ones.
if (Network::GetMode() != Network::Mode::none)
return Type == EntityType::moneyEffect;
}
/**
*
* rct2: 0x0067351F
*/
void MoneyEffect::CreateAt(money64 value, const CoordsXYZ& effectPos, bool guestPurchase)
{
if (value == 0.00_GBP)
return;
MoneyEffect* moneyEffect = getGameState().entities.CreateEntity<MoneyEffect>();
if (moneyEffect == nullptr)
return;
moneyEffect->GuestPurchase = (guestPurchase ? 1 : 0);
moneyEffect->MoveTo(effectPos);
moneyEffect->SetValue(value);
}
/**
*
* rct2: 0x0069C5D0
*/
void MoneyEffect::Create(money64 value, const CoordsXYZ& loc)
{
auto offsetLoc = loc;
if (loc.IsNull())
{
LOG_WARNING("Attempted to create money effect without a valid location in multiplayer");
return;
// If game actions return no valid location of the action we can not use the screen
// coordinates as every client will have different ones.
if (Network::GetMode() != Network::Mode::none)
{
LOG_WARNING("Attempted to create money effect without a valid location in multiplayer");
return;
}
WindowBase* mainWindow = WindowGetMain();
if (mainWindow == nullptr)
return;
Viewport* mainViewport = WindowGetViewport(mainWindow);
auto mapPositionXY = ScreenGetMapXY(
{ mainViewport->pos.x + (mainViewport->width / 2), mainViewport->pos.y + (mainViewport->height / 2) }, nullptr);
if (!mapPositionXY.has_value())
return;
offsetLoc = { mapPositionXY.value(), TileElementHeight(*mapPositionXY) };
}
WindowBase* mainWindow = WindowGetMain();
if (mainWindow == nullptr)
return;
Viewport* mainViewport = WindowGetViewport(mainWindow);
auto mapPositionXY = ScreenGetMapXY(
{ mainViewport->pos.x + (mainViewport->width / 2), mainViewport->pos.y + (mainViewport->height / 2) }, nullptr);
if (!mapPositionXY.has_value())
return;
offsetLoc = { mapPositionXY.value(), TileElementHeight(*mapPositionXY) };
offsetLoc.z += 10;
CreateAt(-value, offsetLoc, false);
}
offsetLoc.z += 10;
CreateAt(-value, offsetLoc, false);
}
/**
* Set the value of the money effect
*/
void MoneyEffect::SetValue(money64 value)
{
Value = value;
SpriteData.Width = 64;
SpriteData.HeightMin = 20;
SpriteData.HeightMax = 30;
MoveDelay = 0;
NumMovements = 0;
int16_t offsetX = 0;
if (!gOpenRCT2NoGraphics)
/**
* Set the value of the money effect
*/
void MoneyEffect::SetValue(money64 value)
{
auto [stringId, newValue] = GetStringId();
char buffer[128];
FormatStringLegacy(buffer, 128, stringId, &newValue);
offsetX = -(GfxGetStringWidth(buffer, FontStyle::medium) / 2);
}
OffsetX = offsetX;
Wiggle = 0;
}
Value = value;
SpriteData.Width = 64;
SpriteData.HeightMin = 20;
SpriteData.HeightMax = 30;
MoveDelay = 0;
NumMovements = 0;
/**
*
* rct2: 0x00673232
*/
void MoneyEffect::Update()
{
Wiggle++;
if (Wiggle >= 22)
{
int16_t offsetX = 0;
if (!gOpenRCT2NoGraphics)
{
auto [stringId, newValue] = GetStringId();
char buffer[128];
FormatStringLegacy(buffer, 128, stringId, &newValue);
offsetX = -(GfxGetStringWidth(buffer, FontStyle::medium) / 2);
}
OffsetX = offsetX;
Wiggle = 0;
}
MoveDelay++;
if (MoveDelay < 2)
/**
*
* rct2: 0x00673232
*/
void MoneyEffect::Update()
{
return;
Wiggle++;
if (Wiggle >= 22)
{
Wiggle = 0;
}
MoveDelay++;
if (MoveDelay < 2)
{
return;
}
int32_t newX = x;
int32_t newY = y;
int32_t newZ = z;
MoveDelay = 0;
if (GuestPurchase)
{
newZ += 1;
}
newY += kMoneyEffectMoveOffset[GetCurrentRotation()].y;
newX += kMoneyEffectMoveOffset[GetCurrentRotation()].x;
MoveTo({ newX, newY, newZ });
NumMovements++;
if (NumMovements < 55)
{
return;
}
getGameState().entities.EntityRemove(this);
}
int32_t newX = x;
int32_t newY = y;
int32_t newZ = z;
MoveDelay = 0;
if (GuestPurchase)
std::pair<StringId, money64> MoneyEffect::GetStringId() const
{
newZ += 1;
}
newY += kMoneyEffectMoveOffset[GetCurrentRotation()].y;
newX += kMoneyEffectMoveOffset[GetCurrentRotation()].x;
StringId spentStringId = GuestPurchase ? STR_MONEY_EFFECT_SPEND_HIGHP : STR_MONEY_EFFECT_SPEND;
StringId receiveStringId = GuestPurchase ? STR_MONEY_EFFECT_RECEIVE_HIGHP : STR_MONEY_EFFECT_RECEIVE;
StringId stringId = receiveStringId;
money64 outValue = Value;
if (Value < 0)
{
outValue *= -1;
stringId = spentStringId;
}
MoveTo({ newX, newY, newZ });
NumMovements++;
if (NumMovements < 55)
{
return;
return std::make_pair(stringId, outValue);
}
getGameState().entities.EntityRemove(this);
}
std::pair<StringId, money64> MoneyEffect::GetStringId() const
{
StringId spentStringId = GuestPurchase ? STR_MONEY_EFFECT_SPEND_HIGHP : STR_MONEY_EFFECT_SPEND;
StringId receiveStringId = GuestPurchase ? STR_MONEY_EFFECT_RECEIVE_HIGHP : STR_MONEY_EFFECT_RECEIVE;
StringId stringId = receiveStringId;
money64 outValue = Value;
if (Value < 0)
void MoneyEffect::Serialise(DataSerialiser& stream)
{
outValue *= -1;
stringId = spentStringId;
EntityBase::Serialise(stream);
stream << frame;
stream << MoveDelay;
stream << NumMovements;
stream << GuestPurchase;
stream << Value;
stream << OffsetX;
stream << Wiggle;
}
return std::make_pair(stringId, outValue);
}
void MoneyEffect::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << MoveDelay;
stream << NumMovements;
stream << GuestPurchase;
stream << Value;
stream << OffsetX;
stream << Wiggle;
}
void MoneyEffect::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
if (gLegacyScene == LegacyScene::titleSequence)
void MoneyEffect::Paint(PaintSession& session, int32_t imageDirection) const
{
// Don't render any money in the title screen.
return;
PROFILED_FUNCTION();
if (gLegacyScene == LegacyScene::titleSequence)
{
// Don't render any money in the title screen.
return;
}
if (GuestPurchase && !Config::Get().general.showGuestPurchases)
{
// Don't show the money effect for guest purchases when the option is disabled.
return;
}
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
{
return;
}
/** rct2: 0x0097EDA4 */
static constexpr int8_t waveOffset[] = {
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1,
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1,
};
auto [stringId, value] = GetStringId();
PaintFloatingMoneyEffect(
session, value, stringId, y, z, const_cast<int8_t*>(&waveOffset[Wiggle % 22]), OffsetX, session.CurrentRotation);
}
if (GuestPurchase && !Config::Get().general.showGuestPurchases)
{
// Don't show the money effect for guest purchases when the option is disabled.
return;
}
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
{
return;
}
/** rct2: 0x0097EDA4 */
static constexpr int8_t waveOffset[] = {
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1,
0, 1, 2, 2, 3, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -2, -1,
};
auto [stringId, value] = GetStringId();
PaintFloatingMoneyEffect(
session, value, stringId, y, z, const_cast<int8_t*>(&waveOffset[Wiggle % 22]), OffsetX, session.CurrentRotation);
}
} // namespace OpenRCT2
+19 -19
View File
@@ -21,25 +21,25 @@ struct PaintSession;
namespace OpenRCT2
{
class DataSerialiser;
}
struct MoneyEffect : EntityBase
{
static constexpr auto cEntityType = EntityType::moneyEffect;
struct MoneyEffect : EntityBase
{
static constexpr auto cEntityType = EntityType::moneyEffect;
uint16_t frame;
uint16_t MoveDelay;
uint8_t NumMovements;
uint8_t GuestPurchase;
money64 Value;
int16_t OffsetX;
uint16_t Wiggle;
uint16_t frame;
uint16_t MoveDelay;
uint8_t NumMovements;
uint8_t GuestPurchase;
money64 Value;
int16_t OffsetX;
uint16_t Wiggle;
static void CreateAt(money64 value, const CoordsXYZ& effectPos, bool guestPurchase);
static void Create(money64 value, const CoordsXYZ& loc);
void SetValue(money64 value);
void Update();
std::pair<StringId, money64> GetStringId() const;
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
static void CreateAt(money64 value, const CoordsXYZ& effectPos, bool guestPurchase);
static void Create(money64 value, const CoordsXYZ& loc);
void SetValue(money64 value);
void Update();
std::pair<StringId, money64> GetStringId() const;
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
} // namespace OpenRCT2
+317 -316
View File
@@ -22,360 +22,361 @@
#include <iterator>
using namespace OpenRCT2;
static constexpr uint32_t kVehicleCrashParticleSprites[kCrashedVehicleParticleNumberTypes] = {
SPR_VEHICLE_CRASH_PARTICLE_1, SPR_VEHICLE_CRASH_PARTICLE_2, SPR_VEHICLE_CRASH_PARTICLE_3,
SPR_VEHICLE_CRASH_PARTICLE_4, SPR_VEHICLE_CRASH_PARTICLE_5,
};
template<>
bool EntityBase::Is<SteamParticle>() const
namespace OpenRCT2
{
return Type == EntityType::steamParticle;
}
static constexpr uint32_t kVehicleCrashParticleSprites[kCrashedVehicleParticleNumberTypes] = {
SPR_VEHICLE_CRASH_PARTICLE_1, SPR_VEHICLE_CRASH_PARTICLE_2, SPR_VEHICLE_CRASH_PARTICLE_3,
SPR_VEHICLE_CRASH_PARTICLE_4, SPR_VEHICLE_CRASH_PARTICLE_5,
};
template<>
bool EntityBase::Is<ExplosionFlare>() const
{
return Type == EntityType::explosionFlare;
}
template<>
bool EntityBase::Is<ExplosionCloud>() const
{
return Type == EntityType::explosionCloud;
}
template<>
bool EntityBase::Is<VehicleCrashParticle>() const
{
return Type == EntityType::crashedVehicleParticle;
}
template<>
bool EntityBase::Is<CrashSplashParticle>() const
{
return Type == EntityType::crashSplash;
}
void VehicleCrashParticle::SetSpriteData()
{
SpriteData.Width = 8;
SpriteData.HeightMin = 8;
SpriteData.HeightMax = 8;
}
void VehicleCrashParticle::Launch()
{
frame = (ScenarioRand() & 0xFF) * kCrashedVehicleParticleNumberSprites;
time_to_live = (ScenarioRand() & 0x7F) + 140;
crashed_sprite_base = ScenarioRandMax(kCrashedVehicleParticleNumberTypes);
acceleration_x = (static_cast<int16_t>(ScenarioRand() & 0xFFFF)) * 4;
acceleration_y = (static_cast<int16_t>(ScenarioRand() & 0xFFFF)) * 4;
acceleration_z = (ScenarioRand() & 0xFFFF) * 4 + 0x10000;
velocity_x = 0;
velocity_y = 0;
velocity_z = 0;
}
/**
*
* rct2: 0x006735A1
*/
void VehicleCrashParticle::Create(VehicleColour& colours, const CoordsXYZ& vehiclePos)
{
VehicleCrashParticle* sprite = getGameState().entities.CreateEntity<VehicleCrashParticle>();
if (sprite != nullptr)
template<>
bool EntityBase::Is<SteamParticle>() const
{
sprite->MoveTo(vehiclePos);
sprite->colour[0] = colours.Body;
sprite->colour[1] = colours.Trim;
sprite->SetSpriteData();
sprite->Launch();
}
}
/**
*
* rct2: 0x00673298
*/
void VehicleCrashParticle::Update()
{
Invalidate();
time_to_live--;
if (time_to_live == 0)
{
getGameState().entities.EntityRemove(this);
return;
return Type == EntityType::steamParticle;
}
// Apply gravity
acceleration_z -= 5041;
// Apply air resistance
acceleration_x -= (acceleration_x / 256);
acceleration_y -= (acceleration_y / 256);
acceleration_z -= (acceleration_z / 256);
// Update velocity and position
int32_t vx = velocity_x + acceleration_x;
int32_t vy = velocity_y + acceleration_y;
int32_t vz = velocity_z + acceleration_z;
CoordsXYZ newLoc = { x + (vx >> 16), y + (vy >> 16), z + (vz >> 16) };
velocity_x = vx & 0xFFFF;
velocity_y = vy & 0xFFFF;
velocity_z = vz & 0xFFFF;
// Check collision with land / water
int16_t landZ = TileElementHeight(newLoc);
int16_t waterZ = TileElementWaterHeight(newLoc);
if (waterZ != 0 && z >= waterZ && newLoc.z <= waterZ)
template<>
bool EntityBase::Is<ExplosionFlare>() const
{
// Splash
Audio::Play3D(Audio::SoundId::water2, { x, y, waterZ });
CrashSplashParticle::Create({ x, y, waterZ });
getGameState().entities.EntityRemove(this);
return;
return Type == EntityType::explosionFlare;
}
if (z >= landZ && newLoc.z <= landZ)
template<>
bool EntityBase::Is<ExplosionCloud>() const
{
// Bounce
acceleration_z *= -1;
newLoc.z = landZ;
}
MoveTo(newLoc);
frame += kCrashedVehicleParticleFrameIncrement;
if (frame >= (kCrashedVehicleParticleNumberSprites * kCrashedVehicleParticleFrameToSprite))
{
frame = 0;
}
}
void VehicleCrashParticle::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << time_to_live;
stream << colour;
stream << crashed_sprite_base;
stream << velocity_x;
stream << velocity_y;
stream << velocity_z;
stream << acceleration_x;
stream << acceleration_y;
stream << acceleration_z;
}
void VehicleCrashParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
{
return;
return Type == EntityType::explosionCloud;
}
uint32_t imageId = kVehicleCrashParticleSprites[crashed_sprite_base] + frame / 256;
auto image = ImageId(imageId, colour[0], colour[1]);
PaintAddImageAsParent(session, image, { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x00673699
*/
void CrashSplashParticle::Create(const CoordsXYZ& splashPos)
{
auto* sprite = getGameState().entities.CreateEntity<CrashSplashParticle>();
if (sprite != nullptr)
template<>
bool EntityBase::Is<VehicleCrashParticle>() const
{
sprite->SpriteData.Width = 33;
sprite->SpriteData.HeightMin = 51;
sprite->SpriteData.HeightMax = 16;
sprite->MoveTo(splashPos + CoordsXYZ{ 0, 0, 3 });
sprite->frame = 0;
return Type == EntityType::crashedVehicleParticle;
}
}
/**
*
* rct2: 0x0067339D
*/
void CrashSplashParticle::Update()
{
Invalidate();
frame += 85;
if (frame >= 7168)
template<>
bool EntityBase::Is<CrashSplashParticle>() const
{
getGameState().entities.EntityRemove(this);
return Type == EntityType::crashSplash;
}
}
void CrashSplashParticle::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
}
void CrashSplashParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_CRASH_SPLASH_PARTICLE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x006734B2
*/
void SteamParticle::Create(const CoordsXYZ& coords)
{
auto surfaceElement = MapGetSurfaceElementAt(coords);
if (surfaceElement != nullptr && coords.z > surfaceElement->GetBaseZ())
void VehicleCrashParticle::SetSpriteData()
{
SteamParticle* steam = getGameState().entities.CreateEntity<SteamParticle>();
if (steam == nullptr)
SpriteData.Width = 8;
SpriteData.HeightMin = 8;
SpriteData.HeightMax = 8;
}
void VehicleCrashParticle::Launch()
{
frame = (ScenarioRand() & 0xFF) * kCrashedVehicleParticleNumberSprites;
time_to_live = (ScenarioRand() & 0x7F) + 140;
crashed_sprite_base = ScenarioRandMax(kCrashedVehicleParticleNumberTypes);
acceleration_x = (static_cast<int16_t>(ScenarioRand() & 0xFFFF)) * 4;
acceleration_y = (static_cast<int16_t>(ScenarioRand() & 0xFFFF)) * 4;
acceleration_z = (ScenarioRand() & 0xFFFF) * 4 + 0x10000;
velocity_x = 0;
velocity_y = 0;
velocity_z = 0;
}
/**
*
* rct2: 0x006735A1
*/
void VehicleCrashParticle::Create(VehicleColour& colours, const CoordsXYZ& vehiclePos)
{
VehicleCrashParticle* sprite = getGameState().entities.CreateEntity<VehicleCrashParticle>();
if (sprite != nullptr)
{
sprite->MoveTo(vehiclePos);
sprite->colour[0] = colours.Body;
sprite->colour[1] = colours.Trim;
sprite->SetSpriteData();
sprite->Launch();
}
}
/**
*
* rct2: 0x00673298
*/
void VehicleCrashParticle::Update()
{
Invalidate();
time_to_live--;
if (time_to_live == 0)
{
getGameState().entities.EntityRemove(this);
return;
}
steam->SpriteData.Width = 20;
steam->SpriteData.HeightMin = 18;
steam->SpriteData.HeightMax = 16;
steam->frame = 256;
steam->time_to_move = 0;
steam->MoveTo(coords);
// Apply gravity
acceleration_z -= 5041;
// Apply air resistance
acceleration_x -= (acceleration_x / 256);
acceleration_y -= (acceleration_y / 256);
acceleration_z -= (acceleration_z / 256);
// Update velocity and position
int32_t vx = velocity_x + acceleration_x;
int32_t vy = velocity_y + acceleration_y;
int32_t vz = velocity_z + acceleration_z;
CoordsXYZ newLoc = { x + (vx >> 16), y + (vy >> 16), z + (vz >> 16) };
velocity_x = vx & 0xFFFF;
velocity_y = vy & 0xFFFF;
velocity_z = vz & 0xFFFF;
// Check collision with land / water
int16_t landZ = TileElementHeight(newLoc);
int16_t waterZ = TileElementWaterHeight(newLoc);
if (waterZ != 0 && z >= waterZ && newLoc.z <= waterZ)
{
// Splash
Audio::Play3D(Audio::SoundId::water2, { x, y, waterZ });
CrashSplashParticle::Create({ x, y, waterZ });
getGameState().entities.EntityRemove(this);
return;
}
if (z >= landZ && newLoc.z <= landZ)
{
// Bounce
acceleration_z *= -1;
newLoc.z = landZ;
}
MoveTo(newLoc);
frame += kCrashedVehicleParticleFrameIncrement;
if (frame >= (kCrashedVehicleParticleNumberSprites * kCrashedVehicleParticleFrameToSprite))
{
frame = 0;
}
}
}
/**
*
* rct2: 0x00673200
*/
void SteamParticle::Update()
{
// Move up 1 z every 3 ticks (Starts after 4 ticks)
Invalidate();
time_to_move++;
if (time_to_move >= 4)
void VehicleCrashParticle::Serialise(DataSerialiser& stream)
{
time_to_move = 1;
MoveTo({ x, y, z + 1 });
EntityBase::Serialise(stream);
stream << frame;
stream << time_to_live;
stream << colour;
stream << crashed_sprite_base;
stream << velocity_x;
stream << velocity_y;
stream << velocity_z;
stream << acceleration_x;
stream << acceleration_y;
stream << acceleration_z;
}
frame += 64;
if (frame >= (56 * 64))
void VehicleCrashParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
getGameState().entities.EntityRemove(this);
PROFILED_FUNCTION();
auto& rt = session.rt;
if (rt.zoom_level > ZoomLevel{ 0 })
{
return;
}
uint32_t imageId = kVehicleCrashParticleSprites[crashed_sprite_base] + frame / 256;
auto image = ImageId(imageId, colour[0], colour[1]);
PaintAddImageAsParent(session, image, { 0, 0, z }, { 1, 1, 0 });
}
}
void SteamParticle::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << time_to_move;
}
void SteamParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_STEAM_PARTICLE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x0067363D
*/
void ExplosionCloud::Create(const CoordsXYZ& cloudPos)
{
auto* entity = getGameState().entities.CreateEntity<ExplosionCloud>();
if (entity != nullptr)
/**
*
* rct2: 0x00673699
*/
void CrashSplashParticle::Create(const CoordsXYZ& splashPos)
{
entity->SpriteData.Width = 44;
entity->SpriteData.HeightMin = 32;
entity->SpriteData.HeightMax = 34;
entity->MoveTo(cloudPos + CoordsXYZ{ 0, 0, 4 });
entity->frame = 0;
auto* sprite = getGameState().entities.CreateEntity<CrashSplashParticle>();
if (sprite != nullptr)
{
sprite->SpriteData.Width = 33;
sprite->SpriteData.HeightMin = 51;
sprite->SpriteData.HeightMax = 16;
sprite->MoveTo(splashPos + CoordsXYZ{ 0, 0, 3 });
sprite->frame = 0;
}
}
}
/**
*
* rct2: 0x00673385
*/
void ExplosionCloud::Update()
{
Invalidate();
frame += 128;
if (frame >= (36 * 128))
/**
*
* rct2: 0x0067339D
*/
void CrashSplashParticle::Update()
{
getGameState().entities.EntityRemove(this);
Invalidate();
frame += 85;
if (frame >= 7168)
{
getGameState().entities.EntityRemove(this);
}
}
}
void ExplosionCloud::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
}
void ExplosionCloud::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_EXPLOSION_CLOUD + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x0067366B
*/
void ExplosionFlare::Create(const CoordsXYZ& flarePos)
{
auto* entity = getGameState().entities.CreateEntity<ExplosionFlare>();
if (entity != nullptr)
void CrashSplashParticle::Serialise(DataSerialiser& stream)
{
entity->SpriteData.Width = 25;
entity->SpriteData.HeightMin = 85;
entity->SpriteData.HeightMax = 8;
entity->MoveTo(flarePos + CoordsXYZ{ 0, 0, 4 });
entity->frame = 0;
EntityBase::Serialise(stream);
stream << frame;
}
}
/**
*
* rct2: 0x006733B4
*/
void ExplosionFlare::Update()
{
Invalidate();
frame += 64;
if (frame >= (124 * 64))
void CrashSplashParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
getGameState().entities.EntityRemove(this);
PROFILED_FUNCTION();
uint32_t imageId = SPR_CRASH_SPLASH_PARTICLE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
}
void ExplosionFlare::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
}
/**
*
* rct2: 0x006734B2
*/
void SteamParticle::Create(const CoordsXYZ& coords)
{
auto surfaceElement = MapGetSurfaceElementAt(coords);
if (surfaceElement != nullptr && coords.z > surfaceElement->GetBaseZ())
{
SteamParticle* steam = getGameState().entities.CreateEntity<SteamParticle>();
if (steam == nullptr)
return;
void ExplosionFlare::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
steam->SpriteData.Width = 20;
steam->SpriteData.HeightMin = 18;
steam->SpriteData.HeightMax = 16;
steam->frame = 256;
steam->time_to_move = 0;
steam->MoveTo(coords);
}
}
uint32_t imageId = SPR_EXPLOSION_FLARE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x00673200
*/
void SteamParticle::Update()
{
// Move up 1 z every 3 ticks (Starts after 4 ticks)
Invalidate();
time_to_move++;
if (time_to_move >= 4)
{
time_to_move = 1;
MoveTo({ x, y, z + 1 });
}
frame += 64;
if (frame >= (56 * 64))
{
getGameState().entities.EntityRemove(this);
}
}
void SteamParticle::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
stream << time_to_move;
}
void SteamParticle::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_STEAM_PARTICLE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x0067363D
*/
void ExplosionCloud::Create(const CoordsXYZ& cloudPos)
{
auto* entity = getGameState().entities.CreateEntity<ExplosionCloud>();
if (entity != nullptr)
{
entity->SpriteData.Width = 44;
entity->SpriteData.HeightMin = 32;
entity->SpriteData.HeightMax = 34;
entity->MoveTo(cloudPos + CoordsXYZ{ 0, 0, 4 });
entity->frame = 0;
}
}
/**
*
* rct2: 0x00673385
*/
void ExplosionCloud::Update()
{
Invalidate();
frame += 128;
if (frame >= (36 * 128))
{
getGameState().entities.EntityRemove(this);
}
}
void ExplosionCloud::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
}
void ExplosionCloud::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_EXPLOSION_CLOUD + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
/**
*
* rct2: 0x0067366B
*/
void ExplosionFlare::Create(const CoordsXYZ& flarePos)
{
auto* entity = getGameState().entities.CreateEntity<ExplosionFlare>();
if (entity != nullptr)
{
entity->SpriteData.Width = 25;
entity->SpriteData.HeightMin = 85;
entity->SpriteData.HeightMax = 8;
entity->MoveTo(flarePos + CoordsXYZ{ 0, 0, 4 });
entity->frame = 0;
}
}
/**
*
* rct2: 0x006733B4
*/
void ExplosionFlare::Update()
{
Invalidate();
frame += 64;
if (frame >= (124 * 64))
{
getGameState().entities.EntityRemove(this);
}
}
void ExplosionFlare::Serialise(DataSerialiser& stream)
{
EntityBase::Serialise(stream);
stream << frame;
}
void ExplosionFlare::Paint(PaintSession& session, int32_t imageDirection) const
{
PROFILED_FUNCTION();
uint32_t imageId = SPR_EXPLOSION_FLARE + (frame / 256);
PaintAddImageAsParent(session, ImageId(imageId), { 0, 0, z }, { 1, 1, 0 });
}
} // namespace OpenRCT2
+66 -66
View File
@@ -15,80 +15,80 @@ struct CoordsXYZ;
struct PaintSession;
struct VehicleColour;
namespace OpenRCT2
{
class DataSerialiser;
}
namespace OpenRCT2::Drawing
{
enum class Colour : uint8_t;
}
constexpr int32_t kCrashedVehicleParticleFrameToSprite = 256;
constexpr int32_t kCrashedVehicleParticleNumberSprites = 12;
constexpr int32_t kCrashedVehicleParticleNumberTypes = 5;
constexpr int32_t kCrashedVehicleParticleFrameIncrement = 85; // 1/3 of 256, rounded up
struct VehicleCrashParticle : EntityBase
namespace OpenRCT2
{
static constexpr auto cEntityType = EntityType::crashedVehicleParticle;
uint16_t frame;
uint16_t time_to_live;
OpenRCT2::Drawing::Colour colour[2];
uint16_t crashed_sprite_base;
int16_t velocity_x;
int16_t velocity_y;
int16_t velocity_z;
int32_t acceleration_x;
int32_t acceleration_y;
int32_t acceleration_z;
static void Create(VehicleColour& colours, const CoordsXYZ& vehiclePos);
void SetSpriteData();
void Launch();
void Update();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
class DataSerialiser;
struct CrashSplashParticle : EntityBase
{
static constexpr auto cEntityType = EntityType::crashSplash;
uint16_t frame;
static void Create(const CoordsXYZ& splashPos);
void Update();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
constexpr int32_t kCrashedVehicleParticleFrameToSprite = 256;
constexpr int32_t kCrashedVehicleParticleNumberSprites = 12;
constexpr int32_t kCrashedVehicleParticleNumberTypes = 5;
constexpr int32_t kCrashedVehicleParticleFrameIncrement = 85; // 1/3 of 256, rounded up
struct ExplosionFlare : EntityBase
{
static constexpr auto cEntityType = EntityType::explosionFlare;
uint16_t frame;
static void Create(const CoordsXYZ& flarePos);
void Update();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct VehicleCrashParticle : EntityBase
{
static constexpr auto cEntityType = EntityType::crashedVehicleParticle;
uint16_t frame;
uint16_t time_to_live;
Drawing::Colour colour[2];
uint16_t crashed_sprite_base;
int16_t velocity_x;
int16_t velocity_y;
int16_t velocity_z;
int32_t acceleration_x;
int32_t acceleration_y;
int32_t acceleration_z;
static void Create(VehicleColour& colours, const CoordsXYZ& vehiclePos);
void SetSpriteData();
void Launch();
void Update();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct ExplosionCloud : EntityBase
{
static constexpr auto cEntityType = EntityType::explosionCloud;
uint16_t frame;
static void Create(const CoordsXYZ& cloudPos);
void Update();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct CrashSplashParticle : EntityBase
{
static constexpr auto cEntityType = EntityType::crashSplash;
uint16_t frame;
static void Create(const CoordsXYZ& splashPos);
void Update();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct SteamParticle : EntityBase
{
static constexpr auto cEntityType = EntityType::steamParticle;
uint16_t frame;
uint16_t time_to_move;
struct ExplosionFlare : EntityBase
{
static constexpr auto cEntityType = EntityType::explosionFlare;
uint16_t frame;
static void Create(const CoordsXYZ& flarePos);
void Update();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
static void Create(const CoordsXYZ& coords);
void Update();
void Serialise(OpenRCT2::DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct ExplosionCloud : EntityBase
{
static constexpr auto cEntityType = EntityType::explosionCloud;
uint16_t frame;
static void Create(const CoordsXYZ& cloudPos);
void Update();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
struct SteamParticle : EntityBase
{
static constexpr auto cEntityType = EntityType::steamParticle;
uint16_t frame;
uint16_t time_to_move;
static void Create(const CoordsXYZ& coords);
void Update();
void Serialise(DataSerialiser& stream);
void Paint(PaintSession& session, int32_t imageDirection) const;
};
} // namespace OpenRCT2
+140 -138
View File
@@ -15,169 +15,171 @@
#include <cassert>
using namespace OpenRCT2;
using namespace OpenRCT2::Core;
static PatrolArea _consolidatedPatrolArea[EnumValue(StaffType::count)];
static std::variant<StaffType, EntityId> _patrolAreaToRender;
static bool CompareTileCoordsXY(const TileCoordsXY& lhs, const TileCoordsXY& rhs)
namespace OpenRCT2
{
if (lhs.y == rhs.y)
return lhs.x < rhs.x;
return lhs.y < rhs.y;
}
using namespace OpenRCT2::Core;
const PatrolArea::Cell* PatrolArea::GetCell(const TileCoordsXY& pos) const
{
return const_cast<PatrolArea*>(this)->GetCell(pos);
}
static PatrolArea _consolidatedPatrolArea[EnumValue(StaffType::count)];
static std::variant<StaffType, EntityId> _patrolAreaToRender;
PatrolArea::Cell* PatrolArea::GetCell(const TileCoordsXY& pos)
{
auto areaPos = TileCoordsXY(pos.x / Cell::Width, pos.y / Cell::Height);
if (areaPos.x < 0 || areaPos.x >= CellColumns || areaPos.y < 0 || areaPos.y >= CellRows)
return nullptr;
auto& area = Areas[(areaPos.y * CellColumns) + areaPos.x];
return &area;
}
bool PatrolArea::IsEmpty() const
{
return TileCount == 0;
}
void PatrolArea::Clear()
{
for (auto& area : Areas)
static bool CompareTileCoordsXY(const TileCoordsXY& lhs, const TileCoordsXY& rhs)
{
area.SortedTiles.clear();
if (lhs.y == rhs.y)
return lhs.x < rhs.x;
return lhs.y < rhs.y;
}
}
bool PatrolArea::Get(const TileCoordsXY& pos) const
{
auto* area = GetCell(pos);
if (area == nullptr)
return false;
auto it = Algorithm::binaryFind(area->SortedTiles.begin(), area->SortedTiles.end(), pos, CompareTileCoordsXY);
auto found = it != area->SortedTiles.end();
return found;
}
bool PatrolArea::Get(const CoordsXY& pos) const
{
return Get(TileCoordsXY(pos));
}
void PatrolArea::Set(const TileCoordsXY& pos, bool value)
{
auto* area = GetCell(pos);
if (area == nullptr)
return;
auto it = std::lower_bound(area->SortedTiles.begin(), area->SortedTiles.end(), pos, CompareTileCoordsXY);
auto found = it != area->SortedTiles.end() && *it == pos;
if (!found && value)
const PatrolArea::Cell* PatrolArea::GetCell(const TileCoordsXY& pos) const
{
area->SortedTiles.insert(it, pos);
TileCount++;
return const_cast<PatrolArea*>(this)->GetCell(pos);
}
else if (found && !value)
PatrolArea::Cell* PatrolArea::GetCell(const TileCoordsXY& pos)
{
area->SortedTiles.erase(it);
assert(TileCount != 0);
TileCount--;
auto areaPos = TileCoordsXY(pos.x / Cell::Width, pos.y / Cell::Height);
if (areaPos.x < 0 || areaPos.x >= CellColumns || areaPos.y < 0 || areaPos.y >= CellRows)
return nullptr;
auto& area = Areas[(areaPos.y * CellColumns) + areaPos.x];
return &area;
}
}
void PatrolArea::Set(const CoordsXY& pos, bool value)
{
Set(TileCoordsXY(pos), value);
}
void PatrolArea::Union(const PatrolArea& other)
{
for (size_t i = 0; i < Areas.size(); i++)
bool PatrolArea::IsEmpty() const
{
for (const auto& pos : other.Areas[i].SortedTiles)
return TileCount == 0;
}
void PatrolArea::Clear()
{
for (auto& area : Areas)
{
area.SortedTiles.clear();
}
}
bool PatrolArea::Get(const TileCoordsXY& pos) const
{
auto* area = GetCell(pos);
if (area == nullptr)
return false;
auto it = Algorithm::binaryFind(area->SortedTiles.begin(), area->SortedTiles.end(), pos, CompareTileCoordsXY);
auto found = it != area->SortedTiles.end();
return found;
}
bool PatrolArea::Get(const CoordsXY& pos) const
{
return Get(TileCoordsXY(pos));
}
void PatrolArea::Set(const TileCoordsXY& pos, bool value)
{
auto* area = GetCell(pos);
if (area == nullptr)
return;
auto it = std::lower_bound(area->SortedTiles.begin(), area->SortedTiles.end(), pos, CompareTileCoordsXY);
auto found = it != area->SortedTiles.end() && *it == pos;
if (!found && value)
{
area->SortedTiles.insert(it, pos);
TileCount++;
}
else if (found && !value)
{
area->SortedTiles.erase(it);
assert(TileCount != 0);
TileCount--;
}
}
void PatrolArea::Set(const CoordsXY& pos, bool value)
{
Set(TileCoordsXY(pos), value);
}
void PatrolArea::Union(const PatrolArea& other)
{
for (size_t i = 0; i < Areas.size(); i++)
{
for (const auto& pos : other.Areas[i].SortedTiles)
{
Set(pos, true);
}
}
}
void PatrolArea::Union(const std::vector<TileCoordsXY>& other)
{
for (const auto& pos : other)
{
Set(pos, true);
}
}
}
void PatrolArea::Union(const std::vector<TileCoordsXY>& other)
{
for (const auto& pos : other)
std::vector<TileCoordsXY> PatrolArea::ToVector() const
{
Set(pos, true);
}
}
std::vector<TileCoordsXY> PatrolArea::ToVector() const
{
std::vector<TileCoordsXY> result;
for (const auto& area : Areas)
{
for (const auto& pos : area.SortedTiles)
std::vector<TileCoordsXY> result;
for (const auto& area : Areas)
{
result.push_back(pos);
for (const auto& pos : area.SortedTiles)
{
result.push_back(pos);
}
}
return result;
}
const PatrolArea& GetMergedPatrolArea(const StaffType type)
{
return _consolidatedPatrolArea[EnumValue(type)];
}
void UpdateConsolidatedPatrolAreas()
{
for (int32_t staffType = 0; staffType < EnumValue(StaffType::count); ++staffType)
{
// Reset all of the merged data for the type.
auto& mergedArea = _consolidatedPatrolArea[staffType];
mergedArea.Clear();
for (auto staff : EntityList<Staff>())
{
if (EnumValue(staff->AssignedStaffType) != staffType)
continue;
if (staff->PatrolInfo == nullptr)
continue;
mergedArea.Union(*staff->PatrolInfo);
}
}
}
return result;
}
const PatrolArea& GetMergedPatrolArea(const StaffType type)
{
return _consolidatedPatrolArea[EnumValue(type)];
}
void UpdateConsolidatedPatrolAreas()
{
for (int32_t staffType = 0; staffType < EnumValue(StaffType::count); ++staffType)
bool IsPatrolAreaSetForStaffType(StaffType type, const CoordsXY& coords)
{
// Reset all of the merged data for the type.
auto& mergedArea = _consolidatedPatrolArea[staffType];
mergedArea.Clear();
for (auto staff : EntityList<Staff>())
{
if (EnumValue(staff->AssignedStaffType) != staffType)
continue;
if (staff->PatrolInfo == nullptr)
continue;
mergedArea.Union(*staff->PatrolInfo);
}
return _consolidatedPatrolArea[EnumValue(type)].Get(coords);
}
}
bool IsPatrolAreaSetForStaffType(StaffType type, const CoordsXY& coords)
{
return _consolidatedPatrolArea[EnumValue(type)].Get(coords);
}
std::variant<StaffType, EntityId> GetPatrolAreaToRender()
{
return _patrolAreaToRender;
}
std::variant<StaffType, EntityId> GetPatrolAreaToRender()
{
return _patrolAreaToRender;
}
void ClearPatrolAreaToRender()
{
SetPatrolAreaToRender(EntityId::GetNull());
}
void ClearPatrolAreaToRender()
{
SetPatrolAreaToRender(EntityId::GetNull());
}
void SetPatrolAreaToRender(EntityId staffId)
{
_patrolAreaToRender = staffId;
}
void SetPatrolAreaToRender(EntityId staffId)
{
_patrolAreaToRender = staffId;
}
void SetPatrolAreaToRender(StaffType staffType)
{
_patrolAreaToRender = staffType;
}
void SetPatrolAreaToRender(StaffType staffType)
{
_patrolAreaToRender = staffType;
}
} // namespace OpenRCT2
+45 -42
View File
@@ -15,49 +15,52 @@
#include <variant>
#include <vector>
// The number of elements in the GameState_t.StaffPatrolAreas array per staff member. Every bit in the array represents a 4x4
// square. Right now, it's a 32-bit array like in RCT2. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on a
// 256x256 map.
constexpr size_t kStaffPatrolAreaBlocksPerLine = kMaximumMapSizeTechnical / 4;
constexpr size_t kStaffPatrolAreaSize = (kStaffPatrolAreaBlocksPerLine * kStaffPatrolAreaBlocksPerLine) / 32;
class PatrolArea
namespace OpenRCT2
{
private:
struct Cell
{
static constexpr auto Width = 64;
static constexpr auto Height = 64;
static constexpr auto NumTiles = Width * Height;
// The number of elements in the GameState_t.StaffPatrolAreas array per staff member. Every bit in the array represents a
// 4x4 square. Right now, it's a 32-bit array like in RCT2. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on
// a 256x256 map.
constexpr size_t kStaffPatrolAreaBlocksPerLine = kMaximumMapSizeTechnical / 4;
constexpr size_t kStaffPatrolAreaSize = (kStaffPatrolAreaBlocksPerLine * kStaffPatrolAreaBlocksPerLine) / 32;
std::vector<TileCoordsXY> SortedTiles;
class PatrolArea
{
private:
struct Cell
{
static constexpr auto Width = 64;
static constexpr auto Height = 64;
static constexpr auto NumTiles = Width * Height;
std::vector<TileCoordsXY> SortedTiles;
};
static constexpr auto CellColumns = (kMaximumMapSizeTechnical + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (kMaximumMapSizeTechnical + (Cell::Height - 1)) / Cell::Height;
static constexpr auto NumCells = CellColumns * CellRows;
std::array<Cell, NumCells> Areas;
size_t TileCount{};
const Cell* GetCell(const TileCoordsXY& pos) const;
Cell* GetCell(const TileCoordsXY& pos);
public:
bool IsEmpty() const;
void Clear();
bool Get(const TileCoordsXY& pos) const;
bool Get(const CoordsXY& pos) const;
void Set(const TileCoordsXY& pos, bool value);
void Set(const CoordsXY& pos, bool value);
void Union(const PatrolArea& other);
void Union(const std::vector<TileCoordsXY>& other);
std::vector<TileCoordsXY> ToVector() const;
};
static constexpr auto CellColumns = (kMaximumMapSizeTechnical + (Cell::Width - 1)) / Cell::Width;
static constexpr auto CellRows = (kMaximumMapSizeTechnical + (Cell::Height - 1)) / Cell::Height;
static constexpr auto NumCells = CellColumns * CellRows;
std::array<Cell, NumCells> Areas;
size_t TileCount{};
const Cell* GetCell(const TileCoordsXY& pos) const;
Cell* GetCell(const TileCoordsXY& pos);
public:
bool IsEmpty() const;
void Clear();
bool Get(const TileCoordsXY& pos) const;
bool Get(const CoordsXY& pos) const;
void Set(const TileCoordsXY& pos, bool value);
void Set(const CoordsXY& pos, bool value);
void Union(const PatrolArea& other);
void Union(const std::vector<TileCoordsXY>& other);
std::vector<TileCoordsXY> ToVector() const;
};
void UpdateConsolidatedPatrolAreas();
bool IsPatrolAreaSetForStaffType(StaffType type, const CoordsXY& coords);
std::variant<StaffType, EntityId> GetPatrolAreaToRender();
void ClearPatrolAreaToRender();
void SetPatrolAreaToRender(EntityId staffId);
void SetPatrolAreaToRender(StaffType staffType);
void UpdateConsolidatedPatrolAreas();
bool IsPatrolAreaSetForStaffType(StaffType type, const CoordsXY& coords);
std::variant<StaffType, EntityId> GetPatrolAreaToRender();
void ClearPatrolAreaToRender();
void SetPatrolAreaToRender(EntityId staffId);
void SetPatrolAreaToRender(StaffType staffType);
} // namespace OpenRCT2
+2292 -2286
View File
File diff suppressed because it is too large. Load diff
+414 -414
View File
@@ -22,19 +22,6 @@
#include <string_view>
#include <utility>
constexpr uint8_t kPeepMinEnergy = 32;
constexpr uint8_t kPeepMaxEnergy = 128;
constexpr uint8_t kPeepMaxEnergyTarget = 255; // Oddly, this differs from max energy!
constexpr auto kPeepClearanceHeight = 4 * kCoordsZStep;
namespace OpenRCT2
{
class DataSerialiser;
class Formatter;
struct TileElement;
} // namespace OpenRCT2
namespace OpenRCT2::GameActions
{
class Result;
@@ -45,427 +32,440 @@ namespace OpenRCT2::Drawing
enum class Colour : uint8_t;
}
enum class PeepState : uint8_t
namespace OpenRCT2
{
falling = 0, // Drowning is part of falling
one = 1, // was PEEP_STATE_1
queuingFront = 2,
onRide = 3,
leavingRide = 4,
walking = 5,
queuing = 6,
enteringRide = 7,
sitting = 8,
picked = 9,
patrolling = 10, // Not sure
mowing = 11,
sweeping = 12,
enteringPark = 13,
leavingPark = 14,
answering = 15,
fixing = 16,
buying = 17,
watching = 18,
emptyingBin = 19,
usingBin = 20,
watering = 21,
headingToInspection = 22,
inspecting = 23,
};
class DataSerialiser;
class Formatter;
struct TileElement;
enum class PeepSittingSubState : uint8_t
{
tryingToSit, // was = 0
satDown // was unassigned
};
constexpr uint8_t kPeepMinEnergy = 32;
constexpr uint8_t kPeepMaxEnergy = 128;
constexpr uint8_t kPeepMaxEnergyTarget = 255; // Oddly, this differs from max energy!
enum class PeepRideSubState : uint8_t
{
atEntrance = 0,
inEntrance = 1,
freeVehicleCheck = 2, // Spend money on ride
leaveEntrance = 3, // Calculate what direction and where to go after committing to entering vehicle
approachVehicle = 4,
enterVehicle = 5,
onRide = 6,
leaveVehicle = 7,
approachExit = 8,
inExit = 9,
inQueue = 10,
atQueueFront = 11,
approachVehicleWaypoints = 12,
approachExitWaypoints = 13,
approachSpiralSlide = 14,
onSpiralSlide = 15,
leaveSpiralSlide = 16,
mazePathfinding = 17,
leaveExit = 18,
approachShop = 19,
interactShop = 20,
leaveShop = 21,
};
constexpr auto kPeepClearanceHeight = 4 * kCoordsZStep;
// Substates for guests that are inside the Spiral Slide. Declared as uint16_t to match DestinationX.
enum class PeepSpiralSlideSubState : uint16_t
{
goingUp = 0,
prepareToSlide = 1,
slidingDown = 2,
finishedSliding = 3
};
enum class PeepUsingBinSubState : uint8_t
{
walkingToBin = 0,
goingBack,
};
enum class PeepActionType : uint8_t
{
checkTime = 0,
// If no food then check watch
eatFood = 1,
shakeHead = 2,
emptyPockets = 3,
sittingEatFood = 4,
sittingCheckWatch = 4,
sittingLookAroundLeft = 5,
sittingLookAroundRight = 6,
wow = 7,
throwUp = 8,
jump = 9,
staffSweep = 10,
drowning = 11,
staffAnswerCall = 12,
staffAnswerCall2 = 13,
staffCheckBoard = 14,
staffFix = 15,
staffFix2 = 16,
staffFixGround = 17,
staffFix3 = 18,
staffWatering = 19,
joy = 20,
readMap = 21,
wave = 22,
staffEmptyBin = 23,
wave2 = 24,
takePhoto = 25,
clap = 26,
disgust = 27,
drawPicture = 28,
beingWatched = 29,
withdrawMoney = 30,
idle = 254,
walking = 255,
};
enum class PeepAnimationType : uint8_t
{
walking = 0,
checkTime = 1,
watchRide = 2,
eatFood = 3,
shakeHead = 4,
emptyPockets = 5,
holdMat = 6,
sittingIdle = 7,
sittingEatFood = 8,
sittingLookAroundLeft = 9,
sittingLookAroundRight = 10,
hanging = 11,
staffMower = 12,
wow = 13,
throwUp = 14,
jump = 15,
staffSweep = 16,
drowning = 17,
staffAnswerCall = 18,
staffAnswerCall2 = 19,
staffCheckBoard = 20,
staffFix = 21,
staffFix2 = 22,
staffFixGround = 23,
staffFix3 = 24,
staffWatering = 25,
joy = 26,
readMap = 27,
wave = 28,
staffEmptyBin = 29,
wave2 = 30,
takePhoto = 31,
clap = 32,
disgust = 33,
drawPicture = 34,
beingWatched = 35,
withdrawMoney = 36,
invalid = 255
};
enum PeepFlags : uint32_t
{
PEEP_FLAGS_LEAVING_PARK = (1 << 0),
PEEP_FLAGS_SLOW_WALK = (1 << 1),
PEEP_FLAGS_DEBUG_PATHFINDING = (1 << 2), // Enables debug logging for path finding
PEEP_FLAGS_TRACKING = (1 << 3),
PEEP_FLAGS_WAVING = (1 << 4), // Makes the peep wave
PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY = (1 << 5), // Set on paying to enter park
PEEP_FLAGS_PHOTO = (1 << 6), // Makes the peep take a picture
PEEP_FLAGS_PAINTING = (1 << 7),
PEEP_FLAGS_WOW = (1 << 8), // Makes a peep WOW2
PEEP_FLAGS_LITTER = (1 << 9), // Makes the peep throw litter
PEEP_FLAGS_LOST = (1 << 10), // Makes the peep feel lost (animation triggered)
PEEP_FLAGS_HUNGER = (1 << 11), // Makes the peep become hungry quicker
PEEP_FLAGS_TOILET = (1 << 12), // Makes the peep want to go to the toilet
PEEP_FLAGS_CROWDED = (1 << 13), // The peep will start feeling crowded
PEEP_FLAGS_HAPPINESS = (1 << 14), // The peep will start increasing happiness
PEEP_FLAGS_NAUSEA = (1 << 15), // Makes the peep feel sick (e.g. after an extreme ride)
PEEP_FLAGS_PURPLE = (1 << 16), // Makes surrounding peeps purple
PEEP_FLAGS_PIZZA = (1 << 17), // Gives passing peeps pizza
PEEP_FLAGS_EXPLODE = (1 << 18),
PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE = (1 << 19),
PEEP_FLAGS_PARK_ENTRANCE_CHOSEN = (1 << 20), // Set when the nearest park entrance has been chosen
PEEP_FLAGS_21 = (1 << 21),
PEEP_FLAGS_CONTAGIOUS = (1 << 22), // Makes any peeps in surrounding tiles sick
PEEP_FLAGS_JOY = (1 << 23), // Makes the peep jump in joy
PEEP_FLAGS_ANGRY = (1 << 24),
PEEP_FLAGS_ICE_CREAM = (1 << 25), // Gives passing peeps ice cream and they wave back
PEEP_FLAGS_NICE_RIDE_DEPRECATED = (1 << 26), // Used to make the peep think "Nice ride! But not as good as the Phoenix..."
// on exiting a ride
PEEP_FLAGS_INTAMIN_DEPRECATED = (1 << 27), // Used to make the peep think "I'm so excited - It's an Intamin ride!" while
// riding on a Intamin ride.
PEEP_FLAGS_HERE_WE_ARE = (1 << 28), // Makes the peep think "...and here we are on X!" while riding a ride
PEEP_FLAGS_POSITION_FROZEN = (1 << 29), // Prevents the peep from moving around, thus keeping them in place
PEEP_FLAGS_ANIMATION_FROZEN = (1 << 30), // Prevents the peep sprite from updating
PEEP_FLAGS_TWITCH_DEPRECATED = (1u << 31), // Formerly used for twitch integration
};
enum PeepNextFlags
{
PEEP_NEXT_FLAG_DIRECTION_MASK = 0x3,
PEEP_NEXT_FLAG_IS_SLOPED = (1 << 2),
PEEP_NEXT_FLAG_IS_SURFACE = (1 << 3),
PEEP_NEXT_FLAG_UNUSED = (1 << 4),
};
enum class PeepAnimationGroup : uint8_t
{
normal = 0,
// Security staff
alternate = 1,
// 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,
sujeonggwa = 26,
juice = 27,
funnelCake = 28,
noodles = 29,
sausage = 30,
soup = 31,
sandwich = 32,
invalid = 255
};
// Flags used by peep->WindowInvalidateFlags
enum PeepInvalidate
{
PEEP_INVALIDATE_PEEP_THOUGHTS = 1,
PEEP_INVALIDATE_PEEP_STATS = 1 << 1,
PEEP_INVALIDATE_PEEP_2 = 1 << 2,
PEEP_INVALIDATE_PEEP_INVENTORY = 1 << 3,
PEEP_INVALIDATE_STAFF_STATS = 1 << 4,
PEEP_INVALIDATE_PEEP_ACTION = 1 << 5, // Currently set only when GuestHeadingToRideId is changed
};
struct Guest;
struct Staff;
struct Peep : EntityBase
{
char* Name;
CoordsXYZ NextLoc;
uint8_t NextFlags;
PeepState State;
union
enum class PeepState : uint8_t
{
uint8_t SubState;
PeepSittingSubState SittingSubState;
PeepRideSubState RideSubState;
PeepUsingBinSubState UsingBinSubState;
falling = 0, // Drowning is part of falling
one = 1, // was PEEP_STATE_1
queuingFront = 2,
onRide = 3,
leavingRide = 4,
walking = 5,
queuing = 6,
enteringRide = 7,
sitting = 8,
picked = 9,
patrolling = 10, // Not sure
mowing = 11,
sweeping = 12,
enteringPark = 13,
leavingPark = 14,
answering = 15,
fixing = 16,
buying = 17,
watching = 18,
emptyingBin = 19,
usingBin = 20,
watering = 21,
headingToInspection = 22,
inspecting = 23,
};
OpenRCT2::ObjectEntryIndex AnimationObjectIndex;
PeepAnimationGroup AnimationGroup;
OpenRCT2::Drawing::Colour TshirtColour;
OpenRCT2::Drawing::Colour TrousersColour;
union
enum class PeepSittingSubState : uint8_t
{
uint16_t DestinationX;
PeepSpiralSlideSubState spiralSlideSubstate;
tryingToSit, // was = 0
satDown // was unassigned
};
union
enum class PeepRideSubState : uint8_t
{
uint16_t DestinationY;
uint16_t spiralSlideGoingUpTimer;
atEntrance = 0,
inEntrance = 1,
freeVehicleCheck = 2, // Spend money on ride
leaveEntrance = 3, // Calculate what direction and where to go after committing to entering vehicle
approachVehicle = 4,
enterVehicle = 5,
onRide = 6,
leaveVehicle = 7,
approachExit = 8,
inExit = 9,
inQueue = 10,
atQueueFront = 11,
approachVehicleWaypoints = 12,
approachExitWaypoints = 13,
approachSpiralSlide = 14,
onSpiralSlide = 15,
leaveSpiralSlide = 16,
mazePathfinding = 17,
leaveExit = 18,
approachShop = 19,
interactShop = 20,
leaveShop = 21,
};
uint8_t DestinationTolerance; // How close to destination before next action/state 0 = exact
uint8_t Var37;
uint8_t Energy;
uint8_t EnergyTarget;
uint8_t Mass;
uint8_t WindowInvalidateFlags;
RideId CurrentRide;
StationIndex CurrentRideStation;
uint8_t CurrentTrain;
union
// Substates for guests that are inside the Spiral Slide. Declared as uint16_t to match DestinationX.
enum class PeepSpiralSlideSubState : uint16_t
{
struct
goingUp = 0,
prepareToSlide = 1,
slidingDown = 2,
finishedSliding = 3
};
enum class PeepUsingBinSubState : uint8_t
{
walkingToBin = 0,
goingBack,
};
enum class PeepActionType : uint8_t
{
checkTime = 0,
// If no food then check watch
eatFood = 1,
shakeHead = 2,
emptyPockets = 3,
sittingEatFood = 4,
sittingCheckWatch = 4,
sittingLookAroundLeft = 5,
sittingLookAroundRight = 6,
wow = 7,
throwUp = 8,
jump = 9,
staffSweep = 10,
drowning = 11,
staffAnswerCall = 12,
staffAnswerCall2 = 13,
staffCheckBoard = 14,
staffFix = 15,
staffFix2 = 16,
staffFixGround = 17,
staffFix3 = 18,
staffWatering = 19,
joy = 20,
readMap = 21,
wave = 22,
staffEmptyBin = 23,
wave2 = 24,
takePhoto = 25,
clap = 26,
disgust = 27,
drawPicture = 28,
beingWatched = 29,
withdrawMoney = 30,
idle = 254,
walking = 255,
};
enum class PeepAnimationType : uint8_t
{
walking = 0,
checkTime = 1,
watchRide = 2,
eatFood = 3,
shakeHead = 4,
emptyPockets = 5,
holdMat = 6,
sittingIdle = 7,
sittingEatFood = 8,
sittingLookAroundLeft = 9,
sittingLookAroundRight = 10,
hanging = 11,
staffMower = 12,
wow = 13,
throwUp = 14,
jump = 15,
staffSweep = 16,
drowning = 17,
staffAnswerCall = 18,
staffAnswerCall2 = 19,
staffCheckBoard = 20,
staffFix = 21,
staffFix2 = 22,
staffFixGround = 23,
staffFix3 = 24,
staffWatering = 25,
joy = 26,
readMap = 27,
wave = 28,
staffEmptyBin = 29,
wave2 = 30,
takePhoto = 31,
clap = 32,
disgust = 33,
drawPicture = 34,
beingWatched = 35,
withdrawMoney = 36,
invalid = 255
};
enum PeepFlags : uint32_t
{
PEEP_FLAGS_LEAVING_PARK = (1 << 0),
PEEP_FLAGS_SLOW_WALK = (1 << 1),
PEEP_FLAGS_DEBUG_PATHFINDING = (1 << 2), // Enables debug logging for path finding
PEEP_FLAGS_TRACKING = (1 << 3),
PEEP_FLAGS_WAVING = (1 << 4), // Makes the peep wave
PEEP_FLAGS_HAS_PAID_FOR_PARK_ENTRY = (1 << 5), // Set on paying to enter park
PEEP_FLAGS_PHOTO = (1 << 6), // Makes the peep take a picture
PEEP_FLAGS_PAINTING = (1 << 7),
PEEP_FLAGS_WOW = (1 << 8), // Makes a peep WOW2
PEEP_FLAGS_LITTER = (1 << 9), // Makes the peep throw litter
PEEP_FLAGS_LOST = (1 << 10), // Makes the peep feel lost (animation triggered)
PEEP_FLAGS_HUNGER = (1 << 11), // Makes the peep become hungry quicker
PEEP_FLAGS_TOILET = (1 << 12), // Makes the peep want to go to the toilet
PEEP_FLAGS_CROWDED = (1 << 13), // The peep will start feeling crowded
PEEP_FLAGS_HAPPINESS = (1 << 14), // The peep will start increasing happiness
PEEP_FLAGS_NAUSEA = (1 << 15), // Makes the peep feel sick (e.g. after an extreme ride)
PEEP_FLAGS_PURPLE = (1 << 16), // Makes surrounding peeps purple
PEEP_FLAGS_PIZZA = (1 << 17), // Gives passing peeps pizza
PEEP_FLAGS_EXPLODE = (1 << 18),
PEEP_FLAGS_RIDE_SHOULD_BE_MARKED_AS_FAVOURITE = (1 << 19),
PEEP_FLAGS_PARK_ENTRANCE_CHOSEN = (1 << 20), // Set when the nearest park entrance has been chosen
PEEP_FLAGS_21 = (1 << 21),
PEEP_FLAGS_CONTAGIOUS = (1 << 22), // Makes any peeps in surrounding tiles sick
PEEP_FLAGS_JOY = (1 << 23), // Makes the peep jump in joy
PEEP_FLAGS_ANGRY = (1 << 24),
PEEP_FLAGS_ICE_CREAM = (1 << 25), // Gives passing peeps ice cream and they wave back
PEEP_FLAGS_NICE_RIDE_DEPRECATED = (1 << 26), // Used to make the peep think "Nice ride! But not as good as the
// Phoenix..." on exiting a ride
PEEP_FLAGS_INTAMIN_DEPRECATED = (1 << 27), // Used to make the peep think "I'm so excited - It's an Intamin ride!" while
// riding on a Intamin ride.
PEEP_FLAGS_HERE_WE_ARE = (1 << 28), // Makes the peep think "...and here we are on X!" while riding a ride
PEEP_FLAGS_POSITION_FROZEN = (1 << 29), // Prevents the peep from moving around, thus keeping them in place
PEEP_FLAGS_ANIMATION_FROZEN = (1 << 30), // Prevents the peep sprite from updating
PEEP_FLAGS_TWITCH_DEPRECATED = (1u << 31), // Formerly used for twitch integration
};
enum PeepNextFlags
{
PEEP_NEXT_FLAG_DIRECTION_MASK = 0x3,
PEEP_NEXT_FLAG_IS_SLOPED = (1 << 2),
PEEP_NEXT_FLAG_IS_SURFACE = (1 << 3),
PEEP_NEXT_FLAG_UNUSED = (1 << 4),
};
enum class PeepAnimationGroup : uint8_t
{
normal = 0,
// Security staff
alternate = 1,
// 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,
sujeonggwa = 26,
juice = 27,
funnelCake = 28,
noodles = 29,
sausage = 30,
soup = 31,
sandwich = 32,
invalid = 255
};
// Flags used by peep->WindowInvalidateFlags
enum PeepInvalidate
{
PEEP_INVALIDATE_PEEP_THOUGHTS = 1,
PEEP_INVALIDATE_PEEP_STATS = 1 << 1,
PEEP_INVALIDATE_PEEP_2 = 1 << 2,
PEEP_INVALIDATE_PEEP_INVENTORY = 1 << 3,
PEEP_INVALIDATE_STAFF_STATS = 1 << 4,
PEEP_INVALIDATE_PEEP_ACTION = 1 << 5, // Currently set only when GuestHeadingToRideId is changed
};
struct Guest;
struct Staff;
struct Peep : EntityBase
{
char* Name;
CoordsXYZ NextLoc;
uint8_t NextFlags;
PeepState State;
union
{
uint8_t CurrentCar;
uint8_t CurrentSeat;
uint8_t SubState;
PeepSittingSubState SittingSubState;
PeepRideSubState RideSubState;
PeepUsingBinSubState UsingBinSubState;
};
uint16_t TimeToSitdown;
struct
ObjectEntryIndex AnimationObjectIndex;
PeepAnimationGroup AnimationGroup;
Drawing::Colour TshirtColour;
Drawing::Colour TrousersColour;
union
{
uint8_t TimeToStand;
uint8_t StandingFlags;
uint16_t DestinationX;
PeepSpiralSlideSubState spiralSlideSubstate;
};
uint8_t timesSlidDown;
union
{
uint16_t DestinationY;
uint16_t spiralSlideGoingUpTimer;
};
uint8_t DestinationTolerance; // How close to destination before next action/state 0 = exact
uint8_t Var37;
uint8_t Energy;
uint8_t EnergyTarget;
uint8_t Mass;
uint8_t WindowInvalidateFlags;
RideId CurrentRide;
StationIndex CurrentRideStation;
uint8_t CurrentTrain;
union
{
struct
{
uint8_t CurrentCar;
uint8_t CurrentSeat;
};
uint16_t TimeToSitdown;
struct
{
uint8_t TimeToStand;
uint8_t StandingFlags;
};
uint8_t timesSlidDown;
};
// Normally 0, 1 for carrying sliding board on spiral slide ride, 2 for carrying lawn mower
uint8_t SpecialSprite;
PeepAnimationType AnimationType;
// Seems to be used like a local variable, as it's always set before calling SwitchNextAnimationType, which
// reads this again
PeepAnimationType NextAnimationType;
uint8_t AnimationImageIdOffset;
PeepActionType Action;
uint8_t AnimationFrameNum;
uint8_t StepProgress;
union
{
uint8_t MazeLastEdge;
::Direction PeepDirection; // Direction ?
};
RideId InteractionRideIndex;
uint32_t PeepId;
uint8_t PathCheckOptimisation; // see peep.checkForPath
TileCoordsXYZD PathfindGoal;
std::array<TileCoordsXYZD, 4> PathfindHistory;
uint8_t WalkingAnimationFrameNum;
uint32_t PeepFlags;
public: // Peep
std::optional<CoordsXY> UpdateAction(int16_t& xy_distance);
std::optional<CoordsXY> UpdateAction();
bool UpdateActionAnimation();
std::optional<CoordsXY> UpdateWalkingAction(const CoordsXY& differenceLoc, int16_t& xy_distance);
void UpdateWalkingAnimation();
void SetState(PeepState new_state);
void Remove();
void UpdateCurrentAnimationType();
void UpdateSpriteBoundingBox();
void SwitchToSpecialSprite(uint8_t special_sprite_id);
void StateReset();
[[nodiscard]] uint8_t GetNextDirection() const;
bool GetNextIsSloped() const;
bool GetNextIsSurface() const;
void SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surface);
bool CanBePickedUp() const;
void Pickup();
void PickupAbort(int32_t old_x);
[[nodiscard]] GameActions::Result Place(const TileCoordsXYZ& location, bool apply);
void RemoveFromRide();
void FormatActionTo(Formatter&) const;
void FormatNameTo(Formatter&) const;
[[nodiscard]] std::string GetName() const;
bool SetName(std::string_view value);
bool IsActionWalking() const;
bool IsActionIdle() const;
bool IsActionInterruptable() const;
bool IsActionInterruptableSafely() const;
// Reset the peep's stored goal, which means they will forget any stored pathfinding history
// on the next GuestPathfinding::ChooseDirection call.
void ResetPathfindGoal();
void SetDestination(const CoordsXY& coords);
void SetDestination(const CoordsXY& coords, int32_t tolerance);
[[nodiscard]] CoordsXY GetDestination() const;
void Serialise(class DataSerialiser& stream);
// TODO: Make these private again when done refactoring
public: // Peep
[[nodiscard]] bool CheckForPath();
std::pair<uint8_t, TileElement*> PerformNextAction();
[[nodiscard]] int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y);
void SwitchNextAnimationType();
[[nodiscard]] PeepAnimationType GetAnimationType();
protected:
bool ShouldWaitForLevelCrossing() const;
bool IsOnLevelCrossing() const;
bool IsOnPathBlockedByVehicle() const;
void UpdateWaitingAtCrossing();
void UpdateFalling();
void Update1();
void UpdatePicked();
uint32_t GetStepsToTake() const;
};
// Normally 0, 1 for carrying sliding board on spiral slide ride, 2 for carrying lawn mower
uint8_t SpecialSprite;
PeepAnimationType AnimationType;
// Seems to be used like a local variable, as it's always set before calling SwitchNextAnimationType, which
// reads this again
PeepAnimationType NextAnimationType;
uint8_t AnimationImageIdOffset;
PeepActionType Action;
uint8_t AnimationFrameNum;
uint8_t StepProgress;
union
enum
{
uint8_t MazeLastEdge;
::Direction PeepDirection; // Direction ?
PATHING_DESTINATION_REACHED = 1 << 0,
PATHING_OUTSIDE_PARK = 1 << 1,
PATHING_RIDE_EXIT = 1 << 2,
PATHING_RIDE_ENTRANCE = 1 << 3,
};
RideId InteractionRideIndex;
uint32_t PeepId;
uint8_t PathCheckOptimisation; // see peep.checkForPath
TileCoordsXYZD PathfindGoal;
std::array<TileCoordsXYZD, 4> PathfindHistory;
uint8_t WalkingAnimationFrameNum;
uint32_t PeepFlags;
public: // Peep
std::optional<CoordsXY> UpdateAction(int16_t& xy_distance);
std::optional<CoordsXY> UpdateAction();
bool UpdateActionAnimation();
std::optional<CoordsXY> UpdateWalkingAction(const CoordsXY& differenceLoc, int16_t& xy_distance);
void UpdateWalkingAnimation();
void SetState(PeepState new_state);
void Remove();
void UpdateCurrentAnimationType();
void UpdateSpriteBoundingBox();
void SwitchToSpecialSprite(uint8_t special_sprite_id);
void StateReset();
[[nodiscard]] uint8_t GetNextDirection() const;
bool GetNextIsSloped() const;
bool GetNextIsSurface() const;
void SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surface);
bool CanBePickedUp() const;
void Pickup();
void PickupAbort(int32_t old_x);
[[nodiscard]] OpenRCT2::GameActions::Result Place(const TileCoordsXYZ& location, bool apply);
void RemoveFromRide();
void FormatActionTo(OpenRCT2::Formatter&) const;
void FormatNameTo(OpenRCT2::Formatter&) const;
[[nodiscard]] std::string GetName() const;
bool SetName(std::string_view value);
bool IsActionWalking() const;
bool IsActionIdle() const;
bool IsActionInterruptable() const;
bool IsActionInterruptableSafely() const;
int32_t PeepGetStaffCount();
void PeepUpdateAll();
void PeepUpdateAllBoundingBoxes();
void PeepProblemWarningsUpdate();
void PeepStopCrowdNoise();
void PeepUpdateCrowdNoise();
void PeepUpdateDaysInQueue();
void PeepApplause();
int32_t GetPeepFaceSpriteSmall(Guest* peep);
int32_t GetPeepFaceSpriteLarge(Guest* peep);
void PeepEntityRemove(Peep* peep);
// Reset the peep's stored goal, which means they will forget any stored pathfinding history
// on the next GuestPathfinding::ChooseDirection call.
void ResetPathfindGoal();
void PeepWindowStateUpdate(Peep* peep);
void PeepDecrementNumRiders(Peep* peep);
void SetDestination(const CoordsXY& coords);
void SetDestination(const CoordsXY& coords, int32_t tolerance);
[[nodiscard]] CoordsXY GetDestination() const;
void PeepSetMapTooltip(Peep* peep);
int32_t PeepCompare(EntityId sprite_index_a, EntityId sprite_index_b);
void Serialise(class OpenRCT2::DataSerialiser& stream);
void PeepUpdateNames();
// TODO: Make these private again when done refactoring
public: // Peep
[[nodiscard]] bool CheckForPath();
std::pair<uint8_t, OpenRCT2::TileElement*> PerformNextAction();
[[nodiscard]] int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y);
void SwitchNextAnimationType();
[[nodiscard]] PeepAnimationType GetAnimationType();
protected:
bool ShouldWaitForLevelCrossing() const;
bool IsOnLevelCrossing() const;
bool IsOnPathBlockedByVehicle() const;
void UpdateWaitingAtCrossing();
void UpdateFalling();
void Update1();
void UpdatePicked();
uint32_t GetStepsToTake() const;
};
enum
{
PATHING_DESTINATION_REACHED = 1 << 0,
PATHING_OUTSIDE_PARK = 1 << 1,
PATHING_RIDE_EXIT = 1 << 2,
PATHING_RIDE_ENTRANCE = 1 << 3,
};
int32_t PeepGetStaffCount();
void PeepUpdateAll();
void PeepUpdateAllBoundingBoxes();
void PeepProblemWarningsUpdate();
void PeepStopCrowdNoise();
void PeepUpdateCrowdNoise();
void PeepUpdateDaysInQueue();
void PeepApplause();
int32_t GetPeepFaceSpriteSmall(Guest* peep);
int32_t GetPeepFaceSpriteLarge(Guest* peep);
void PeepEntityRemove(Peep* peep);
void PeepWindowStateUpdate(Peep* peep);
void PeepDecrementNumRiders(Peep* peep);
void PeepSetMapTooltip(Peep* peep);
int32_t PeepCompare(EntityId sprite_index_a, EntityId sprite_index_b);
void PeepUpdateNames();
StringId GetRealNameStringIDFromPeepID(uint32_t id);
StringId GetRealNameStringIDFromPeepID(uint32_t id);
} // namespace OpenRCT2
+2343 -2339
View File
File diff suppressed because it is too large. Load diff
+137 -136
View File
@@ -16,160 +16,161 @@
#include <cstdint>
#include <vector>
namespace OpenRCT2
{
class DataSerialiser;
struct TileElement;
struct PathElement;
} // namespace OpenRCT2
struct Ride;
namespace OpenRCT2::Drawing
{
enum class Colour : uint8_t;
}
class PatrolArea;
struct Ride;
enum class StaffType : uint8_t
namespace OpenRCT2
{
handyman,
mechanic,
security,
entertainer,
class DataSerialiser;
count
};
struct TileElement;
struct PathElement;
struct Staff : Peep
{
static constexpr auto cEntityType = EntityType::staff;
class PatrolArea;
public:
PatrolArea* PatrolInfo;
StaffType AssignedStaffType;
uint16_t MechanicTimeSinceCall; // time getting to ride to fix
int32_t HireDate;
uint8_t StaffOrders;
uint8_t StaffMowingTimeout;
union
enum class StaffType : uint8_t
{
uint32_t StaffLawnsMown;
uint32_t StaffRidesFixed;
handyman,
mechanic,
security,
entertainer,
count
};
union
struct Staff : Peep
{
uint32_t StaffGardensWatered;
uint32_t StaffRidesInspected;
static constexpr auto cEntityType = EntityType::staff;
public:
PatrolArea* PatrolInfo;
StaffType AssignedStaffType;
uint16_t MechanicTimeSinceCall; // time getting to ride to fix
int32_t HireDate;
uint8_t StaffOrders;
uint8_t StaffMowingTimeout;
union
{
uint32_t StaffLawnsMown;
uint32_t StaffRidesFixed;
};
union
{
uint32_t StaffGardensWatered;
uint32_t StaffRidesInspected;
};
union
{
uint32_t StaffLitterSwept;
uint32_t StaffVandalsStopped;
};
uint32_t StaffBinsEmptied;
void Update();
void Tick128UpdateStaff();
bool IsMechanic() const;
bool isEntertainer() const;
bool IsPatrolAreaSet(const CoordsXY& coords) const;
bool IsLocationInPatrol(const CoordsXY& loc) const;
bool IsLocationOnPatrolEdge(const CoordsXY& loc) const;
bool DoPathFinding();
void SetHireDate(int32_t hireDate);
int32_t GetHireDate() const;
bool CanIgnoreWideFlag(const CoordsXYZ& staffPos, TileElement* path) const;
static void ResetStats();
void Serialise(DataSerialiser& stream);
void ClearPatrolArea();
void SetPatrolArea(const CoordsXY& coords, bool value);
void SetPatrolArea(const MapRange& range, bool value);
bool HasPatrolArea() const;
private:
void UpdatePatrolling();
void UpdateMowing();
void UpdateSweeping();
void UpdateEmptyingBin();
void UpdateWatering();
void UpdateAnswering();
void UpdateFixing(int32_t steps);
bool UpdateFixingEnterStation(Ride& ride) const;
bool UpdateFixingMoveToBrokenDownVehicle(bool firstRun, const Ride& ride);
bool UpdateFixingFixVehicle(bool firstRun, const Ride& ride);
bool UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride& ride);
bool UpdateFixingMoveToStationEnd(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationEnd(bool firstRun);
bool UpdateFixingMoveToStationStart(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationStart(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationBrakes(bool firstRun, Ride& ride);
bool UpdateFixingMoveToStationExit(bool firstRun, const Ride& ride);
bool UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride& ride);
bool UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride& ride);
void UpdateRideInspected(RideId rideIndex);
void UpdateHeadingToInspect();
bool DoHandymanPathFinding();
bool DoMechanicPathFinding();
bool DoEntertainerPathFinding();
bool DoMiscPathFinding();
bool IsMechanicHeadingToFixRideBlockingPath();
Direction HandymanDirectionRandSurface(uint8_t validDirections) const;
void EntertainerUpdateNearbyPeeps() const;
bool SecurityGuardPathIsCrowded() const;
uint8_t GetValidPatrolDirections(const CoordsXY& loc) const;
Direction HandymanDirectionToNearestLitter() const;
uint8_t HandymanDirectionToUncutGrass(uint8_t valid_directions) const;
Direction DirectionSurface(Direction initialDirection) const;
Direction DirectionPath(uint8_t validDirections, PathElement* pathElement) const;
Direction MechanicDirectionSurface() const;
Direction MechanicDirectionPathRand(uint8_t pathDirections) const;
Direction MechanicDirectionPath(uint8_t validDirections, PathElement* pathElement);
bool UpdatePatrollingFindWatering();
bool UpdatePatrollingFindBin();
bool UpdatePatrollingFindSweeping();
bool UpdatePatrollingFindGrass();
};
union
static_assert(sizeof(Staff) <= 512);
enum STAFF_ORDERS
{
uint32_t StaffLitterSwept;
uint32_t StaffVandalsStopped;
STAFF_ORDERS_SWEEPING = (1 << 0),
STAFF_ORDERS_WATER_FLOWERS = (1 << 1),
STAFF_ORDERS_EMPTY_BINS = (1 << 2),
STAFF_ORDERS_MOWING = (1 << 3),
STAFF_ORDERS_INSPECT_RIDES = (1 << 0),
STAFF_ORDERS_FIX_RIDES = (1 << 1)
};
uint32_t StaffBinsEmptied;
void Update();
void Tick128UpdateStaff();
bool IsMechanic() const;
bool isEntertainer() const;
bool IsPatrolAreaSet(const CoordsXY& coords) const;
bool IsLocationInPatrol(const CoordsXY& loc) const;
bool IsLocationOnPatrolEdge(const CoordsXY& loc) const;
bool DoPathFinding();
void SetHireDate(int32_t hireDate);
int32_t GetHireDate() const;
enum class EntertainerCostume : uint8_t
{
Panda,
Tiger,
Elephant,
Roman,
Gorilla,
Snowman,
Knight,
Astronaut,
Bandit,
Sheriff,
Pirate,
bool CanIgnoreWideFlag(const CoordsXYZ& staffPos, OpenRCT2::TileElement* path) const;
Count
};
static void ResetStats();
void Serialise(OpenRCT2::DataSerialiser& stream);
Drawing::Colour StaffGetColour(StaffType staffType);
GameActions::Result StaffSetColour(StaffType staffType, Drawing::Colour value);
void ClearPatrolArea();
void SetPatrolArea(const CoordsXY& coords, bool value);
void SetPatrolArea(const MapRange& range, bool value);
bool HasPatrolArea() const;
money64 GetStaffWage(StaffType type);
private:
void UpdatePatrolling();
void UpdateMowing();
void UpdateSweeping();
void UpdateEmptyingBin();
void UpdateWatering();
void UpdateAnswering();
void UpdateFixing(int32_t steps);
bool UpdateFixingEnterStation(Ride& ride) const;
bool UpdateFixingMoveToBrokenDownVehicle(bool firstRun, const Ride& ride);
bool UpdateFixingFixVehicle(bool firstRun, const Ride& ride);
bool UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride& ride);
bool UpdateFixingMoveToStationEnd(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationEnd(bool firstRun);
bool UpdateFixingMoveToStationStart(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationStart(bool firstRun, const Ride& ride);
bool UpdateFixingFixStationBrakes(bool firstRun, Ride& ride);
bool UpdateFixingMoveToStationExit(bool firstRun, const Ride& ride);
bool UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride& ride);
bool UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride& ride);
void UpdateRideInspected(RideId rideIndex);
void UpdateHeadingToInspect();
bool DoHandymanPathFinding();
bool DoMechanicPathFinding();
bool DoEntertainerPathFinding();
bool DoMiscPathFinding();
bool IsMechanicHeadingToFixRideBlockingPath();
Direction HandymanDirectionRandSurface(uint8_t validDirections) const;
void EntertainerUpdateNearbyPeeps() const;
bool SecurityGuardPathIsCrowded() const;
uint8_t GetValidPatrolDirections(const CoordsXY& loc) const;
Direction HandymanDirectionToNearestLitter() const;
uint8_t HandymanDirectionToUncutGrass(uint8_t valid_directions) const;
Direction DirectionSurface(Direction initialDirection) const;
Direction DirectionPath(uint8_t validDirections, OpenRCT2::PathElement* pathElement) const;
Direction MechanicDirectionSurface() const;
Direction MechanicDirectionPathRand(uint8_t pathDirections) const;
Direction MechanicDirectionPath(uint8_t validDirections, OpenRCT2::PathElement* pathElement);
bool UpdatePatrollingFindWatering();
bool UpdatePatrollingFindBin();
bool UpdatePatrollingFindSweeping();
bool UpdatePatrollingFindGrass();
};
static_assert(sizeof(Staff) <= 512);
enum STAFF_ORDERS
{
STAFF_ORDERS_SWEEPING = (1 << 0),
STAFF_ORDERS_WATER_FLOWERS = (1 << 1),
STAFF_ORDERS_EMPTY_BINS = (1 << 2),
STAFF_ORDERS_MOWING = (1 << 3),
STAFF_ORDERS_INSPECT_RIDES = (1 << 0),
STAFF_ORDERS_FIX_RIDES = (1 << 1)
};
enum class EntertainerCostume : uint8_t
{
Panda,
Tiger,
Elephant,
Roman,
Gorilla,
Snowman,
Knight,
Astronaut,
Bandit,
Sheriff,
Pirate,
Count
};
OpenRCT2::Drawing::Colour StaffGetColour(StaffType staffType);
OpenRCT2::GameActions::Result StaffSetColour(StaffType staffType, OpenRCT2::Drawing::Colour value);
money64 GetStaffWage(StaffType type);
const PatrolArea& GetMergedPatrolArea(StaffType type);
const PatrolArea& GetMergedPatrolArea(StaffType type);
} // namespace OpenRCT2
+3 -3
View File
@@ -19,9 +19,6 @@
struct PaintSession;
struct PaintStruct;
struct EntityBase;
struct Guest;
struct Staff;
struct PaintEntry;
namespace OpenRCT2::Drawing
@@ -31,6 +28,9 @@ namespace OpenRCT2::Drawing
namespace OpenRCT2
{
struct EntityBase;
struct Guest;
struct Staff;
struct TileElement;
struct WindowBase;
+3 -3
View File
@@ -15,8 +15,6 @@
#include "../ride/RideTypes.h"
#include "../ride/ShopItem.h"
struct Guest;
enum
{
ADVERTISING_CAMPAIGN_PARK_ENTRY_FREE,
@@ -44,6 +42,8 @@ enum
namespace OpenRCT2
{
struct Guest;
enum class MarketingCampaignFlag : uint8_t
{
firstWeek,
@@ -69,7 +69,7 @@ extern const StringId kMarketingCampaignNames[ADVERTISING_CAMPAIGN_COUNT][3];
uint16_t MarketingGetCampaignGuestGenerationProbability(int32_t campaign);
void MarketingUpdate();
void MarketingSetGuestCampaign(Guest* peep, int32_t campaign);
void MarketingSetGuestCampaign(OpenRCT2::Guest* peep, int32_t campaign);
bool MarketingIsCampaignTypeApplicable(int32_t campaignType);
MarketingCampaign* MarketingGetCampaign(int32_t campaignType);
void MarketingNewCampaign(const MarketingCampaign& campaign);
+5 -1
View File
@@ -20,9 +20,13 @@
#include <string_view>
#include <vector>
struct Peep;
struct CoordsXYZ;
namespace OpenRCT2
{
struct Peep;
}
namespace OpenRCT2::GameActions
{
class GameAction;
+1 -1
View File
@@ -52,7 +52,7 @@ constexpr uint8_t kStreamVersion = 2;
const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion);
static Peep* _pickup_peep = nullptr;
static OpenRCT2::Peep* _pickup_peep = nullptr;
static int32_t _pickup_peep_old_x = kLocationNull;
#ifndef DISABLE_NETWORK
+4 -1
View File
@@ -17,7 +17,10 @@
#include <string_view>
#include <unordered_map>
struct Peep;
namespace OpenRCT2
{
struct Peep;
}
namespace OpenRCT2::Network
{
+4 -4
View File
@@ -25,12 +25,12 @@
#include <sfl/static_vector.hpp>
#include <thread>
struct EntityBase;
enum class ViewportInteractionItem : uint8_t;
namespace OpenRCT2
{
struct EntityBase;
struct TileElement;
struct SurfaceElement;
@@ -64,7 +64,7 @@ struct PaintStruct
PaintStruct* Children;
PaintStruct* NextQuadrantEntry;
OpenRCT2::TileElement* Element;
EntityBase* Entity;
OpenRCT2::EntityBase* Entity;
ImageId image_id;
ScreenCoordsXY ScreenPos;
CoordsXY MapPos;
@@ -142,7 +142,7 @@ struct PaintSessionCore
PaintStringStruct* LastPSString;
AttachedPaintStruct* LastAttachedPS;
const OpenRCT2::SurfaceElement* Surface;
EntityBase* CurrentlyDrawnEntity;
OpenRCT2::EntityBase* CurrentlyDrawnEntity;
OpenRCT2::TileElement* CurrentlyDrawnTileElement;
const OpenRCT2::TileElement* PathElementOnSameHeight;
const OpenRCT2::TileElement* TrackElementOnSameHeight;
+8 -4
View File
@@ -11,13 +11,17 @@
#include <cstdint>
namespace OpenRCT2
{
struct Guest;
enum class PeepAnimationType : uint8_t;
} // namespace OpenRCT2
struct BoundBoxXYZ;
struct Guest;
struct PaintSession;
enum class PeepAnimationType : uint8_t;
using Direction = uint8_t;
void PaintGuest(PaintSession& session, const Guest& guest, int32_t orientation);
void PaintGuest(PaintSession& session, const OpenRCT2::Guest& guest, int32_t orientation);
void PaintGuestAccesories(
PaintSession& session, const Guest& guest, uint8_t imageOffset, PeepAnimationType actionAnimationGroup,
PaintSession& session, const OpenRCT2::Guest& guest, uint8_t imageOffset, OpenRCT2::PeepAnimationType actionAnimationGroup,
Direction direction);
+8 -4
View File
@@ -14,9 +14,13 @@
#include <cstdint>
struct Peep;
namespace OpenRCT2
{
struct Peep;
enum class PeepAnimationType : uint8_t;
} // namespace OpenRCT2
using Direction = uint8_t;
enum class PeepAnimationType : uint8_t;
constexpr BoundBoxXYZ kPaintPeepBoundBox(int32_t z)
{
@@ -33,7 +37,7 @@ struct BaseImageAndOffset
{
ImageIndex baseImageId;
uint8_t offset;
PeepAnimationType actionAnimationGroup;
OpenRCT2::PeepAnimationType actionAnimationGroup;
};
BaseImageAndOffset PaintPeepGetBaseImageAndOffset(const Peep& peep, Direction direction);
BaseImageAndOffset PaintPeepGetBaseImageAndOffset(const OpenRCT2::Peep& peep, Direction direction);
@@ -16,6 +16,8 @@
#include "../Paint.h"
#include "Paint.Peep.h"
using namespace OpenRCT2;
namespace LightFx = OpenRCT2::Drawing::LightFx;
void PaintStaff(PaintSession& session, const Staff& staff, int32_t orientation)
+8 -4
View File
@@ -11,8 +11,12 @@
#include <cstdint>
struct PaintSession;
struct Staff;
namespace OpenRCT2
{
struct Staff;
}
void PaintStaff(PaintSession& session, const Staff& staff, int32_t orientation);
void PaintStaffLightingEffects(const Staff& staff);
struct PaintSession;
void PaintStaff(PaintSession& session, const OpenRCT2::Staff& staff, int32_t orientation);
void PaintStaffLightingEffects(const OpenRCT2::Staff& staff);
+3 -4
View File
@@ -14,13 +14,12 @@
#include <memory>
struct Peep;
struct Guest;
namespace OpenRCT2
{
struct Guest;
struct Peep;
struct TileElement;
}
} // namespace OpenRCT2
namespace OpenRCT2::PathFinding
{
+2 -1
View File
@@ -18,12 +18,13 @@
#include <vector>
enum class RCT12PeepAnimationGroup : uint8_t;
enum class StaffType : uint8_t;
namespace OpenRCT2
{
class PeepAnimationsObject;
enum class StaffType : uint8_t;
enum class AnimationPeepType : uint8_t
{
guest,
+8 -7
View File
@@ -31,14 +31,15 @@
struct IObjectManager;
struct Ride;
struct RideTypeDescriptor;
struct Guest;
struct Staff;
struct Vehicle;
struct RideObjectEntry;
struct ResultWithMessage;
namespace OpenRCT2
{
struct Guest;
struct Staff;
class Formatter;
class MusicObject;
class StationObject;
@@ -483,8 +484,8 @@ public:
int32_t getTotalQueueLength() const;
int32_t getMaxQueueTime() const;
void queueInsertGuestAtFront(StationIndex stationIndex, Guest* peep);
Guest* getQueueHeadGuest(StationIndex stationIndex) const;
void queueInsertGuestAtFront(StationIndex stationIndex, OpenRCT2::Guest* peep);
OpenRCT2::Guest* getQueueHeadGuest(StationIndex stationIndex) const;
void setNameToDefault();
std::string getName() const;
@@ -820,14 +821,14 @@ void RideCheckAllReachable();
bool RideTryGetOriginElement(const Ride& ride, CoordsXYE* output);
void RideClearBlockedTiles(const Ride& ride);
Staff* RideGetMechanic(const Ride& ride);
Staff* RideGetAssignedMechanic(const Ride& ride);
OpenRCT2::Staff* RideGetMechanic(const Ride& ride);
OpenRCT2::Staff* RideGetAssignedMechanic(const Ride& ride);
VehicleColour RideGetVehicleColour(const Ride& ride, int32_t vehicleIndex);
int32_t RideGetUnusedPresetVehicleColour(OpenRCT2::ObjectEntryIndex subType);
void RideSetVehicleColoursToRandomPreset(Ride& ride, uint8_t preset_index);
void RideMeasurementsUpdate();
void RideBreakdownAddNewsItem(const Ride& ride);
Staff* RideFindClosestMechanic(const Ride& ride, int32_t forInspection);
OpenRCT2::Staff* RideFindClosestMechanic(const Ride& ride, int32_t forInspection);
int32_t RideInitialiseConstructionWindow(Ride& ride);
void RideSetMapTooltip(const OpenRCT2::TileElement& tileElement);
void RidePrepareBreakdown(Ride& ride, Breakdown breakdownReason);
+7 -6
View File
@@ -275,9 +275,9 @@ struct UpkeepCostsDescriptor
};
using RideTrackGroups = OpenRCT2::BitSet<EnumValue(OpenRCT2::TrackGroup::count)>;
using UpdateRideApproachVehicleWaypointsFunction = void (*)(Guest&, const CoordsXY&, int16_t&);
using UpdateRideApproachVehicleWaypointsFunction = void (*)(OpenRCT2::Guest&, const CoordsXY&, int16_t&);
using RideMusicUpdateFunction = void (*)(Ride&);
using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest&, Ride&, CoordsXYZD&);
using PeepUpdateRideLeaveEntranceFunc = void (*)(OpenRCT2::Guest&, Ride&, CoordsXYZD&);
using StartRideMusicFunction = void (*)(const OpenRCT2::RideAudio::ViewportRideMusicInstance&);
using LightFXAddLightsMagicVehicleFunction = void (*)(const Vehicle* vehicle);
using RideLocationFunction = CoordsXY (*)(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
@@ -546,10 +546,10 @@ struct RideTypeDescriptor
RideMusicUpdateFunction MusicUpdateFunction = DefaultMusicUpdate;
RideClassification Classification = RideClassification::ride;
PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault;
PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = OpenRCT2::PeepUpdateRideLeaveEntranceDefault;
SpecialElementRatingAdjustmentFunc SpecialElementRatingAdjustment = SpecialTrackElementRatingsAjustment_Default;
RideLocationFunction GetGuestWaypointLocation = GetGuestWaypointLocationDefault;
RideLocationFunction GetGuestWaypointLocation = OpenRCT2::GetGuestWaypointLocationDefault;
RideConstructionWindowContext ConstructionWindowContext = RideConstructionWindowContext::Default;
RideUpdateFunction RideUpdate = nullptr;
@@ -558,7 +558,8 @@ struct RideTypeDescriptor
MusicTrackOffsetLengthFunc MusicTrackOffsetLength = OpenRCT2::RideAudio::RideMusicGetTrackOffsetLength_Default;
UpdateRideApproachVehicleWaypointsFunction UpdateRideApproachVehicleWaypoints = UpdateRideApproachVehicleWaypointsDefault;
UpdateRideApproachVehicleWaypointsFunction UpdateRideApproachVehicleWaypoints = OpenRCT2::
UpdateRideApproachVehicleWaypointsDefault;
RtdSpecialType specialType = RtdSpecialType::none;
/** @deprecated */
@@ -679,7 +680,7 @@ constexpr RideTypeDescriptor kDummyRTD =
.DesignCreateMode = TrackDesignCreateMode::Default,
.MusicUpdateFunction = DefaultMusicUpdate,
.Classification = RideClassification::ride,
.UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault,
.UpdateLeaveEntrance = OpenRCT2::PeepUpdateRideLeaveEntranceDefault,
};
// clang-format on
+7 -4
View File
@@ -14,7 +14,10 @@
struct Ride;
enum class PeepThoughtType : uint8_t;
namespace OpenRCT2
{
enum class PeepThoughtType : uint8_t;
}
enum class ShopItem : uint8_t
{
@@ -96,11 +99,11 @@ struct ShopItemDescriptor
uint32_t Image;
ShopItemStrings Naming;
uint16_t Flags;
Litter::Type Type;
OpenRCT2::Litter::Type Type;
uint8_t ConsumptionTime;
ShopItem DiscardContainer;
PeepThoughtType TooMuchThought;
PeepThoughtType GoodValueThought;
OpenRCT2::PeepThoughtType TooMuchThought;
OpenRCT2::PeepThoughtType GoodValueThought;
constexpr bool HasFlag(const uint16_t flag) const
{
+2 -2
View File
@@ -110,9 +110,9 @@ enum class MiniGolfFlag : uint8_t
using MiniGolfFlags = FlagHolder<uint8_t, MiniGolfFlag>;
struct Vehicle : EntityBase
struct Vehicle : OpenRCT2::EntityBase
{
static constexpr auto cEntityType = EntityType::vehicle;
static constexpr auto cEntityType = OpenRCT2::EntityType::vehicle;
enum class Type : uint8_t
{
@@ -13,7 +13,10 @@
#include "ScEntity.hpp"
struct Balloon;
namespace OpenRCT2
{
struct Balloon;
}
namespace OpenRCT2::Scripting
{
@@ -15,7 +15,10 @@
#include "../../../management/Marketing.h"
#include "ScPeep.hpp"
enum class PeepAnimationType : uint8_t;
namespace OpenRCT2
{
enum class PeepAnimationType : uint8_t;
}
namespace OpenRCT2::Scripting
{
@@ -13,7 +13,10 @@
#include "ScEntity.hpp"
struct Litter;
namespace OpenRCT2
{
struct Litter;
}
namespace OpenRCT2::Scripting
{
@@ -13,7 +13,10 @@
#include "ScEntity.hpp"
struct MoneyEffect;
namespace OpenRCT2
{
struct MoneyEffect;
}
namespace OpenRCT2::Scripting
{
@@ -15,8 +15,11 @@
#include <memory>
enum class PeepAnimationType : uint8_t;
enum class StaffType : uint8_t;
namespace OpenRCT2
{
enum class PeepAnimationType : uint8_t;
enum class StaffType : uint8_t;
} // namespace OpenRCT2
namespace OpenRCT2::Scripting
{
+1 -2
View File
@@ -12,11 +12,10 @@
#include "../core/Money.hpp"
#include "Location.hpp"
struct Guest;
namespace OpenRCT2
{
struct GameState_t;
struct Guest;
} // namespace OpenRCT2
namespace OpenRCT2::Park