forked from OpenRCT2/OpenRCT2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add buttons to make a ride invisible/visible
- Loading branch information
1 parent
4273bb7
commit 75195bf
Showing
7 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/***************************************************************************** | ||
* Copyright (c) 2014-2024 OpenRCT2 developers | ||
* | ||
* For a complete list of all authors, please refer to contributors.md | ||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 | ||
* | ||
* OpenRCT2 is licensed under the GNU General Public License version 3. | ||
*****************************************************************************/ | ||
|
||
#include "RideSetVisibilityAction.h" | ||
|
||
#include "../Diagnostic.h" | ||
#include "../GameState.h" | ||
#include "../world/TileElementsView.h" | ||
#include "../world/tile_element/TrackElement.h" | ||
#include "GameAction.h" | ||
|
||
using namespace OpenRCT2; | ||
|
||
RideSetVisibilityAction::RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visiblity) | ||
: _rideIndex(rideIndex) | ||
, _visibility(visiblity) | ||
{ | ||
} | ||
|
||
void RideSetVisibilityAction::AcceptParameters(GameActionParameterVisitor& visitor) | ||
{ | ||
visitor.Visit("ride", _rideIndex); | ||
visitor.Visit("visiblity", _visibility); | ||
} | ||
|
||
uint16_t RideSetVisibilityAction::GetActionFlags() const | ||
{ | ||
return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; | ||
} | ||
|
||
void RideSetVisibilityAction::Serialise(DataSerialiser& stream) | ||
{ | ||
GameAction::Serialise(stream); | ||
stream << DS_TAG(_rideIndex) << DS_TAG(_visibility); | ||
} | ||
|
||
GameActions::Result RideSetVisibilityAction::Query() const | ||
{ | ||
if (EnumValue(_visibility) >= 2) | ||
{ | ||
LOG_ERROR("Invalid visibility type %d", _visibility); | ||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_THIS, STR_ERR_VALUE_OUT_OF_RANGE); | ||
} | ||
|
||
return GameActions::Result(); | ||
} | ||
|
||
GameActions::Result RideSetVisibilityAction::Execute() const | ||
{ | ||
auto& gameState = GetGameState(); | ||
for (int32_t y = 1; y <= gameState.MapSize.y; y++) | ||
{ | ||
for (int32_t x = 1; x <= gameState.MapSize.x; x++) | ||
{ | ||
for (auto* trackElement : TileElementsView<TrackElement>(TileCoordsXY{ x, y })) | ||
{ | ||
if (trackElement->GetRideIndex() == _rideIndex) | ||
{ | ||
trackElement->SetInvisible(_visibility == RideSetVisibilityType::Invisible); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return GameActions::Result(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/***************************************************************************** | ||
* Copyright (c) 2014-2024 OpenRCT2 developers | ||
* | ||
* For a complete list of all authors, please refer to contributors.md | ||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 | ||
* | ||
* OpenRCT2 is licensed under the GNU General Public License version 3. | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "GameAction.h" | ||
|
||
enum class RideSetVisibilityType : uint8_t | ||
{ | ||
Invisible, | ||
Visible, | ||
}; | ||
|
||
class RideSetVisibilityAction final : public GameActionBase<GameCommand::SetRideVehicles> | ||
{ | ||
private: | ||
RideId _rideIndex{ RideId::GetNull() }; | ||
RideSetVisibilityType _visibility{}; | ||
|
||
public: | ||
RideSetVisibilityAction() = default; | ||
RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visibility); | ||
|
||
void AcceptParameters(GameActionParameterVisitor& visitor) override; | ||
|
||
uint16_t GetActionFlags() const override; | ||
|
||
void Serialise(DataSerialiser& stream) override; | ||
OpenRCT2::GameActions::Result Query() const override; | ||
OpenRCT2::GameActions::Result Execute() const override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters