Add railway crossing behaviour for staff (#18057)

This commit is contained in:
Rik Smeets 2022-09-24 07:44:19 +02:00 committed by GitHub
parent 6be41893a4
commit 6c6ea169f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 10 deletions

View File

@ -11,6 +11,7 @@
- Feature: [#17821] [Plugin] Add API for track subpositions and vehicle subposition.
- Feature: [#17877] Add three real-life flying roller coaster colour schemes.
- Feature: [#17900] Add “Classic Wooden Coaster” with shallow banked turns.
- Feature: [#18057] Staff members now wait for passing or stalled vehicles before crossing railway tracks.
- Feature: [objects#198] Add additional pirate roofs.
- Feature: [objects#205] Add additional glass roofs.
- Feature: [objects#209] Add the Steel Roller Coaster train and 2-across Inverted Train from RollerCoaster Tycoon 1.

View File

@ -5299,16 +5299,10 @@ void Guest::UpdateWalking()
}
}
// Check if vehicle is blocking the destination tile
auto curPos = TileCoordsXYZ(GetLocation());
auto dstPos = TileCoordsXYZ(CoordsXYZ{ GetDestination(), NextLoc.z });
if (curPos.x != dstPos.x || curPos.y != dstPos.y)
if (PathIsBlockedByVehicle())
{
if (footpath_is_blocked_by_vehicle(dstPos))
{
// Wait for vehicle to pass
return;
}
// Wait for vehicle to pass
return;
}
uint8_t pathingResult;

View File

@ -321,6 +321,18 @@ bool Peep::CheckForPath()
return false;
}
bool Peep::PathIsBlockedByVehicle()
{
auto curPos = TileCoordsXYZ(GetLocation());
auto dstPos = TileCoordsXYZ(CoordsXYZ{ GetDestination(), NextLoc.z });
if ((curPos.x != dstPos.x || curPos.y != dstPos.y) && footpath_is_blocked_by_vehicle(dstPos))
{
return true;
}
return false;
}
PeepActionSpriteType Peep::GetActionSpriteType()
{
if (IsActionInterruptable())

View File

@ -412,6 +412,7 @@ public: // Peep
// TODO: Make these private again when done refactoring
public: // Peep
[[nodiscard]] bool CheckForPath();
bool PathIsBlockedByVehicle();
void PerformNextAction(uint8_t& pathing_result);
void PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result);
[[nodiscard]] int32_t GetZOnSlope(int32_t tile_x, int32_t tile_y);

View File

@ -862,6 +862,14 @@ bool Staff::DoMiscPathFinding()
return false;
}
bool Staff::IsMechanicHeadingToFixRideBlockingPath()
{
auto trackElement = map_get_track_element_at(CoordsXYZ{ GetDestination(), NextLoc.z });
auto ride = get_ride(trackElement->GetRideIndex());
return AssignedStaffType == StaffType::Mechanic && ride->id == CurrentRide
&& ride->breakdown_reason == BREAKDOWN_SAFETY_CUT_OUT;
}
/**
*
* rct2: 0x006C086D
@ -1323,6 +1331,9 @@ void Staff::UpdateHeadingToInspect()
if (!CheckForPath())
return;
if (PathIsBlockedByVehicle() && !IsMechanicHeadingToFixRideBlockingPath())
return;
uint8_t pathingResult;
TileElement* rideEntranceExitElement;
PerformNextAction(pathingResult, rideEntranceExitElement);
@ -1428,6 +1439,9 @@ void Staff::UpdateAnswering()
if (!CheckForPath())
return;
if (PathIsBlockedByVehicle() && !IsMechanicHeadingToFixRideBlockingPath())
return;
uint8_t pathingResult;
TileElement* rideEntranceExitElement;
PerformNextAction(pathingResult, rideEntranceExitElement);
@ -1760,6 +1774,9 @@ void Staff::UpdatePatrolling()
if (!CheckForPath())
return;
if (PathIsBlockedByVehicle() && !IsMechanicHeadingToFixRideBlockingPath())
return;
uint8_t pathingResult;
PerformNextAction(pathingResult);
if (!(pathingResult & PATHING_DESTINATION_REACHED))

View File

@ -94,6 +94,7 @@ private:
bool DoMechanicPathFinding();
bool DoEntertainerPathFinding();
bool DoMiscPathFinding();
bool IsMechanicHeadingToFixRideBlockingPath();
Direction HandymanDirectionRandSurface(uint8_t validDirections) const;

View File

@ -42,7 +42,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "16"
#define NETWORK_STREAM_VERSION "17"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;