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

706 lines
20 KiB
C++
Raw Normal View History

/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 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"
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;
}
void map_animation_create(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
*/
void map_animation_invalidate_all()
{
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
*/
static bool map_animation_invalidate_ride_entrance(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
auto tileElement = map_get_first_element_at(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 = get_ride(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;
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_queue_banner(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 = map_get_first_element_at(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;
int32_t direction = (tileElement->AsPath()->GetQueueBannerDirection() + get_current_rotation()) & 3;
2018-06-22 23:17:03 +02:00
if (direction == TILE_ELEMENT_DIRECTION_NORTH || direction == TILE_ELEMENT_DIRECTION_EAST)
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_small_scenery(const CoordsXYZ& loc)
{
2019-12-21 09:07:34 +00:00
TileCoordsXYZ tileLoc{ loc };
auto tileElement = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ 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
2018-06-22 23:17:03 +02:00
if (!(gCurrentTicks & 0x3FF) && game_is_not_paused())
{
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;
}
}
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_park_entrance(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 = map_get_first_element_at(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;
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_track_waterfall(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 = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_track_rapids(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 = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_track_onridephoto(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 = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ loc, loc.z, tileElement->GetClearanceZ() });
2018-06-22 23:17:03 +02:00
if (game_is_paused())
{
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
*/
static bool map_animation_invalidate_track_whirlpool(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 = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_track_spinningtunnel(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 = map_get_first_element_at(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
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_remove([[maybe_unused]] const CoordsXYZ& loc)
{
2017-06-06 23:24:18 +02:00
return true;
}
/**
*
* rct2: 0x006BA2BB
*/
static bool map_animation_invalidate_banner(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 = map_get_first_element_at(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;
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_large_scenery(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 = map_get_first_element_at(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();
if (sceneryEntry->flags & LARGE_SCENERY_FLAG_ANIMATED)
2018-06-22 23:17:03 +02:00
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_wall_door(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 = map_get_first_element_at(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;
2018-06-22 23:17:03 +02:00
if (game_is_paused())
{
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)
{
map_invalidate_tile_zoom1({ 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
*/
static bool map_animation_invalidate_wall(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 = map_get_first_element_at(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;
map_invalidate_tile_zoom1({ 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] = {
map_animation_invalidate_ride_entrance,
map_animation_invalidate_queue_banner,
map_animation_invalidate_small_scenery,
map_animation_invalidate_park_entrance,
map_animation_invalidate_track_waterfall,
map_animation_invalidate_track_rapids,
map_animation_invalidate_track_onridephoto,
map_animation_invalidate_track_whirlpool,
map_animation_invalidate_track_spinningtunnel,
map_animation_invalidate_remove,
map_animation_invalidate_banner,
map_animation_invalidate_large_scenery,
map_animation_invalidate_wall_door,
2021-10-17 15:31:56 +02:00
map_animation_invalidate_wall,
};
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();
}
void AutoCreateMapAnimations()
{
ClearMapAnimations();
tile_element_iterator it;
tile_element_iterator_begin(&it);
while (tile_element_iterator_next(&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:
2019-12-19 18:38:46 +00:00
map_animation_create(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))
{
2019-12-19 18:38:46 +00:00
map_animation_create(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))
{
2019-12-19 18:38:46 +00:00
map_animation_create(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))
{
2019-12-19 18:38:46 +00:00
map_animation_create(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())
{
2019-12-19 18:38:46 +00:00
map_animation_create(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)
{
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, loc);
}
break;
case ENTRANCE_TYPE_RIDE_ENTRANCE:
2019-12-19 18:38:46 +00:00
map_animation_create(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:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, loc);
break;
case TrackElemType::Rapids:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_RAPIDS, loc);
break;
case TrackElemType::Whirlpool:
2019-12-19 18:38:46 +00:00
map_animation_create(MAP_ANIMATION_TYPE_TRACK_WHIRLPOOL, loc);
break;
case TrackElemType::SpinningTunnel:
2019-12-19 18:38:46 +00:00
map_animation_create(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
}