mirror of https://github.com/OpenRCT2/OpenRCT2.git
move all function into ScGuest
This commit is contained in:
parent
f147f3f867
commit
cb44ce917d
|
@ -103,7 +103,6 @@ enum class CheatType : int32_t
|
|||
AllowRegularPathAsQueue,
|
||||
AllowSpecialColourSchemes,
|
||||
RemoveParkFences,
|
||||
SendGuestToRide,
|
||||
Count,
|
||||
};
|
||||
|
||||
|
|
|
@ -264,13 +264,6 @@ GameActions::Result CheatSetAction::Execute() const
|
|||
case CheatType::RemoveParkFences:
|
||||
RemoveParkFences();
|
||||
break;
|
||||
case CheatType::SendGuestToRide:
|
||||
{
|
||||
EntityId guestId = EntityId::FromUnderlying(_param1);
|
||||
RideId rideId = RideId::FromUnderlying(_param2);
|
||||
SendGuestToRide(guestId, rideId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
LOG_ERROR("Invalid cheat type %d", _cheatType.id);
|
||||
|
@ -421,8 +414,6 @@ ParametersRange CheatSetAction::GetParameterRange(CheatType cheatType) const
|
|||
[[fallthrough]];
|
||||
case CheatType::RemoveParkFences:
|
||||
return { { 0, 0 }, { 0, 0 } };
|
||||
case CheatType::SendGuestToRide:
|
||||
return { { 0, MAX_ENTITIES}, { 0, 10000} };
|
||||
case CheatType::Count:
|
||||
break;
|
||||
}
|
||||
|
@ -831,14 +822,3 @@ void CheatSetAction::RemoveParkFences() const
|
|||
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
void CheatSetAction::SendGuestToRide(EntityId guestId, RideId rideId) const
|
||||
{
|
||||
auto guest = TryGetEntity<Guest>(guestId);
|
||||
if (guest != nullptr)
|
||||
{
|
||||
{
|
||||
guest->SendToRide(rideId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,5 +55,4 @@ private:
|
|||
void ParkSetOpen(bool isOpen) const;
|
||||
void CreateDucks(int count) const;
|
||||
void RemoveParkFences() const;
|
||||
void SendGuestToRide(EntityId guestId, RideId rideId) const;
|
||||
};
|
||||
|
|
|
@ -1804,52 +1804,6 @@ void Guest::OnExitRide(Ride& ride)
|
|||
ride.window_invalidate_flags |= RIDE_INVALIDATE_RIDE_CUSTOMER;
|
||||
}
|
||||
|
||||
|
||||
void Guest::SendToRide(RideId rideId)
|
||||
{
|
||||
if (rideId.IsNull())
|
||||
return;
|
||||
Ride* ride = GetRide(rideId);
|
||||
if (ride == nullptr)
|
||||
return;
|
||||
if (x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
// Make the guest stay in the park
|
||||
if (PeepFlags & PEEP_FLAGS_LEAVING_PARK)
|
||||
{
|
||||
PeepFlags &= ~PEEP_FLAGS_LEAVING_PARK;
|
||||
}
|
||||
/**
|
||||
* Ideally it would also be able affect guests that are
|
||||
* PeepState::Queuing and PeepState::QueuingFront for a different ride,
|
||||
* but there's some issue causing the game to crash
|
||||
* when the original ride tries processing its depleted queue.
|
||||
*/
|
||||
if (
|
||||
State != PeepState::Walking &&
|
||||
State != PeepState::Sitting &&
|
||||
State != PeepState::Watching &&
|
||||
State != PeepState::UsingBin
|
||||
)
|
||||
return;
|
||||
|
||||
// Head to that ride
|
||||
SetState(PeepState::Walking);
|
||||
GuestHeadingToRideId = ride->id;
|
||||
GuestIsLostCountdown = 200;
|
||||
TimeLost = 0;
|
||||
ResetPathfindGoal();
|
||||
WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION;
|
||||
|
||||
|
||||
// Make peep look at their map if they have one
|
||||
if (HasItem(ShopItem::Map))
|
||||
{
|
||||
ReadMap();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00695DD2
|
||||
|
|
|
@ -335,7 +335,6 @@ public:
|
|||
void TryGetUpFromSitting();
|
||||
bool ShouldRideWhileRaining(const Ride& ride);
|
||||
void ChoseNotToGoOnRide(const Ride& ride, bool peepAtRide, bool updateLastRide);
|
||||
void SendToRide(RideId rideId);
|
||||
void PickRideToGoOn();
|
||||
void ReadMap();
|
||||
bool ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, bool thinking);
|
||||
|
@ -381,7 +380,7 @@ public:
|
|||
|
||||
private:
|
||||
void UpdateRide();
|
||||
void UpdateOnRide(){}; // TODO
|
||||
void UpdateOnRide() {}; // TODO
|
||||
void UpdateWalking();
|
||||
void UpdateWaitingAtCrossing();
|
||||
void UpdateQueuing();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
# include "../../../entity/Guest.h"
|
||||
# include "../../../localisation/Localisation.h"
|
||||
# include "../../../ride/Ride.h"
|
||||
# include "../ride/ScRide.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
|
@ -175,8 +176,7 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScGuest::lostCountdown_get, &ScGuest::lostCountdown_set, "lostCountdown");
|
||||
dukglue_register_property(ctx, &ScGuest::thoughts_get, nullptr, "thoughts");
|
||||
dukglue_register_property(ctx, &ScGuest::items_get, nullptr, "items");
|
||||
dukglue_register_property(ctx, &ScGuest::rideHeadedTo_get, nullptr, "rideHeadedTo");
|
||||
dukglue_register_method(ctx, &ScGuest::rideHeadedTo_set, "sendToRide");
|
||||
dukglue_register_property(ctx, &ScGuest::rideHeadedTo_get, &ScGuest::rideHeadedTo_set, "rideHeadedTo");
|
||||
dukglue_register_method(ctx, &ScGuest::has_item, "hasItem");
|
||||
dukglue_register_method(ctx, &ScGuest::give_item, "giveItem");
|
||||
dukglue_register_method(ctx, &ScGuest::remove_item, "removeItem");
|
||||
|
@ -477,7 +477,6 @@ namespace OpenRCT2::Scripting
|
|||
|
||||
std::shared_ptr<ScRide> ScGuest::rideHeadedTo_get() const
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
auto peep = GetGuest();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
|
@ -494,10 +493,48 @@ namespace OpenRCT2::Scripting
|
|||
void ScGuest::rideHeadedTo_set(int32_t rideId)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
auto peep = GetGuest();
|
||||
if (peep != nullptr)
|
||||
auto guest = GetGuest();
|
||||
if (guest == nullptr)
|
||||
return;
|
||||
|
||||
Ride* ride = GetRide(RideId::FromUnderlying(rideId));
|
||||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
if (guest->x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
/**
|
||||
* Filters out guests who are not in the park or are doing the wrong actions.
|
||||
*/
|
||||
PeepState& State = guest->State;
|
||||
if (State != PeepState::Walking && State != PeepState::Sitting && State != PeepState::Watching
|
||||
&& State != PeepState::UsingBin && State != PeepState::Queuing && State != PeepState::QueuingFront)
|
||||
return;
|
||||
|
||||
// If the guest is leaving the park, interrupts and sends them to the ride
|
||||
if (guest->PeepFlags & PEEP_FLAGS_LEAVING_PARK)
|
||||
{
|
||||
peep->SendToRide(RideId::FromUnderlying(rideId));
|
||||
guest->PeepFlags &= ~PEEP_FLAGS_LEAVING_PARK;
|
||||
}
|
||||
|
||||
if (State == PeepState::Queuing || State == PeepState::QueuingFront)
|
||||
{
|
||||
guest->RemoveFromQueue();
|
||||
}
|
||||
|
||||
// Head to that ride
|
||||
guest->SetState(PeepState::Walking);
|
||||
guest->GuestHeadingToRideId = ride->id;
|
||||
guest->GuestIsLostCountdown = 200;
|
||||
guest->TimeLost = 0;
|
||||
guest->ResetPathfindGoal();
|
||||
guest->WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_ACTION;
|
||||
|
||||
// Make peep look at their map if they have one
|
||||
if (guest->HasItem(ShopItem::Map))
|
||||
{
|
||||
guest->ReadMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "../../../entity/Guest.h"
|
||||
# include "ScPeep.hpp"
|
||||
# include "../ride/ScRide.hpp"
|
||||
# include "ScPeep.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue