Skip to content

Commit beecc77

Browse files
committed
feat: pause/unpause game when in modal
1 parent 5962984 commit beecc77

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

resources/js/clientScripts/pause.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { GamePieces } from './gamePieces';
22
import { controls } from './controls';
33
import { Game } from '../advclient';
44
import viewport from './viewport';
5+
import { gameEventBus } from '@/gameEventsBus';
56

67
export const pauseManager = {
78
togglePause() {
@@ -67,3 +68,11 @@ export const pauseManager = {
6768
Game.properties.requestId = window.requestAnimationFrame(Game.update);
6869
},
6970
};
71+
72+
gameEventBus.subscribe('GUIDE_OPEN', () => {
73+
pauseManager.pauseGame();
74+
});
75+
76+
gameEventBus.subscribe('GUIDE_CLOSED', () => {
77+
pauseManager.resumeGame();
78+
});

resources/js/gameEventsBus.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { GuideIdentifier } from '@/types/Guide';
55
export type GameEventMap = {
66
PLAYER_HEALTH_UPDATE: { health: number };
77
PLAYER_HUNTED_UPDATE: { isHunted: boolean };
8+
GUIDE_CLOSED: null;
89
GUIDE_OPEN: { guide: GuideIdentifier };
910
} & InputHandlerEvents &
1011
GameLoggerEvents &
@@ -26,6 +27,7 @@ class GameEventBus {
2627
PLAYER_HEALTH_UPDATE: [],
2728
PLAYER_HUNTED_UPDATE: [],
2829
GUIDE_OPEN: [],
30+
GUIDE_CLOSED: [],
2931
GAMELOGGER_MESSAGE_LOGGED: [],
3032
CHANGED_LOCATION: [],
3133
};

resources/js/ui/components/HUD/GuideModal.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ const openGuide = async (identifier: GuideIdentifier): Promise<void> => {
164164
const close = (): void => {
165165
isOpen.value = false;
166166
selectedGuide.value = null;
167+
gameEventBus.emit('GUIDE_CLOSED', null);
167168
};
168169
169170
defineExpose({

0 commit comments

Comments
 (0)