mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
This commit is contained in:
parent
f80ae5b948
commit
bdc35d0907
16 changed files with 143 additions and 27 deletions
|
|
@ -169,8 +169,29 @@ export interface PlayerState {
|
|||
team: Team,
|
||||
playerClass: Class,
|
||||
info: PlayerInfo,
|
||||
charge: number,
|
||||
class_data: PlayerClassState,
|
||||
ubered: boolean,
|
||||
cloaked: boolean,
|
||||
}
|
||||
|
||||
export type PlayerClassState = MedicState | SpyState | null;
|
||||
|
||||
export enum MedigunType {
|
||||
Uber = 0,
|
||||
Kritzkrieg = 1,
|
||||
Quickfix = 2,
|
||||
Vaccinator = 3,
|
||||
}
|
||||
|
||||
export interface MedicState {
|
||||
charge: number,
|
||||
medigun: MedigunType
|
||||
}
|
||||
|
||||
export interface SpyState {
|
||||
disguise_team: Team,
|
||||
disguise_class: Class,
|
||||
cloak: number,
|
||||
}
|
||||
|
||||
export interface BuildingState {
|
||||
|
|
@ -307,7 +328,7 @@ export class ParsedDemo {
|
|||
}
|
||||
}
|
||||
|
||||
const PLAYER_PACK_SIZE = 8;
|
||||
const PLAYER_PACK_SIZE = 9;
|
||||
const BUILDING_PACK_SIZE = 7;
|
||||
const PROJECTILE_PACK_SIZE = 6;
|
||||
const CART_PACK_SIZE = 4;
|
||||
|
|
@ -321,7 +342,25 @@ function unpackPlayer(bytes: Uint8Array, base: number, world: WorldBoundaries, i
|
|||
const health = (team_class_health >> 1) & 511;
|
||||
const team = (team_class_health >> 14) as Team;
|
||||
const playerClass = ((team_class_health >> 10) & 15) as Class;
|
||||
const charge = bytes[base + 7];
|
||||
const class_bits = [bytes[base + 7], bytes[base + 8]];
|
||||
let class_data = null;
|
||||
let cloaked = false;
|
||||
switch (playerClass) {
|
||||
case Class.Medic:
|
||||
class_data = {
|
||||
charge: class_bits[0],
|
||||
medigun: class_bits[1],
|
||||
}
|
||||
break;
|
||||
case Class.Spy:
|
||||
class_data = {
|
||||
disguise_team: class_bits[0] >> 6,
|
||||
disguise_class: class_bits[0] >> 2 & 15,
|
||||
cloak: class_bits[1] >> 1,
|
||||
}
|
||||
cloaked = (class_bits[1] & 1) === 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
position: {x, y},
|
||||
|
|
@ -330,8 +369,9 @@ function unpackPlayer(bytes: Uint8Array, base: number, world: WorldBoundaries, i
|
|||
team,
|
||||
playerClass,
|
||||
info,
|
||||
charge,
|
||||
class_data,
|
||||
ubered,
|
||||
cloaked,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue