forked from rosebudai/OpenRCT2-Web
Add RCT1 land edge door map animations
This commit is contained in:
1 parent
28a7e8f02a
commit
d42ee0a062
11 files changed
+153
-64
No files matched your search
@@ -613,8 +613,8 @@ GameActions::Result TrackPlaceAction::Execute() const
|
||||
|
||||
if (rtd.HasFlag(RtdFlag::hasLandscapeDoors))
|
||||
{
|
||||
trackElement->SetDoorAState(LANDSCAPE_DOOR_CLOSED);
|
||||
trackElement->SetDoorBState(LANDSCAPE_DOOR_CLOSED);
|
||||
trackElement->SetDoorAState(kLandEdgeDoorFrameClosed);
|
||||
trackElement->SetDoorBState(kLandEdgeDoorFrameClosed);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -153,24 +153,26 @@ static constexpr uint32_t kGhostTrainTrackPiecesBrakes[4] = {
|
||||
SprGhostTrainTrackBrakesNwSe,
|
||||
};
|
||||
|
||||
static constexpr TunnelType kDoorOpeningOutwardsToImage[] = {
|
||||
TunnelType::Doors2, // Closed
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors3, // Half open
|
||||
TunnelType::Doors4, // Fully open
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors2, // Unused?
|
||||
static constexpr std::array<TunnelType, kLandEdgeDoorFrameCount> kDoorOpeningOutwardsToImage = {
|
||||
TunnelType::Doors2, // closed
|
||||
TunnelType::Doors3, // opening
|
||||
TunnelType::Doors3, // opening
|
||||
TunnelType::Doors4, // open
|
||||
TunnelType::Doors3, // closing
|
||||
TunnelType::Doors3, // closing
|
||||
TunnelType::Doors2, // closed
|
||||
TunnelType::Doors2, // unused
|
||||
};
|
||||
|
||||
static constexpr TunnelType kDoorOpeningInwardsToImage[] = {
|
||||
TunnelType::Doors2, // Closed
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors5, // Half open
|
||||
TunnelType::Doors6, // Fully open
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors2, // Unused?
|
||||
TunnelType::Doors2, // Unused?
|
||||
static constexpr std::array<TunnelType, kLandEdgeDoorFrameCount> kDoorOpeningInwardsToImage = {
|
||||
TunnelType::Doors2, // closed
|
||||
TunnelType::Doors5, // opening
|
||||
TunnelType::Doors5, // opening
|
||||
TunnelType::Doors6, // open
|
||||
TunnelType::Doors5, // closing
|
||||
TunnelType::Doors5, // closing
|
||||
TunnelType::Doors2, // closed
|
||||
TunnelType::Doors2, // unused
|
||||
};
|
||||
|
||||
static TunnelType GetTunnelDoorsImageStraightFlat(const TrackElement& trackElement, uint8_t direction)
|
||||
@@ -189,24 +191,26 @@ static TunnelType GetTunnelDoorsImageStraightFlat(const TrackElement& trackEleme
|
||||
return TunnelType::Doors2;
|
||||
}
|
||||
|
||||
static constexpr TunnelType kDoorFlatTo25DegOpeningOutwardsToImage[] = {
|
||||
TunnelType::DoorsFlatTo25Deg2, // Closed
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg3, // Half open
|
||||
TunnelType::DoorsFlatTo25Deg4, // Fully open
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
static constexpr std::array<TunnelType, kLandEdgeDoorFrameCount> kDoorFlatTo25DegOpeningOutwardsToImage = {
|
||||
TunnelType::DoorsFlatTo25Deg2, // closed
|
||||
TunnelType::DoorsFlatTo25Deg3, // opening
|
||||
TunnelType::DoorsFlatTo25Deg3, // opening
|
||||
TunnelType::DoorsFlatTo25Deg4, // open
|
||||
TunnelType::DoorsFlatTo25Deg3, // closing
|
||||
TunnelType::DoorsFlatTo25Deg3, // closing
|
||||
TunnelType::DoorsFlatTo25Deg2, // closed
|
||||
TunnelType::DoorsFlatTo25Deg2, // unused
|
||||
};
|
||||
|
||||
static constexpr TunnelType kDoorFlatTo25DegOpeningInwardsToImage[] = {
|
||||
TunnelType::DoorsFlatTo25Deg2, // Closed
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg5, // Half open
|
||||
TunnelType::DoorsFlatTo25Deg6, // Fully open
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
TunnelType::DoorsFlatTo25Deg2, // Unused?
|
||||
static constexpr std::array<TunnelType, kLandEdgeDoorFrameCount> kDoorFlatTo25DegOpeningInwardsToImage = {
|
||||
TunnelType::DoorsFlatTo25Deg2, // closed
|
||||
TunnelType::DoorsFlatTo25Deg5, // opening
|
||||
TunnelType::DoorsFlatTo25Deg5, // opening
|
||||
TunnelType::DoorsFlatTo25Deg6, // open
|
||||
TunnelType::DoorsFlatTo25Deg5, // closing
|
||||
TunnelType::DoorsFlatTo25Deg5, // closing
|
||||
TunnelType::DoorsFlatTo25Deg2, // closed
|
||||
TunnelType::DoorsFlatTo25Deg2, // unused
|
||||
};
|
||||
|
||||
/** rct2: 0x00770BEC */
|
||||
|
||||
@@ -1285,13 +1285,6 @@ namespace OpenRCT2::RCT1
|
||||
RCT1_SCENERY_SMALL_RED_GARDENS = 176, // TG19
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RCT1_LANDSCAPE_DOOR_CLOSED = 0,
|
||||
RCT1_LANDSCAPE_DOOR_HALF_OPEN = 2,
|
||||
RCT1_LANDSCAPE_DOOR_OPEN = 3,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RCT1_PATH_SUPPORT_TYPE_TRUSS,
|
||||
|
||||
@@ -1472,6 +1472,11 @@ namespace OpenRCT2::RCT1
|
||||
{ mapAnimation.x, mapAnimation.y, (mapAnimation.BaseZ / 2) * kCoordsZStep },
|
||||
MapAnimations::TemporaryType::onRidePhoto);
|
||||
break;
|
||||
case kRCT12MapAnimationTypeLandEdgeDoor:
|
||||
MapAnimations::CreateTemporary(
|
||||
{ mapAnimation.x, mapAnimation.y, (mapAnimation.BaseZ / 2) * kCoordsZStep },
|
||||
MapAnimations::TemporaryType::landEdgeDoor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,6 +1166,7 @@ struct RCT12MapAnimation
|
||||
static_assert(sizeof(RCT12MapAnimation) == 6);
|
||||
|
||||
static constexpr uint8_t kRCT12MapAnimationTypeOnRidePhoto = 6;
|
||||
static constexpr uint8_t kRCT12MapAnimationTypeLandEdgeDoor = 9;
|
||||
static constexpr uint8_t kRCT12MapAnimationTypeWallDoor = 12;
|
||||
|
||||
struct RCT12ResearchItem
|
||||
|
||||
@@ -6347,25 +6347,27 @@ void Vehicle::UpdateSceneryDoor() const
|
||||
}
|
||||
|
||||
template<bool isBackwards>
|
||||
static void AnimateLandscapeDoor(TrackElement* trackElement, bool isLastVehicle)
|
||||
static void AnimateLandscapeDoor(const CoordsXYZ& doorLocation, TrackElement& trackElement, const bool isLastVehicle)
|
||||
{
|
||||
auto doorState = isBackwards ? trackElement->GetDoorAState() : trackElement->GetDoorBState();
|
||||
if (!isLastVehicle && doorState == LANDSCAPE_DOOR_CLOSED)
|
||||
const auto doorState = isBackwards ? trackElement.GetDoorAState() : trackElement.GetDoorBState();
|
||||
if (!isLastVehicle && doorState == kLandEdgeDoorFrameClosed)
|
||||
{
|
||||
if (isBackwards)
|
||||
trackElement->SetDoorAState(LANDSCAPE_DOOR_OPEN);
|
||||
trackElement.SetDoorAState(kLandEdgeDoorFrameOpening);
|
||||
else
|
||||
trackElement->SetDoorBState(LANDSCAPE_DOOR_OPEN);
|
||||
// TODO: play door open sound
|
||||
trackElement.SetDoorBState(kLandEdgeDoorFrameOpening);
|
||||
|
||||
MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor);
|
||||
}
|
||||
|
||||
if (isLastVehicle)
|
||||
{
|
||||
if (isBackwards)
|
||||
trackElement->SetDoorAState(LANDSCAPE_DOOR_CLOSED);
|
||||
trackElement.SetDoorAState(kLandEdgeDoorFrameClosing);
|
||||
else
|
||||
trackElement->SetDoorBState(LANDSCAPE_DOOR_CLOSED);
|
||||
// TODO: play door close sound
|
||||
trackElement.SetDoorBState(kLandEdgeDoorFrameClosing);
|
||||
|
||||
MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6377,11 +6379,11 @@ void Vehicle::UpdateLandscapeDoor() const
|
||||
return;
|
||||
}
|
||||
|
||||
auto coords = CoordsXYZ{ x, y, TrackLocation.z }.ToTileStart();
|
||||
auto* tileElement = MapGetTrackElementAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr && tileElement->GetType() == TileElementType::Track)
|
||||
const auto coords = CoordsXYZ{ x, y, TrackLocation.z }.ToTileStart();
|
||||
auto* const tileElement = MapGetTrackElementBeforeSurfaceAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
AnimateLandscapeDoor<false>(tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
AnimateLandscapeDoor<false>(coords, *tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6438,11 +6440,11 @@ void Vehicle::UpdateLandscapeDoorBackwards() const
|
||||
return;
|
||||
}
|
||||
|
||||
auto coords = CoordsXYZ{ TrackLocation, TrackLocation.z };
|
||||
auto* tileElement = MapGetTrackElementAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr && tileElement->GetType() == TileElementType::Track)
|
||||
const auto coords = CoordsXYZ{ TrackLocation, TrackLocation.z };
|
||||
auto* const tileElement = MapGetTrackElementBeforeSurfaceAtFromRide(coords, ride);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
AnimateLandscapeDoor<true>(tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
AnimateLandscapeDoor<true>(coords, *tileElement->AsTrack(), next_vehicle_on_train.IsNull());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2096,6 +2096,29 @@ TileElement* MapGetTrackElementAtFromRide(const CoordsXYZ& trackPos, RideId ride
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
TileElement* MapGetTrackElementAtBeforeSurfaceFromRide(const CoordsXYZ& trackPos, const RideId rideIndex)
|
||||
{
|
||||
TileElement* tileElement = MapGetFirstElementAt(trackPos);
|
||||
if (tileElement == nullptr)
|
||||
return nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
if (tileElement->GetType() == TileElementType::Surface)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (tileElement->GetType() == TileElementType::Track && tileElement->GetBaseZ() == trackPos.z
|
||||
&& tileElement->AsTrack()->GetRideIndex() == rideIndex)
|
||||
{
|
||||
return tileElement;
|
||||
}
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the track element at x, y, z that is the given track type and sequence.
|
||||
* @param x x units, not tiles.
|
||||
|
||||
@@ -247,6 +247,7 @@ TrackElement* MapGetTrackElementAtOfTypeSeq(const CoordsXYZD& location, OpenRCT2
|
||||
TileElement* MapGetTrackElementAtOfTypeFromRide(const CoordsXYZ& trackPos, OpenRCT2::TrackElemType trackType, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementAtFromRide(const CoordsXYZ& trackPos, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementAtWithDirectionFromRide(const CoordsXYZD& trackPos, RideId rideIndex);
|
||||
TileElement* MapGetTrackElementAtBeforeSurfaceFromRide(const CoordsXYZ& trackPos, RideId rideIndex);
|
||||
|
||||
bool MapIsLocationAtEdge(const CoordsXY& loc);
|
||||
|
||||
|
||||
@@ -415,6 +415,57 @@ static bool UpdateOnRidePhotoAnimation(TrackElement& track, const CoordsXYZ& coo
|
||||
return false;
|
||||
}
|
||||
|
||||
template<bool invalidate>
|
||||
static bool UpdateLandEdgeDoorsAnimation(TrackElement& track, const CoordsXYZ& coords)
|
||||
{
|
||||
if (getGameState().currentTicks & 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isAnimating = false;
|
||||
|
||||
const auto doorAState = track.GetDoorAState();
|
||||
if (doorAState >= kLandEdgeDoorFrameEnd)
|
||||
{
|
||||
track.SetDoorAState(kLandEdgeDoorFrameClosed);
|
||||
if constexpr (invalidate)
|
||||
{
|
||||
ViewportsInvalidate(coords.x, coords.y, coords.z, coords.z + 32, kMaxZoom);
|
||||
}
|
||||
}
|
||||
else if (doorAState != kLandEdgeDoorFrameClosed && doorAState != kLandEdgeDoorFrameOpen)
|
||||
{
|
||||
track.SetDoorAState(doorAState + 1);
|
||||
if constexpr (invalidate)
|
||||
{
|
||||
ViewportsInvalidate(coords.x, coords.y, coords.z, coords.z + 32, kMaxZoom);
|
||||
}
|
||||
isAnimating = true;
|
||||
}
|
||||
|
||||
const auto doorBState = track.GetDoorBState();
|
||||
if (doorBState >= kLandEdgeDoorFrameEnd)
|
||||
{
|
||||
track.SetDoorBState(kLandEdgeDoorFrameClosed);
|
||||
if constexpr (invalidate)
|
||||
{
|
||||
ViewportsInvalidate(coords.x, coords.y, coords.z, coords.z + 32, kMaxZoom);
|
||||
}
|
||||
}
|
||||
else if (doorBState != kLandEdgeDoorFrameClosed && doorBState != kLandEdgeDoorFrameOpen)
|
||||
{
|
||||
track.SetDoorBState(doorBState + 1);
|
||||
if constexpr (invalidate)
|
||||
{
|
||||
ViewportsInvalidate(coords.x, coords.y, coords.z, coords.z + 32, kMaxZoom);
|
||||
}
|
||||
isAnimating = true;
|
||||
}
|
||||
|
||||
return isAnimating;
|
||||
}
|
||||
|
||||
template<bool invalidate>
|
||||
static bool UpdateTemporaryAnimation(const TemporaryMapAnimation& animation)
|
||||
{
|
||||
@@ -439,6 +490,13 @@ static bool UpdateTemporaryAnimation(const TemporaryMapAnimation& animation)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MapAnimations::TemporaryType::landEdgeDoor:
|
||||
{
|
||||
if (tileElement->GetType() == TileElementType::Track && tileElement->BaseHeight == tileCoords.z)
|
||||
{
|
||||
isAnimating |= UpdateLandEdgeDoorsAnimation<invalidate>(*tileElement->AsTrack(), animation.location);
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace OpenRCT2::MapAnimations
|
||||
enum class TemporaryType : uint8_t
|
||||
{
|
||||
onRidePhoto,
|
||||
landEdgeDoor,
|
||||
};
|
||||
|
||||
void MarkTileForInvalidation(const TileCoordsXY coords);
|
||||
|
||||
@@ -41,12 +41,13 @@ enum
|
||||
TRACK_ELEMENT_COLOUR_SEAT_ROTATION_MASK = 0b11110000,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LANDSCAPE_DOOR_CLOSED = 0,
|
||||
LANDSCAPE_DOOR_HALF_OPEN = 2,
|
||||
LANDSCAPE_DOOR_OPEN = 3,
|
||||
};
|
||||
constexpr const int32_t kLandEdgeDoorFrameClosed = 0;
|
||||
constexpr const int32_t kLandEdgeDoorFrameOpening = 1;
|
||||
constexpr const int32_t kLandEdgeDoorFrameOpen = 3;
|
||||
constexpr const int32_t kLandEdgeDoorFrameClosing = 4;
|
||||
constexpr const int32_t kLandEdgeDoorFrameEnd = 6;
|
||||
|
||||
constexpr const int32_t kLandEdgeDoorFrameCount = 8;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
||||
Reference in new issue
Block a user