mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor fountain painting (#11891)
* Refactor fountain painting Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
parent
b3d77dd6c9
commit
319bab8978
|
@ -108,63 +108,27 @@ void misc_paint(paint_session* session, const rct_sprite* misc, int32_t imageDir
|
|||
uint16_t height = jumpingFountain.z + 6;
|
||||
int32_t ebx = imageDirection / 8;
|
||||
|
||||
uint8_t al = (jumpingFountain.FountainFlags / 128) & 1;
|
||||
uint8_t ah = (jumpingFountain.sprite_direction / 16) & 1;
|
||||
// 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
|
||||
|
||||
if (al == ah)
|
||||
// These cancel each other out
|
||||
if (reversed != rotated)
|
||||
{
|
||||
al = ebx / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
al = ebx / 2;
|
||||
al = al ^ 1;
|
||||
isAntiClockwise = !isAntiClockwise;
|
||||
}
|
||||
|
||||
uint32_t baseImageId = (jumpingFountain.type == SPRITE_MISC_JUMPING_FOUNTAIN_SNOW) ? 23037 : 22973;
|
||||
uint32_t imageId = baseImageId + ebx * 16 + jumpingFountain.frame;
|
||||
if (al & 1)
|
||||
{
|
||||
switch (ebx)
|
||||
{
|
||||
case 0:
|
||||
sub_98197C(session, imageId, 0, 0, 32, 1, 3, height, -32, -3, height);
|
||||
break;
|
||||
constexpr std::array<CoordsXY, 2> antiClockWiseBoundingBoxes = { CoordsXY{ -COORDS_XY_STEP, -3 },
|
||||
CoordsXY{ 0, -3 } };
|
||||
constexpr std::array<CoordsXY, 2> clockWiseBoundingBoxes = { CoordsXY{ -COORDS_XY_STEP, 3 }, CoordsXY{ 0, 3 } };
|
||||
|
||||
case 1:
|
||||
sub_98197C(session, imageId, 0, 0, 1, 32, 3, height, -3, 0, height);
|
||||
break;
|
||||
auto bb = isAntiClockwise ? antiClockWiseBoundingBoxes : clockWiseBoundingBoxes;
|
||||
|
||||
case 2:
|
||||
sub_98197C(session, imageId, 0, 0, 32, 1, 3, height, 0, -3, height);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
sub_98197C(session, imageId, 0, 0, 1, 32, 3, height, -3, -32, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ebx)
|
||||
{
|
||||
case 0:
|
||||
sub_98197C(session, imageId, 0, 0, 32, 1, 3, height, -32, 3, height);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sub_98197C(session, imageId, 0, 0, 1, 32, 3, height, 3, 0, height);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sub_98197C(session, imageId, 0, 0, 32, 1, 3, height, 0, 3, height);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
sub_98197C(session, imageId, 0, 0, 1, 32, 3, height, 3, -32, height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sub_98197C_rotated(session, ebx, imageId, 0, 0, 32, 1, 3, height, bb[ebx & 1].x, bb[ebx & 1].y, height);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,16 +28,6 @@ enum class PATTERN
|
|||
FAST_RANDOM_CHASERS,
|
||||
};
|
||||
|
||||
namespace FOUNTAIN_FLAG
|
||||
{
|
||||
const uint32_t FAST = 1 << 0;
|
||||
const uint32_t GOTO_EDGE = 1 << 1;
|
||||
const uint32_t SPLIT = 1 << 2;
|
||||
const uint32_t TERMINATE = 1 << 3;
|
||||
const uint32_t BOUNCE = 1 << 4;
|
||||
const uint32_t DIRECTION = 1 << 7;
|
||||
}; // namespace FOUNTAIN_FLAG
|
||||
|
||||
static constexpr const std::array<CoordsXY, 8> _fountainDirectionsNegative = {
|
||||
CoordsXY{ -COORDS_XY_STEP, 0 },
|
||||
CoordsXY{ -COORDS_XY_STEP, -COORDS_XY_STEP },
|
||||
|
|
|
@ -41,3 +41,13 @@ enum
|
|||
JUMPING_FOUNTAIN_TYPE_WATER,
|
||||
JUMPING_FOUNTAIN_TYPE_SNOW
|
||||
};
|
||||
|
||||
namespace FOUNTAIN_FLAG
|
||||
{
|
||||
const uint32_t FAST = 1 << 0;
|
||||
const uint32_t GOTO_EDGE = 1 << 1;
|
||||
const uint32_t SPLIT = 1 << 2;
|
||||
const uint32_t TERMINATE = 1 << 3;
|
||||
const uint32_t BOUNCE = 1 << 4;
|
||||
const uint32_t DIRECTION = 1 << 7;
|
||||
}; // namespace FOUNTAIN_FLAG
|
||||
|
|
Loading…
Reference in New Issue