Skip to content

Commit fe98e88

Browse files
committed
mirage breakables
1 parent 1ff9a0b commit fe98e88

123 files changed

Lines changed: 11830 additions & 308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dockerignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
!packages/assets/public/models/maps/mirage-physics.glb.gz
2121
!packages/assets/public/models/maps/mirage-nav.json
2222
!packages/assets/public/models/maps/mirage-bomb.bin.gz
23+
!packages/assets/public/models/maps/mirage-breakables.json
2324
!packages/protocol/
2425
!packages/protocol/**
2526
!packages/simulation/

‎.github/workflows/deploy.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
if ! git diff --quiet "$BEFORE" HEAD -- apps/game scripts/build-assets.mjs scripts/service-worker.js turbo.json; then
4949
client=true
5050
fi
51-
if ! git diff --quiet "$BEFORE" HEAD -- apps/server Dockerfile .dockerignore 'packages/assets/public/models/maps/*-physics.glb.gz' 'packages/assets/public/models/maps/*-nav.json' 'packages/assets/public/models/maps/*-bomb.bin.gz'; then
51+
if ! git diff --quiet "$BEFORE" HEAD -- apps/server Dockerfile .dockerignore 'packages/assets/public/models/maps/*-physics.glb.gz' 'packages/assets/public/models/maps/*-nav.json' 'packages/assets/public/models/maps/*-bomb.bin.gz' 'packages/assets/public/models/maps/*-breakables.json'; then
5252
server=true
5353
fi
5454
fi
@@ -189,6 +189,7 @@ jobs:
189189
/packages/assets/public/models/maps/mirage-physics.glb.gz
190190
/packages/assets/public/models/maps/mirage-nav.json
191191
/packages/assets/public/models/maps/mirage-bomb.bin.gz
192+
/packages/assets/public/models/maps/mirage-breakables.json
192193
- uses: docker/setup-buildx-action@v4
193194
- name: Log in to DHI
194195
uses: docker/login-action@v4

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LABEL org.opencontainers.image.source=https://github.com/3kh0/cs2go \
2020
org.opencontainers.image.description="CS2GO authoritative multiplayer server, powered by Bun"
2121
ENV NODE_ENV=production PORT=3001 ALLOWED_ORIGINS=https://cs2go.3kh0.net MAP_DIRECTORY=/app/maps
2222
COPY --from=build --chown=65532:65532 /app/apps/server/dist/index.js ./server.js
23-
COPY --chown=65532:65532 packages/assets/public/models/maps/dust2-physics.glb.gz packages/assets/public/models/maps/dust2-nav.json packages/assets/public/models/maps/mirage-physics.glb.gz packages/assets/public/models/maps/mirage-nav.json packages/assets/public/models/maps/dust2-bomb.bin.gz packages/assets/public/models/maps/mirage-bomb.bin.gz ./maps/
23+
COPY --chown=65532:65532 packages/assets/public/models/maps/dust2-physics.glb.gz packages/assets/public/models/maps/dust2-nav.json packages/assets/public/models/maps/mirage-physics.glb.gz packages/assets/public/models/maps/mirage-nav.json packages/assets/public/models/maps/dust2-bomb.bin.gz packages/assets/public/models/maps/mirage-bomb.bin.gz packages/assets/public/models/maps/mirage-breakables.json ./maps/
2424
USER 65532:65532
2525
EXPOSE 3001
2626
HEALTHCHECK --interval=15s --timeout=3s --start-period=5s --retries=3 \

‎apps/game/src/app.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ${homeMenuMarkup()}
4545
<div class="match-top" role="group" aria-label="Match status"><div class="match-alive ct" aria-label="Counter-Terrorists alive"><strong id="ct-alive">0</strong><small>ALIVE</small></div><div class="match-center"><strong id="clock" aria-label="Round time">5:00</strong><div class="match-scores"><span class="ct" id="score" aria-label="Counter-Terrorists score">0</span><span class="t" id="enemy-score" aria-label="Terrorists score">0</span></div></div><div class="match-alive t" aria-label="Terrorists alive"><strong id="t-alive">0</strong><small>ALIVE</small></div></div>
4646
<div id="killfeed" role="list" aria-label="Eliminations" aria-live="polite"></div><div id="crosshair"><i></i><i></i><i></i><i></i><b></b></div><div id="hitmarker">×</div><div id="damage"></div>
4747
<div id="death-banner" class="hidden" role="status"><div class="death-details"><strong id="death-killer"></strong><div><span class="death-message">killed you with the </span><span id="death-weapon"></span></div></div><img id="death-weapon-icon" alt=""></div>
48-
${matchNoticesMarkup()}<div id="inventory" role="list" aria-label="Weapon inventory"></div><div class="hud-bottom"><div class="vitals"><span class="armor" aria-label="Armor"><svg viewBox="0 0 40 46" aria-hidden="true"><path d="M8 10V5h24v5l5 4v14c0 8-9 13-17 16C12 41 3 36 3 28V14Z" fill="none" stroke="currentColor" stroke-width="2"/></svg><b id="armor">100</b></span><span class="health-stat" aria-label="Health"><b id="health">100</b><span class="health-track"><i id="health-fill"></i></span></span></div><div class="hud-team" aria-label="Your team"><span></span><img id="hud-team-icon" src="/icons/team-ct.png" alt="Counter-Terrorists"><span></span></div><div class="ammo"><div id="gun-name">USP-S</div><b id="ammo">12</b><span>/ <span id="reserve">48</span></span></div></div>
48+
${matchNoticesMarkup()}<div id="inventory" role="list" aria-label="Weapon inventory"></div><div class="hud-bottom"><div class="vitals"><span id="armor-state" class="armor" aria-label="Armor" data-helmet="true"><img class="armor-vest" src="/icons/hud/armor.svg" alt=""><img class="armor-helmet" src="/icons/hud/armor_helmet.svg" alt=""><b id="armor">100</b></span><span class="health-stat" aria-label="Health"><b id="health">100</b><span class="health-track"><i id="health-fill"></i></span></span></div><div class="hud-team" aria-label="Your team"><span></span><img id="hud-team-icon" src="/icons/team-ct.png" alt="Counter-Terrorists"><span></span></div><div class="ammo"><div id="gun-name">USP-S</div><b id="ammo">12</b><span>/ <span id="reserve">48</span></span></div></div>
4949
5050
<div id="telemetry">0 FPS &nbsp; - &nbsp; – MS FRAME &nbsp; - &nbsp; 128 TICK</div>
5151
<div id="scoreboard" class="hidden" role="region" aria-label="Match scoreboard"><header class="scoreboard-title"><h2></h2><span id="scoreboard-clock"></span></header><div id="scoreboard-rows"></div><footer id="scoreboard-lobby" hidden><span>LOBBY ID <strong id="lobby-pin"></strong></span><span id="lobby-server"></span></footer></div>

‎apps/game/src/audio-source.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,27 @@ it("every packed effect has verified native CS2 or pinned supplemental C4 proven
139139
expect(clip.resourceSha256).toMatch(/^[a-f0-9]{64}$/);
140140
sources.set(`/audio/source/${name}.ogg`, clip.outputSha256);
141141
}
142+
const breaks = JSON.parse(
143+
readFileSync("../../packages/assets/public/audio/source/mirage-break-sounds.json", "utf8"),
144+
);
145+
expect(breaks.source).toBe("Read-only installed CS2 via Windows Amp runner");
146+
expect(breaks.resourceSha256).toMatch(/^[a-f0-9]{64}$/);
147+
expect(breaks.clips).toHaveLength(8);
148+
for (const clip of breaks.clips) {
149+
expect(breaks.soundEvents[clip.sourceEvent].vsnd_files_track_01).toContain(
150+
clip.resource.replace(/_c$/, ""),
151+
);
152+
expect(clip.resourceSha256).toMatch(/^[a-f0-9]{64}$/);
153+
expect(clip.sourceEventResourceSha256).toBe(breaks.resourceSha256);
154+
expect(
155+
manifest.clips.find((entry: { name: string }) => entry.name === clip.name),
156+
).toMatchObject({
157+
resource: clip.resource,
158+
outputSha256: clip.outputSha256,
159+
sourceEvent: clip.sourceEvent,
160+
});
161+
sources.set(`/audio/source/${clip.name}.ogg`, clip.outputSha256);
162+
}
142163
expect(bank.clips).toHaveLength(sources.size);
143164
for (const clip of bank.clips) {
144165
expect(sources.get(clip.url), clip.url).toBe(clip.sha256);

‎apps/game/src/dust2.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import { loadGzipped } from "./gltf";
2121
import { dustCollision } from "@cs2go/simulation/dust-map";
2222
import { Navigation } from "./navigation";
2323
import { loadNativeMapSky } from "./native-map-sky";
24+
import { applySourceSelfIllumination, type SourceSelfIllumination } from "./source-self-illum";
25+
import { loadNativeMapProbes, applyNativeMapProbes } from "./native-map-probes";
26+
import { loadNativeMapLayers, applyNativeMapLayers } from "./native-map-layers";
27+
import { BreakableWorld, bindBreakablePhysics } from "@cs2go/simulation/breakables";
28+
import { NativeMapBreakableView, type NativeBreakableManifest } from "./map-breakable-view";
2429
import type { MapNavigation } from "./navigation";
2530
import type { Wall } from "./physics";
2631
export type NativeMapConfig = {
@@ -67,6 +72,10 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
6772
nativeLighting,
6873
grade,
6974
nativeSky,
75+
nativeMaterials,
76+
nativeProbes,
77+
nativeLayers,
78+
breakableData,
7079
] = await Promise.all([
7180
loadGzipped(`/models/maps/${id}.glb.gz`, 1),
7281
assetFetch(`/models/maps/${id}-nav.json`),
@@ -79,6 +88,24 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
7988
config.lighting ? loadNativeMapLighting(config.lighting, renderer) : undefined,
8089
config.postprocess ? loadNativeMapGrade(config.postprocess) : undefined,
8190
config.skyWorld ? loadNativeMapSky(renderer, config.skyWorld, skyLoad, config.sun) : undefined,
91+
sourceLighting
92+
? undefined
93+
: assetFetch(`/models/maps/${id}-materials.json`).then(async (r) => {
94+
if (!r.ok) throw new Error(`${id} native material configuration unavailable`);
95+
return r.json() as Promise<{
96+
materials: { name: string; selfIllumination?: SourceSelfIllumination }[];
97+
}>;
98+
}),
99+
sourceLighting
100+
? undefined
101+
: loadNativeMapProbes(renderer, `/models/maps/${id}-lighting/gpu-probes/`),
102+
sourceLighting ? undefined : loadNativeMapLayers(renderer, id),
103+
id === "mirage"
104+
? assetFetch(`/models/maps/${id}-breakables.json`).then(async (r) => {
105+
if (!r.ok) throw new Error(`${id} native breakable configuration unavailable`);
106+
return r.json() as Promise<NativeBreakableManifest>;
107+
})
108+
: ({ version: 1, mapId: id, breakables: [] } as NativeBreakableManifest),
82109
]);
83110
// Native particle ropes are absent from the world export. Their settled tubes are baked offline and share static map lighting; native static_collision=false!
84111
if (cables) asset.scene.add(cables.scene);
@@ -118,6 +145,7 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
118145
root.add(asset.scene);
119146
if (mapSky) root.add(mapSky);
120147
asset.scene.updateMatrixWorld(true);
148+
const emissiveMaterials = new Set<T.Material>();
121149
asset.scene.traverse((object) => {
122150
if (!(object instanceof T.Mesh)) return;
123151
const material = (
@@ -136,7 +164,16 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
136164
object.castShadow = object.receiveShadow = true;
137165
// Preserve the native albedo. The shared scenery grade runs once, after lighting.
138166
for (const tex of [material.map, material.normalMap]) if (tex) tex.anisotropy = 8;
167+
for (const entry of Array.isArray(object.material) ? object.material : [object.material]) {
168+
if (!(entry instanceof T.MeshStandardMaterial) || emissiveMaterials.has(entry)) continue;
169+
emissiveMaterials.add(entry);
170+
const source = nativeMaterials?.materials.find(
171+
(m) => m.name === entry.name,
172+
)?.selfIllumination;
173+
if (source) applySourceSelfIllumination(entry, source);
174+
}
139175
});
176+
if (nativeLayers) applyNativeMapLayers(asset.scene, nativeLayers);
140177
if (lighting) applySourceMapLighting(asset.scene, lighting);
141178
else {
142179
// Cache architecture shadows, but refresh moving actors in a separate atlas.
@@ -159,13 +196,17 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
159196
}
160197
}
161198
if (nativeLighting) applyNativeMapLighting(asset.scene, nativeLighting);
199+
if (nativeProbes) applyNativeMapProbes(asset.scene, nativeProbes);
162200
if (grade) gradeNativeMapColors(asset.scene);
163201
// The imported architecture never moves; skip its per-frame matrix updates.
164202
asset.scene.traverse((object) => {
165203
object.matrixAutoUpdate = false;
166204
object.matrixWorldAutoUpdate = false;
167205
});
206+
bindBreakablePhysics(physics.scene, breakableData.breakables, breakableData.enabledRemainders);
168207
const { collision, grenadeCollision } = dustCollision(physics.scene);
208+
const breakables = new BreakableWorld(collision, breakableData.breakables);
209+
const breakableView = new NativeMapBreakableView(root, asset.scene, breakableData, collision);
169210
const ball = new WorldBall(root, collision, id === "dust2" || !!data.worldBallOrigin);
170211
physics.scene.traverse((object) => {
171212
if (!(object instanceof T.Mesh)) return;
@@ -267,6 +308,9 @@ export async function loadNativeMap(scene: T.Scene, renderer: T.WebGLRenderer, i
267308
sky,
268309
skybox: mapSky,
269310
nativeSky,
311+
breakables,
312+
breakableView,
313+
sun,
270314
bombDamage,
271315
};
272316
}

‎apps/game/src/game-utility.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,11 @@ export class GameUtility {
614614
weapon: p.weapon,
615615
};
616616
if (p.kind === "he") {
617+
if (
618+
!g.network &&
619+
g.world.breakables?.damageRadius(p.position, data.radius, heDamage, "explosion").length
620+
)
621+
g.syncMapBreakables(true, p.position);
617622
this.areaDamage(effect, 0, data.radius);
618623
for (const e of this.effects)
619624
if (

0 commit comments

Comments
 (0)