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:
parent
7b9131b7fe
commit
c064439b4e
11 changed files with 1786 additions and 43 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export class SendTable {
|
|||
}
|
||||
}
|
||||
|
||||
get flattenedProps() {
|
||||
get flattenedProps(): SendPropDefinition[] {
|
||||
if (this.cachedFlattenedProps.length === 0) {
|
||||
this.flatten();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue