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

add entity update encoder

This commit is contained in:
Robin Appelman 2017-09-04 23:01:48 +02:00
commit c064439b4e
11 changed files with 1786 additions and 43 deletions

View file

@ -53,4 +53,15 @@ export class PacketEntity {
}
return result;
}
public applyPropUpdate(props: SendProp[]) {
for (const prop of props) {
const existingProp = this.getPropByDefinition(prop.definition);
if (existingProp) {
existingProp.value = prop.value;
} else {
this.props.push(prop);
}
}
}
}

View file

@ -53,6 +53,27 @@ export class SendPropDefinition {
return data;
}
get fullName() {
return `${this.ownerTableName}.${this.name}`;
}
get allFlags() {
return SendPropDefinition.formatFlags(this.flags);
}
static formatFlags(flags: number) {
let names: string[] = [];
for (const name in SendPropFlag) {
const flagValue = <SendPropFlag | string>SendPropFlag[name];
if (typeof flagValue === 'number') {
if (flags & flagValue) {
names.push(name);
}
}
}
return names;
}
}
export enum SendPropType {

View file

@ -48,7 +48,7 @@ export class SendTable {
}
}
get flattenedProps() {
get flattenedProps(): SendPropDefinition[] {
if (this.cachedFlattenedProps.length === 0) {
this.flatten();
}