mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Move painting for Fountain entity
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../Game.h"
|
||||
#include "../core/DataSerialiser.h"
|
||||
#include "../paint/Paint.h"
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../world/Footpath.h"
|
||||
#include "../world/Map.h"
|
||||
@@ -393,6 +394,47 @@ void JumpingFountain::Serialise(DataSerialiser& stream)
|
||||
stream << Iteration;
|
||||
}
|
||||
|
||||
void JumpingFountain::Paint() const
|
||||
void JumpingFountain::Paint(paint_session* session, int32_t imageDirection) const
|
||||
{
|
||||
// TODO: Move into sprites.h
|
||||
constexpr uint32_t JumpingFountainSnowBaseImage = 23037;
|
||||
constexpr uint32_t JumpingFountainWaterBaseImage = 22973;
|
||||
|
||||
rct_drawpixelinfo& dpi = session->DPI;
|
||||
if (dpi.zoom_level > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t height = z + 6;
|
||||
imageDirection = imageDirection / 8;
|
||||
|
||||
// Fountain is firing anti clockwise
|
||||
bool reversed = (FountainFlags & FOUNTAIN_FLAG::DIRECTION);
|
||||
// Fountain rotation
|
||||
bool rotated = (sprite_direction / 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) ? JumpingFountainSnowBaseImage
|
||||
: JumpingFountainWaterBaseImage;
|
||||
uint32_t imageId = baseImageId + imageDirection * 16 + frame;
|
||||
constexpr std::array antiClockWiseBoundingBoxes = {
|
||||
CoordsXY{ -COORDS_XY_STEP, -3 },
|
||||
CoordsXY{ 0, -3 },
|
||||
};
|
||||
constexpr std::array clockWiseBoundingBoxes = {
|
||||
CoordsXY{ -COORDS_XY_STEP, 3 },
|
||||
CoordsXY{ 0, 3 },
|
||||
};
|
||||
|
||||
auto bb = isAntiClockwise ? antiClockWiseBoundingBoxes : clockWiseBoundingBoxes;
|
||||
|
||||
PaintAddImageAsParentRotated(
|
||||
session, imageDirection, imageId, 0, 0, 32, 1, 3, height, bb[imageDirection & 1].x, bb[imageDirection & 1].y, height);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ struct JumpingFountain : EntityBase
|
||||
void Update();
|
||||
static void StartAnimation(JumpingFountainType newType, const CoordsXY& newLoc, const TileElement* tileElement);
|
||||
void Serialise(DataSerialiser& stream);
|
||||
void Paint() const;
|
||||
void Paint(paint_session* session, int32_t imageDirection) const;
|
||||
|
||||
private:
|
||||
JumpingFountainType GetType() const;
|
||||
|
||||
@@ -90,48 +90,3 @@ template<> void PaintEntity(paint_session* session, const ExplosionFlare* flare,
|
||||
uint32_t imageId = 22896 + (flare->frame / 256);
|
||||
PaintAddImageAsParent(session, imageId, { 0, 0, flare->z }, { 1, 1, 0 });
|
||||
}
|
||||
|
||||
constexpr uint32_t JumpingFountainSnowBaseImage = 23037;
|
||||
constexpr uint32_t JumpingFountainWaterBaseImage = 22973;
|
||||
|
||||
template<> void PaintEntity(paint_session* session, const JumpingFountain* jumpingFountain, int32_t imageDirection)
|
||||
{
|
||||
rct_drawpixelinfo* dpi = &session->DPI;
|
||||
if (dpi->zoom_level > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (jumpingFountain == nullptr)
|
||||
return;
|
||||
uint16_t height = jumpingFountain->z + 6;
|
||||
int32_t ebx = imageDirection / 8;
|
||||
|
||||
// Fountain is firing anti clockwise
|
||||
bool reversed = (jumpingFountain->FountainFlags & FOUNTAIN_FLAG::DIRECTION);
|
||||
// Fountain rotation
|
||||
bool rotated = (jumpingFountain->sprite_direction / 16) & 1;
|
||||
bool isAntiClockwise = (ebx / 2) & 1; // Clockwise or Anti-clockwise
|
||||
|
||||
// These cancel each other out
|
||||
if (reversed != rotated)
|
||||
{
|
||||
isAntiClockwise = !isAntiClockwise;
|
||||
}
|
||||
|
||||
uint32_t baseImageId = (jumpingFountain->FountainType == JumpingFountainType::Snow) ? JumpingFountainSnowBaseImage
|
||||
: JumpingFountainWaterBaseImage;
|
||||
uint32_t imageId = baseImageId + ebx * 16 + jumpingFountain->frame;
|
||||
constexpr std::array antiClockWiseBoundingBoxes = {
|
||||
CoordsXY{ -COORDS_XY_STEP, -3 },
|
||||
CoordsXY{ 0, -3 },
|
||||
};
|
||||
constexpr std::array clockWiseBoundingBoxes = {
|
||||
CoordsXY{ -COORDS_XY_STEP, 3 },
|
||||
CoordsXY{ 0, 3 },
|
||||
};
|
||||
|
||||
auto bb = isAntiClockwise ? antiClockWiseBoundingBoxes : clockWiseBoundingBoxes;
|
||||
|
||||
PaintAddImageAsParentRotated(session, ebx, imageId, 0, 0, 32, 1, 3, height, bb[ebx & 1].x, bb[ebx & 1].y, height);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user