Files
OpenRCT2-Web/src/openrct2/world/MapAnimation.cpp
T

700 lines
19 KiB
C++
Raw Normal View History

/*****************************************************************************
2023-01-01 04:58:01 -06:00
* Copyright (c) 2014-2023 OpenRCT2 developers
*
2018-06-15 14:07:34 +02:00
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
2018-06-22 23:17:03 +02:00
#include "MapAnimation.h"
2018-03-14 12:44:16 +01:00
#include "../Context.h"
2017-11-30 18:17:06 +01:00
#include "../Game.h"
2021-11-24 16:48:33 +02:00
#include "../entity/EntityList.h"
2021-11-25 23:47:24 +02:00
#include "../entity/Peep.h"
2018-06-22 23:17:03 +02:00
#include "../interface/Viewport.h"
#include "../object/StationObject.h"
2022-01-18 10:21:20 -08:00
#include "../profiling/Profiling.h"
2017-12-31 13:21:34 +01:00
#include "../ride/Ride.h"
2018-01-10 00:00:09 +01:00
#include "../ride/RideData.h"
2017-10-17 13:51:47 +02:00
#include "../ride/Track.h"
2018-05-01 17:47:00 +02:00
#include "../world/Wall.h"
2019-02-14 22:41:48 +01:00
#include "Banner.h"
2018-06-22 23:17:03 +02:00
#include "Footpath.h"
2018-09-14 12:12:22 +02:00
#include "LargeScenery.h"
2018-01-03 14:56:08 +01:00
#include "Map.h"
2018-01-11 10:59:26 +01:00
#include "Scenery.h"
2017-12-04 20:09:38 +01:00
#include "SmallScenery.h"
2018-06-22 23:17:03 +02:00
using map_animation_invalidate_event_handler = bool (*)(const CoordsXYZ& loc);
static std::vector<MapAnimation> _mapAnimations;
constexpr size_t MAX_ANIMATED_OBJECTS = 2000;
static bool InvalidateMapAnimation(const MapAnimation& obj);
static bool DoesAnimationExist(int32_t type, const CoordsXYZ& location)
{
for (const auto& a : _mapAnimations)
{
if (a.type == type && a.location == location)
{
// Animation already exists
return true;
}
}
return false;
}
2022-10-04 20:24:38 +01:00
void MapAnimationCreate(int32_t type, const CoordsXYZ& loc)
{
2019-12-19 18:38:46 +00:00
if (!DoesAnimationExist(type, loc))
2018-06-22 23:17:03 +02:00
{
if (_mapAnimations.size() < MAX_ANIMATED_OBJECTS)
{
// Create new animation
2020-04-17 16:08:22 -03:00
_mapAnimations.push_back({ static_cast<uint8_t>(type), loc });
}
else
{
LOG_ERROR("Exceeded the maximum number of animations");
}
2017-06-06 23:24:18 +02:00
}
}
/**
*
* rct2: 0x0068AFAD
*/
2022-10-04 20:24:38 +01:00
void MapAnimationInvalidateAll()
{
2022-01-18 10:21:20 -08:00
PROFILED_FUNCTION();
auto it = _mapAnimations.begin();
while (it != _mapAnimations.end())
2018-06-22 23:17:03 +02:00
{
if (InvalidateMapAnimation(*it))
2018-06-22 23:17:03 +02:00
{
// Map animation has finished, remove it
it = _mapAnimations.erase(it);
2018-06-22 23:17:03 +02:00
}
else
{
it++;
2017-06-06 23:24:18 +02:00
}
}
}
/**
*
* rct2: 0x00666670
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateRideEntrance(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
auto tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Entrance)
2017-06-06 23:24:18 +02:00
continue;
2018-09-26 12:13:44 +02:00
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
auto ride = GetRide(tileElement->AsEntrance()->GetRideIndex());
if (ride != nullptr)
{
2021-12-18 18:48:52 +01:00
auto stationObj = ride->GetStationObject();
if (stationObj != nullptr)
{
2019-12-19 18:38:46 +00:00
int32_t height = loc.z + stationObj->Height + 8;
MapInvalidateTileZoom1({ loc, height, height + 16 });
}
}
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006A7BD4
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateQueueBanner(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Path)
2017-06-06 23:24:18 +02:00
continue;
if (!(tileElement->AsPath()->IsQueue()))
2017-06-06 23:24:18 +02:00
continue;
if (!tileElement->AsPath()->HasQueueBanner())
2017-06-06 23:24:18 +02:00
continue;
2023-01-16 21:14:50 +01:00
int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + GetCurrentRotation()) & 3;
2018-06-22 23:17:03 +02:00
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST)
{
MapInvalidateTileZoom1({ loc, loc.z + 16, loc.z + 30 });
2017-06-06 23:24:18 +02:00
}
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006E32C9
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateSmallScenery(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
auto tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::SmallScenery)
2017-06-06 23:24:18 +02:00
continue;
2019-02-26 10:09:58 +00:00
if (tileElement->IsGhost())
2017-06-06 23:24:18 +02:00
continue;
2021-06-04 02:14:41 +01:00
auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
2019-02-05 11:02:22 -08:00
if (sceneryEntry == nullptr)
continue;
if (sceneryEntry->HasFlag(
2018-06-22 23:17:03 +02:00
SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_1 | SMALL_SCENERY_FLAG_FOUNTAIN_SPRAY_4 | SMALL_SCENERY_FLAG_SWAMP_GOO
| SMALL_SCENERY_FLAG_HAS_FRAME_OFFSETS))
2017-12-04 20:09:38 +01:00
{
MapInvalidateTileZoom1({ loc, loc.z, tileElement->GetClearanceZ() });
2017-06-06 23:24:18 +02:00
return false;
}
if (sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_CLOCK))
2017-12-04 20:09:38 +01:00
{
2017-06-06 23:24:18 +02:00
// Peep, looking at scenery
if (!(gCurrentTicks & 0x3FF) && GameIsNotPaused())
2018-06-22 23:17:03 +02:00
{
2018-09-14 11:14:19 +02:00
int32_t direction = tileElement->GetDirection();
2020-06-08 20:13:50 +01:00
auto quad = EntityTileList<Peep>(CoordsXY{ loc } - CoordsDirectionDelta[direction]);
for (auto peep : quad)
2018-06-22 23:17:03 +02:00
{
if (peep->State != PeepState::Walking)
2017-06-06 23:24:18 +02:00
continue;
2019-12-19 18:38:46 +00:00
if (peep->z != loc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-05-11 09:44:41 +03:00
if (peep->Action < PeepActionType::Idle)
2017-06-06 23:24:18 +02:00
continue;
peep->Action = PeepActionType::CheckTime;
2020-06-07 20:18:42 -03:00
peep->ActionFrame = 0;
peep->ActionSpriteImageOffset = 0;
2018-04-01 20:35:41 +01:00
peep->UpdateCurrentActionSpriteType();
peep->Invalidate();
2017-06-06 23:24:18 +02:00
break;
}
}
MapInvalidateTileZoom1({ loc, loc.z, tileElement->GetClearanceZ() });
2017-06-06 23:24:18 +02:00
return false;
}
2017-10-15 15:53:16 +02:00
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x00666C63
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateParkEntrance(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Entrance)
2017-06-06 23:24:18 +02:00
continue;
2018-09-26 12:13:44 +02:00
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsEntrance()->GetSequenceIndex())
2017-06-06 23:24:18 +02:00
continue;
MapInvalidateTileZoom1({ loc, loc.z + 32, loc.z + 64 });
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE29E
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateTrackWaterfall(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Track)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsTrack()->GetTrackType() == TrackElemType::Waterfall)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z + 14, loc.z + 46 });
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE2F3
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateTrackRapids(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Track)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsTrack()->GetTrackType() == TrackElemType::Rapids)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z + 14, loc.z + 18 });
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE39D
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateTrackOnRidePhoto(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Track)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsTrack()->GetTrackType() == TrackElemType::OnRidePhoto)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z, tileElement->GetClearanceZ() });
if (GameIsPaused())
2018-06-22 23:17:03 +02:00
{
2017-06-06 23:24:18 +02:00
return false;
}
2018-09-18 13:49:58 +02:00
if (tileElement->AsTrack()->IsTakingPhoto())
2018-06-22 23:17:03 +02:00
{
2018-09-18 13:49:58 +02:00
tileElement->AsTrack()->DecrementPhotoTimeout();
2017-06-06 23:24:18 +02:00
return false;
2018-06-22 23:17:03 +02:00
}
2021-09-15 22:22:15 +02:00
return true;
2017-06-06 23:24:18 +02:00
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE348
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateTrackWhirlpool(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Track)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsTrack()->GetTrackType() == TrackElemType::Whirlpool)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z + 14, loc.z + 18 });
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006CE3FA
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateTrackSpinningTunnel(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Track)
2017-06-06 23:24:18 +02:00
continue;
if (tileElement->AsTrack()->GetTrackType() == TrackElemType::SpinningTunnel)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z + 14, loc.z + 32 });
2017-06-06 23:24:18 +02:00
return false;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x0068DF8F
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateRemove([[maybe_unused]] const CoordsXYZ& loc)
{
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006BA2BB
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateBanner(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Banner)
2017-06-06 23:24:18 +02:00
continue;
MapInvalidateTileZoom1({ loc, loc.z, loc.z + 16 });
2017-06-06 23:24:18 +02:00
return false;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006B94EB
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateLargeScenery(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::LargeScenery)
2017-06-06 23:24:18 +02:00
continue;
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
2022-01-19 13:20:38 +01:00
if (sceneryEntry != nullptr && sceneryEntry->flags & LARGE_SCENERY_FLAG_ANIMATED)
2018-06-22 23:17:03 +02:00
{
MapInvalidateTileZoom1({ loc, loc.z, loc.z + 16 });
2017-06-06 23:24:18 +02:00
wasInvalidated = true;
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
/**
*
* rct2: 0x006E5B50
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateWallDoor(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2017-06-06 23:24:18 +02:00
if (gCurrentTicks & 1)
return false;
2017-06-06 23:24:18 +02:00
bool removeAnimation = true;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return removeAnimation;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Wall)
2017-06-06 23:24:18 +02:00
continue;
auto* wallEntry = tileElement->AsWall()->GetEntry();
if (wallEntry == nullptr || !(wallEntry->flags & WALL_SCENERY_IS_DOOR))
2017-06-06 23:24:18 +02:00
continue;
if (GameIsPaused())
2018-06-22 23:17:03 +02:00
{
2017-06-06 23:24:18 +02:00
return false;
}
2017-02-18 08:26:33 +00:00
2017-06-06 23:24:18 +02:00
bool invalidate = false;
2017-02-25 09:36:28 +00:00
uint8_t currentFrame = tileElement->AsWall()->GetAnimationFrame();
2018-06-22 23:17:03 +02:00
if (currentFrame != 0)
{
if (currentFrame == 15)
{
2017-06-06 23:24:18 +02:00
currentFrame = 0;
2018-06-22 23:17:03 +02:00
}
else
{
2017-06-06 23:24:18 +02:00
removeAnimation = false;
2018-06-22 23:17:03 +02:00
if (currentFrame != 5)
{
2017-06-06 23:24:18 +02:00
currentFrame++;
if (currentFrame == 13 && !(wallEntry->flags & WALL_SCENERY_LONG_DOOR_ANIMATION))
2017-06-06 23:24:18 +02:00
currentFrame = 15;
2017-02-18 08:26:33 +00:00
2017-06-06 23:24:18 +02:00
invalidate = true;
}
}
}
tileElement->AsWall()->SetAnimationFrame(currentFrame);
2018-06-22 23:17:03 +02:00
if (invalidate)
{
MapInvalidateTileZoom1({ loc, loc.z, loc.z + 32 });
2017-06-06 23:24:18 +02:00
}
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return removeAnimation;
}
/**
*
* rct2: 0x006E5EE4
*/
2022-10-04 20:24:38 +01:00
static bool MapAnimationInvalidateWall(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
2018-11-01 13:53:50 +01:00
TileElement* tileElement;
2017-06-06 23:24:18 +02:00
bool wasInvalidated = false;
tileElement = MapGetFirstElementAt(loc);
if (tileElement == nullptr)
return true;
2018-06-22 23:17:03 +02:00
do
{
2019-12-21 09:07:34 +00:00
if (tileElement->base_height != tileLoc.z)
2017-06-06 23:24:18 +02:00
continue;
2021-12-11 00:39:39 +01:00
if (tileElement->GetType() != TileElementType::Wall)
2017-06-06 23:24:18 +02:00
continue;
auto* wallEntry = tileElement->AsWall()->GetEntry();
2017-10-15 15:53:16 +02:00
if (wallEntry == nullptr
|| (!(wallEntry->flags2 & WALL_SCENERY_2_ANIMATED) && wallEntry->scrolling_mode == SCROLLING_MODE_NONE))
2017-06-06 23:24:18 +02:00
continue;
MapInvalidateTileZoom1({ loc, loc.z, loc.z + 16 });
2017-06-06 23:24:18 +02:00
wasInvalidated = true;
} while (!(tileElement++)->IsLastForTile());
2017-06-06 23:24:18 +02:00
return !wasInvalidated;
}
2015-12-11 09:38:37 -06:00
/**
*
* rct2: 0x009819DC
*/
static constexpr const map_animation_invalidate_event_handler _animatedObjectEventHandlers[MAP_ANIMATION_TYPE_COUNT] = {
2022-10-04 20:24:38 +01:00
MapAnimationInvalidateRideEntrance, MapAnimationInvalidateQueueBanner, MapAnimationInvalidateSmallScenery,
MapAnimationInvalidateParkEntrance, MapAnimationInvalidateTrackWaterfall, MapAnimationInvalidateTrackRapids,
MapAnimationInvalidateTrackOnRidePhoto, MapAnimationInvalidateTrackWhirlpool, MapAnimationInvalidateTrackSpinningTunnel,
MapAnimationInvalidateRemove, MapAnimationInvalidateBanner, MapAnimationInvalidateLargeScenery,
MapAnimationInvalidateWallDoor, MapAnimationInvalidateWall,
};
2018-01-11 10:59:26 +01:00
/**
* @returns true if the animation should be removed.
*/
static bool InvalidateMapAnimation(const MapAnimation& a)
2018-01-11 10:59:26 +01:00
{
if (a.type < std::size(_animatedObjectEventHandlers))
{
2019-12-19 18:38:46 +00:00
return _animatedObjectEventHandlers[a.type](a.location);
}
return true;
}
2018-06-22 23:17:03 +02:00
const std::vector<MapAnimation>& GetMapAnimations()
{
return _mapAnimations;
}
static void ClearMapAnimations()
{
_mapAnimations.clear();
}
2022-10-04 20:24:38 +01:00
void MapAnimationAutoCreate()
{
ClearMapAnimations();
tile_element_iterator it;
TileElementIteratorBegin(&it);
while (TileElementIteratorNext(&it))
{
auto el = it.element;
2020-03-13 12:03:43 +01:00
auto loc = CoordsXYZ{ TileCoordsXY(it.x, it.y).ToCoordsXY(), el->GetBaseZ() };
2021-12-11 00:39:39 +01:00
switch (el->GetType())
{
2021-12-11 00:39:39 +01:00
case TileElementType::Banner:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_BANNER, loc);
break;
2021-12-11 00:39:39 +01:00
case TileElementType::Wall:
{
auto wallEl = el->AsWall();
auto* entry = wallEl->GetEntry();
if (entry != nullptr
&& ((entry->flags2 & WALL_SCENERY_2_ANIMATED) || entry->scrolling_mode != SCROLLING_MODE_NONE))
{
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_WALL, loc);
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::SmallScenery:
{
auto sceneryEl = el->AsSmallScenery();
2021-06-04 02:14:41 +01:00
auto* sceneryEntry = sceneryEl->GetEntry();
if (sceneryEntry != nullptr && sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_ANIMATED))
{
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_SMALL_SCENERY, loc);
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::LargeScenery:
{
auto sceneryEl = el->AsLargeScenery();
auto entry = sceneryEl->GetEntry();
if (entry != nullptr && (entry->flags & LARGE_SCENERY_FLAG_ANIMATED))
{
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_LARGE_SCENERY, loc);
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::Path:
{
auto path = el->AsPath();
if (path->HasQueueBanner())
{
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_QUEUE_BANNER, loc);
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::Entrance:
{
auto entrance = el->AsEntrance();
switch (entrance->GetEntranceType())
{
case ENTRANCE_TYPE_PARK_ENTRANCE:
if (entrance->GetSequenceIndex() == 0)
{
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc);
}
break;
case ENTRANCE_TYPE_RIDE_ENTRANCE:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_RIDE_ENTRANCE, loc);
break;
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::Track:
{
auto track = el->AsTrack();
switch (track->GetTrackType())
{
case TrackElemType::Waterfall:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc);
break;
case TrackElemType::Rapids:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc);
break;
case TrackElemType::Whirlpool:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc);
break;
case TrackElemType::SpinningTunnel:
2022-10-04 20:24:38 +01:00
MapAnimationCreate(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, loc);
break;
}
break;
}
2021-12-11 00:39:39 +01:00
case TileElementType::Surface:
break;
}
}
2018-01-11 10:59:26 +01:00
}