1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 17:42:29 +01:00

Add is animating state to scenery doors

This commit is contained in:
mix
2025-05-19 16:42:50 +01:00
parent e467f5db02
commit daf8c186d3
4 changed files with 27 additions and 6 deletions

View File

@@ -6313,6 +6313,7 @@ static void AnimateSceneryDoor(const CoordsXYZD& doorLocation, const CoordsXYZ&
{
door->SetAnimationIsBackwards(isBackwards);
door->SetAnimationFrame(1);
door->SetIsAnimating(true);
play_scenery_door_open_sound(trackLocation, door);
MapAnimation::Create(doorLocation);
@@ -6322,6 +6323,7 @@ static void AnimateSceneryDoor(const CoordsXYZD& doorLocation, const CoordsXYZ&
{
door->SetAnimationIsBackwards(isBackwards);
door->SetAnimationFrame(6);
door->SetIsAnimating(true);
play_scenery_door_close_sound(trackLocation, door);
MapAnimation::Create(doorLocation);

View File

@@ -189,7 +189,7 @@ static bool UpdateWallAnimation(WallElement& wall, const CoordsXYZ& loc, const i
return false;
}
if (entry->flags & WALL_SCENERY_IS_DOOR)
if (entry->flags & WALL_SCENERY_IS_DOOR && wall.IsAnimating())
{
if (getGameState().currentTicks & 1)
{
@@ -205,6 +205,7 @@ static bool UpdateWallAnimation(WallElement& wall, const CoordsXYZ& loc, const i
if (currentFrame == 15)
{
newFrame = 0;
wall.SetIsAnimating(false);
}
else
{
@@ -327,7 +328,7 @@ static bool UpdateTemporaryAnimation(const TemporaryMapAnimation& animation)
return hasAnimations;
}
static bool IsElementAnimated(const TileElementBase& element, const bool skipDoors)
static bool IsElementAnimated(const TileElementBase& element)
{
switch (element.GetType())
{
@@ -343,7 +344,7 @@ static bool IsElementAnimated(const TileElementBase& element, const bool skipDoo
{
return true;
}
if (!skipDoors && (entry->flags & WALL_SCENERY_IS_DOOR))
if (entry->flags & WALL_SCENERY_IS_DOOR && wall->IsAnimating())
{
return true;
}
@@ -432,7 +433,7 @@ void MapAnimation::CreateAll()
TileElementIteratorBegin(&it);
while (TileElementIteratorNext(&it))
{
if (IsElementAnimated(*it.element, true))
if (IsElementAnimated(*it.element))
{
_mapAnimations.insert(TileCoordsXY(it.x, it.y));
}

View File

@@ -64,6 +64,19 @@ void WallElement::SetAnimationFrame(uint8_t frameNum)
animation |= (frameNum & 0xF) << 3;
}
bool WallElement::IsAnimating() const
{
return (animation & WALL_ANIMATION_FLAG_IS_ANIMATING) != 0;
}
void WallElement::SetIsAnimating(const bool isAnimating)
{
if (isAnimating)
animation |= WALL_ANIMATION_FLAG_IS_ANIMATING;
else
animation &= ~WALL_ANIMATION_FLAG_IS_ANIMATING;
}
uint16_t WallElement::GetEntryIndex() const
{
return entryIndex;

View File

@@ -20,10 +20,12 @@
enum
{
WALL_ANIMATION_FLAG_IS_ANIMATING = (1 << 1),
WALL_ANIMATION_FLAG_ACROSS_TRACK = (1 << 2),
// 3 - 6 animation frame number
WALL_ANIMATION_FLAG_DIRECTION_BACKWARD = (1 << 7),
WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_ACROSS_TRACK | WALL_ANIMATION_FLAG_DIRECTION_BACKWARD
WALL_ANIMATION_FLAG_ALL_FLAGS = WALL_ANIMATION_FLAG_IS_ANIMATING | WALL_ANIMATION_FLAG_ACROSS_TRACK
| WALL_ANIMATION_FLAG_DIRECTION_BACKWARD
};
#pragma pack(push, 1)
@@ -37,7 +39,7 @@ private:
colour_t colour_2; // 08
colour_t colour_3; // 09
BannerIndex banner_index; // 0A
uint8_t animation; // 0C 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used)
uint8_t animation; // 0C 0b_dfff_fta0 d = direction, f = frame num, t = across track flag (not used), a = animating
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
uint8_t Pad0D[3];
@@ -61,6 +63,9 @@ public:
uint8_t GetAnimationFrame() const;
void SetAnimationFrame(uint8_t frameNum);
bool IsAnimating() const;
void SetIsAnimating(const bool isAnimating);
Banner* GetBanner() const;
BannerIndex GetBannerIndex() const;
void SetBannerIndex(BannerIndex newIndex);