perf: only send a numeric ID over the wire
This commit is contained in:
parent
769338a946
commit
2fc0b35eee
|
@ -81,6 +81,8 @@ const decorate = compose(
|
|||
Synchronized,
|
||||
);
|
||||
|
||||
let numericUid = 1;
|
||||
|
||||
export class Entity extends decorate(Resource) {
|
||||
|
||||
constructor(json) {
|
||||
|
@ -97,6 +99,7 @@ export class Entity extends decorate(Resource) {
|
|||
// Bind to prevent lookup overhead.
|
||||
this.tick = this.tick.bind(this);
|
||||
// Fast props.
|
||||
this.numericUid = numericUid++;
|
||||
this.position = [0, 0];
|
||||
this.visibleAabb = [0, 0, 0, 0];
|
||||
// Fast path for instance.
|
||||
|
|
|
@ -6,11 +6,9 @@ export class EntityCreatePacket extends EntityPacket {
|
|||
|
||||
constructor(data, entity) {
|
||||
if ('undefined' !== typeof entity) {
|
||||
data.uuid = entity.instanceUuid;
|
||||
data.layer = entity.layer.index;
|
||||
}
|
||||
super(data);
|
||||
this.entity = entity;
|
||||
super(data, entity);
|
||||
}
|
||||
|
||||
static pack(packet) {
|
||||
|
|
|
@ -4,7 +4,7 @@ export class EntityPacket extends Packet {
|
|||
|
||||
constructor(data, entity) {
|
||||
if ('undefined' !== typeof entity) {
|
||||
data.uuid = entity.instanceUuid;
|
||||
data.uuid = entity.numericUid;
|
||||
}
|
||||
super(data);
|
||||
this.entity = entity;
|
||||
|
@ -14,7 +14,7 @@ export class EntityPacket extends Packet {
|
|||
return {
|
||||
...super.schema,
|
||||
data: {
|
||||
uuid: 'string',
|
||||
uuid: 'uint32',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user