mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-01 05:17:04 +02:00
MISC: Cancel infiltration when player is hospitalized (#1579)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Button, Container, Paper, Typography } from "@mui/material";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { FactionName, ToastVariant } from "@enums";
|
||||
import { Router } from "../../ui/GameRoot";
|
||||
import { Page } from "../../ui/Router";
|
||||
@@ -16,6 +16,8 @@ import { Victory } from "./Victory";
|
||||
import { WireCuttingGame } from "./WireCuttingGame";
|
||||
import { calculateDamageAfterFailingInfiltration } from "../utils";
|
||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||
import { PlayerEventType, PlayerEvents } from "../../PersonObjects/Player/PlayerEvents";
|
||||
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||
|
||||
type GameProps = {
|
||||
StartingDifficulty: number;
|
||||
@@ -151,6 +153,17 @@ export function Game(props: GameProps): React.ReactElement {
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const clearSubscription = PlayerEvents.subscribe((eventType) => {
|
||||
if (eventType !== PlayerEventType.Hospitalized) {
|
||||
return;
|
||||
}
|
||||
cancel();
|
||||
dialogBoxCreate("Infiltration was cancelled because you were hospitalized");
|
||||
});
|
||||
return clearSubscription;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Paper sx={{ p: 1, mb: 1, display: "grid", justifyItems: "center", gap: 1 }}>
|
||||
|
||||
Reference in New Issue
Block a user