Add cheats for destroying and repairing runways.

This commit is contained in:
Dan Albert 2023-07-13 22:01:53 -07:00 committed by Raffson
parent 855fa1347b
commit 7303c8fa20
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
5 changed files with 78 additions and 5 deletions

View File

@ -210,8 +210,8 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions
* **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone.
* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate.
* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate.
* **[UI]** An error will be displayed when invalid fast-forward options are selected rather than beginning a never ending simulation.
* **[UI]** Added cheats for instantly repairing and destroying runways.
## Fixes

View File

@ -878,6 +878,7 @@ class Settings:
enable_frontline_cheats: bool = False
enable_base_capture_cheat: bool = False
enable_transfer_cheat: bool = False
enable_runway_state_cheat: bool = False
# LUA Plugins system
plugins: Dict[str, bool] = field(default_factory=dict)

View File

@ -256,6 +256,10 @@ class RunwayStatus:
# is reset.
self.repair_turns_remaining = None
def repair(self) -> None:
self.repair_turns_remaining = None
self.damaged = False
def begin_repair(self) -> None:
if self.repair_turns_remaining is not None:
logging.error("Runway already under repair. Restarting.")
@ -264,8 +268,7 @@ class RunwayStatus:
def process_turn(self) -> None:
if self.repair_turns_remaining is not None:
if self.repair_turns_remaining == 1:
self.repair_turns_remaining = None
self.damaged = False
self.repair()
else:
self.repair_turns_remaining -= 1
@ -977,6 +980,11 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
def parking_slots(self) -> Iterator[ParkingSlot]:
yield from []
@property
@abstractmethod
def runway_is_destroyable(self) -> bool:
...
@property
@abstractmethod
def runway_status(self) -> RunwayStatus:
@ -1250,6 +1258,10 @@ class Airfield(ControlPoint, CTLD):
def heading(self) -> Heading:
return Heading.from_degrees(self.airport.runways[0].heading)
@property
def runway_is_destroyable(self) -> bool:
return True
def runway_is_operational(self) -> bool:
return not self.runway_status.damaged
@ -1341,6 +1353,10 @@ class NavalControlPoint(
return g
raise RuntimeError(f"Found no carrier/LHA group for {self.name}")
@property
def runway_is_destroyable(self) -> bool:
return False
def runway_is_operational(self) -> bool:
# Necessary because it's possible for the carrier itself to have sunk
# while its escorts are still alive.
@ -1521,6 +1537,10 @@ class OffMapSpawn(ControlPoint):
logging.warning("TODO: Off map spawns have no runways.")
return self.stub_runway_data()
@property
def runway_is_destroyable(self) -> bool:
return False
@property
def runway_status(self) -> RunwayStatus:
return RunwayStatus()
@ -1557,6 +1577,10 @@ class Fob(ControlPoint, RadioFrequencyContainer, CTLD):
def symbol_set_and_entity(self) -> tuple[SymbolSet, Entity]:
return SymbolSet.LAND_INSTALLATIONS, LandInstallationEntity.MILITARY_BASE
@property
def runway_is_destroyable(self) -> bool:
return False
def runway_is_operational(self) -> bool:
return self.has_helipads or self.has_ground_spawns

View File

@ -116,10 +116,23 @@ class QBaseMenu2(QDialog):
top_layout.addWidget(self.intel_summary)
top_layout.setAlignment(Qt.AlignTop)
runway_buttons_layout = QVBoxLayout()
top_layout.addLayout(runway_buttons_layout)
if (
self.cp.runway_is_destroyable
and self.game_model.game.settings.enable_runway_state_cheat
):
self.cheat_runway_state = QPushButton()
self.update_cheat_runway_state_text()
self.cheat_runway_state.clicked.connect(self.on_cheat_runway_state)
runway_buttons_layout.addWidget(self.cheat_runway_state)
self.repair_button = QPushButton()
self.repair_button.clicked.connect(self.begin_runway_repair)
self.update_repair_button()
top_layout.addWidget(self.repair_button)
runway_buttons_layout.addWidget(self.repair_button)
runway_buttons_layout.addStretch()
base_menu_header.setProperty("style", "baseMenuHeader")
base_menu_header.setLayout(top_layout)
@ -181,6 +194,23 @@ class QBaseMenu2(QDialog):
self.cp.captured
).has_destinations(self.cp)
def update_cheat_runway_state_text(self) -> None:
if self.cp.runway_can_be_repaired:
self.cheat_runway_state.setText("CHEAT: Repair runway")
else:
self.cheat_runway_state.setText("CHEAT: Destroy runway")
def on_cheat_runway_state(self) -> None:
if self.cp.runway_can_be_repaired:
self.cp.runway_status.repair()
else:
self.cp.runway_status.damage()
self.update_cheat_runway_state_text()
self.update_repair_button()
self.update_intel_summary()
with EventStream.event_context() as events:
events.update_control_point(self.cp)
@property
def can_repair_runway(self) -> bool:
return self.cp.captured and self.cp.runway_can_be_repaired

View File

@ -81,6 +81,18 @@ class CheatSettingsBox(QGroupBox):
self.base_capture_cheat = QLabeledWidget(
"Enable Base Capture Cheat:", self.base_capture_cheat_checkbox
)
self.base_runway_state_cheat_checkbox = QCheckBox()
self.base_runway_state_cheat_checkbox.setChecked(
game.settings.enable_runway_state_cheat
)
self.base_runway_state_cheat_checkbox.toggled.connect(apply_settings)
self.main_layout.addLayout(
QLabeledWidget(
"Enable runway state cheat:", self.base_runway_state_cheat_checkbox
)
)
self.main_layout.addLayout(self.base_capture_cheat)
self.transfer_cheat = QLabeledWidget(
"Enable Instant Squadron Transfer Cheat:", self.transfer_cheat_checkbox
@ -103,6 +115,9 @@ class CheatSettingsBox(QGroupBox):
def show_transfer_cheat(self) -> bool:
return self.transfer_cheat_checkbox.isChecked()
def enable_runway_state_cheat(self) -> bool:
return self.base_runway_state_cheat_checkbox.isChecked()
class AutoSettingsLayout(QGridLayout):
def __init__(
@ -451,6 +466,9 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
self.cheat_options.show_base_capture_cheat
)
self.settings.enable_transfer_cheat = self.cheat_options.show_transfer_cheat
self.game.settings.enable_runway_state_cheat = (
self.cheat_options.enable_runway_state_cheat
)
if self.game:
events = GameUpdateEvents()