Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Feb 19, 2025
1 parent 5605b31 commit 7699ad1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/frontend/components/atoms/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export function Loading({
return;
}
if (progress === undefined) {
videoRef.current.playbackRate = 2;
videoRef.current.play();
return;
videoRef.current.playbackRate = 2;
videoRef.current.play();
return;
}
const expectedProgress = VIDEO_TIME_S * progress;
const currentTime = videoRef.current.currentTime;
Expand Down
18 changes: 13 additions & 5 deletions src/frontend/components/ingame-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import styles from "./ingame-view.module.css";
import { Game } from "../../game";
import { AmmoCount, GameReactChannel } from "../../interop/gamechannel";
import { WeaponSelector } from "./gameui/weapon-select";
import { IRunningGameInstance, LocalGameInstance } from "../../logic/gameinstance";
import {
IRunningGameInstance,
LocalGameInstance,
} from "../../logic/gameinstance";
import { LoadingPage } from "./loading-page";

export function IngameView({
Expand All @@ -23,16 +26,21 @@ export function IngameView({
const ref = useRef<HTMLDivElement>(null);
const [weaponMenu, setWeaponMenu] = useState<AmmoCount | null>(null);
useEffect(() => {

async function init() {
if (gameInstance instanceof LocalGameInstance) {
// XXX: Only so the game feels more responsive by capturing this inside the loading phase.
await gameInstance.startGame();
console.log("Game started");
}
const game = await Game.create(window, scenario, gameReactChannel, gameInstance, level);
const game = await Game.create(
window,
scenario,
gameReactChannel,
gameInstance,
level,
);
setGame(game);
game.ready$.subscribe(r => {
game.ready$.subscribe((r) => {
if (r) {
console.log("Game loaded");
setLoaded(true);
Expand All @@ -42,7 +50,7 @@ export function IngameView({
(globalThis as unknown as { wormgine: Game }).wormgine = game;
await game.loadResources();
}

void init().catch((ex) => {
setFatalError(ex);
});
Expand Down
12 changes: 10 additions & 2 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ import Logger from "./log";
import { CriticalGameError } from "./errors";
import { getGameSettings } from "./settings";
import { NetGameWorld } from "./net/netGameWorld";
import { BehaviorSubject, debounceTime, fromEvent, map, merge, Observable, of } from "rxjs";
import {
BehaviorSubject,
debounceTime,
fromEvent,
map,
merge,
Observable,
of,
} from "rxjs";
import { IRunningGameInstance } from "./logic/gameinstance";
import { RunningNetGameInstance } from "./net/netgameinstance";

Expand All @@ -30,7 +38,7 @@ export class Game {
public readonly rapierGfx: Graphics;
public readonly screenSize$: Observable<{ width: number; height: number }>;
private readonly ready = new BehaviorSubject(false);
public readonly ready$ = this.ready.asObservable() ;
public readonly ready$ = this.ready.asObservable();

public get pixiRoot() {
return this.viewport;
Expand Down

0 comments on commit 7699ad1

Please sign in to comment.