update
This commit is contained in:
parent
02b2a8efc8
commit
0d9b4b0453
@ -344,8 +344,48 @@ export default function LiveRadar({ matchId }: Props) {
|
|||||||
if (kind.includes('molotov') || kind.includes('incen') || kind.includes('fire')) removeEffect('fire', { id })
|
if (kind.includes('molotov') || kind.includes('incen') || kind.includes('fire')) removeEffect('fire', { id })
|
||||||
markEnded()
|
markEnded()
|
||||||
}
|
}
|
||||||
|
syncNadePaths()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Server: sofort nach Spawn eines Projektils
|
||||||
|
const handleNadeCreate = (m: any) => {
|
||||||
|
const id = String(m?.id ?? '')
|
||||||
|
if (!id) return
|
||||||
|
const kind = String(m?.kind ?? '').toLowerCase()
|
||||||
|
const pos = m.pos ?? {}
|
||||||
|
const t = Number(m?.t ?? Date.now())
|
||||||
|
|
||||||
|
upsertNadeTrace({ id, kind, t, pos, state: 'spawn' })
|
||||||
|
syncNadePaths()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server: periodischer Snapshot aller aktiven Projektile
|
||||||
|
const handleNadesSnapshot = (snap: any) => {
|
||||||
|
const t = Number(snap?.t ?? Date.now())
|
||||||
|
const arr = Array.isArray(snap?.nades) ? snap.nades : []
|
||||||
|
for (const n of arr) {
|
||||||
|
const id = String(n?.id ?? '')
|
||||||
|
if (!id) continue
|
||||||
|
const kind = String(n?.kind ?? '').toLowerCase()
|
||||||
|
const pos = n.pos ?? {}
|
||||||
|
// optional: Geschwindigkeit als „s“ (Segment) mitgeben – hier nicht zwingend nötig
|
||||||
|
upsertNadeTrace({ id, kind, t, pos })
|
||||||
|
}
|
||||||
|
syncNadePaths()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Server: Detonation (HE/Flash/Smoke/Molly/Decoy)
|
||||||
|
const handleNadeExplode = (m: any) => {
|
||||||
|
const id = m?.id != null ? String(m.id) : ''
|
||||||
|
const kind = String(m?.kind ?? '').toLowerCase()
|
||||||
|
const pos = m.pos ?? m
|
||||||
|
const t = Number(m?.t ?? Date.now())
|
||||||
|
upsertNadeTrace({ id, kind, t, pos, state: 'detonate' })
|
||||||
|
// Effekte bei Smoke / Fire starten (wird in upsertNadeTrace ohnehin getan)
|
||||||
|
syncNadePaths()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
if (!alive) return
|
if (!alive) return
|
||||||
setWsStatus('connecting')
|
setWsStatus('connecting')
|
||||||
@ -357,8 +397,12 @@ export default function LiveRadar({ matchId }: Props) {
|
|||||||
let msg: any = null
|
let msg: any = null
|
||||||
try { msg = JSON.parse(ev.data as string) } catch {}
|
try { msg = JSON.parse(ev.data as string) } catch {}
|
||||||
|
|
||||||
const handleEvent = (e: any) => {
|
const dispatch = (e: any) => {
|
||||||
if (!e) return
|
if (!e) return
|
||||||
|
|
||||||
|
if (e.type === 'nade_create') { handleNadeCreate(e); return }
|
||||||
|
if (e.type === 'nades' && Array.isArray(e.nades)) { handleNadesSnapshot(e); return }
|
||||||
|
if (e.type === 'nade_explode') { handleNadeExplode(e); return }
|
||||||
|
|
||||||
// Map wechseln
|
// Map wechseln
|
||||||
if (e.type === 'map' || e.type === 'level' || e.map) {
|
if (e.type === 'map' || e.type === 'level' || e.map) {
|
||||||
@ -378,6 +422,8 @@ export default function LiveRadar({ matchId }: Props) {
|
|||||||
// Grenade-Traces
|
// Grenade-Traces
|
||||||
if (e.type === 'nade' || e.kind || e.nade || e.weapon) {
|
if (e.type === 'nade' || e.kind || e.nade || e.weapon) {
|
||||||
upsertNadeTrace(e)
|
upsertNadeTrace(e)
|
||||||
|
syncNadePaths()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spieler
|
// Spieler
|
||||||
@ -405,7 +451,7 @@ export default function LiveRadar({ matchId }: Props) {
|
|||||||
|
|
||||||
const yawDegRaw = deriveYawDeg(rawYaw, prev, x, y)
|
const yawDegRaw = deriveYawDeg(rawYaw, prev, x, y)
|
||||||
// Sanftes Smoothing, damit kleine Änderungen sichtbar & stabil sind
|
// Sanftes Smoothing, damit kleine Änderungen sichtbar & stabil sind
|
||||||
const YAW_SMOOTH = 0.01
|
const YAW_SMOOTH = 0.30
|
||||||
const yawDeg = prev ? lerpAngleDeg(prev.yaw, yawDegRaw, YAW_SMOOTH) : yawDegRaw
|
const yawDeg = prev ? lerpAngleDeg(prev.yaw, yawDegRaw, YAW_SMOOTH) : yawDegRaw
|
||||||
|
|
||||||
const p: PlayerState = {
|
const p: PlayerState = {
|
||||||
@ -420,11 +466,11 @@ export default function LiveRadar({ matchId }: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(msg)) {
|
if (Array.isArray(msg)) {
|
||||||
for (const e of msg) handleEvent(e)
|
for (const e of msg) dispatch(e)
|
||||||
} else if (msg?.type === 'tick' && Array.isArray(msg.players)) {
|
} else if (msg?.type === 'tick' && Array.isArray(msg.players)) {
|
||||||
for (const p of msg.players) handleEvent(p)
|
for (const p of msg.players) dispatch(p)
|
||||||
} else {
|
} else {
|
||||||
handleEvent(msg)
|
dispatch(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleFlush()
|
scheduleFlush()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user