1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 00:54:14 +02:00

entity encoder wip

This commit is contained in:
Robin Appelman 2017-09-09 02:50:51 +02:00
commit 206facfa8d
17 changed files with 733 additions and 174 deletions

View file

@ -12,7 +12,7 @@ import {EntityId, PacketEntity} from './PacketEntity';
import {Player} from './Player';
import {PlayerResource} from './PlayerResource';
import {SendTable, SendTableName} from './SendTable';
import {ServerClass} from './ServerClass';
import {ServerClass, ServerClassId} from './ServerClass';
import {StringTable} from './StringTable';
import {Team, TeamNumber} from './Team';
import {UserInfo} from './UserInfo';
@ -31,7 +31,7 @@ export class Match {
public rounds: Round[] = [];
public startTick: number = 0;
public intervalPerTick: number = 0;
public staticBaseLines: BitStream[] = [];
public staticBaseLines: Map<ServerClassId, BitStream> = new Map();
public eventDefinitions: Map<number, GameEventDefinition<GameEventType>> = new Map();
public world: World = {
boundaryMin: {x: 0, y: 0, z: 0},

View file

@ -1,6 +1,6 @@
import {BitStream} from 'bit-buffer';
import {GameEventDefinition} from './GameEvent';
import {PacketEntity} from './PacketEntity';
import {EntityId, PacketEntity} from './PacketEntity';
import {SendTable} from './SendTable';
import {ServerClass} from './ServerClass';
import {StringTable, StringTableEntry} from './StringTable';
@ -82,13 +82,10 @@ export interface GameEventListPacket extends BasePacket {
export interface PacketEntitiesPacket extends BasePacket {
packetType: 'packetEntities';
entities: PacketEntity[];
removedEntities: number[];
removedEntities: EntityId[];
maxEntries: number;
isDelta: boolean;
delta: number;
baseLine: number;
updatedEntries: number;
length: number;
updatedBaseLine: boolean;
}

View file

@ -64,4 +64,11 @@ export class PacketEntity {
}
}
}
public diffFromBaseLine(baseline: PacketEntity): SendProp[] {
return this.props.filter(prop => {
const baseProp = baseline.getPropByDefinition(prop.definition);
return (!baseProp || prop.value !== baseProp.value);
});
}
}

View file

@ -1,9 +1,11 @@
export type ServerClassId = number;
export class ServerClass {
public id: number;
public id: ServerClassId;
public name: string;
public dataTable: string;
constructor(id: number, name: string, dataTable: string) {
constructor(id: ServerClassId, name: string, dataTable: string) {
this.id = id;
this.name = name;
this.dataTable = dataTable;