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,
|
Synchronized,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let numericUid = 1;
|
||||||
|
|
||||||
export class Entity extends decorate(Resource) {
|
export class Entity extends decorate(Resource) {
|
||||||
|
|
||||||
constructor(json) {
|
constructor(json) {
|
||||||
|
@ -97,6 +99,7 @@ export class Entity extends decorate(Resource) {
|
||||||
// Bind to prevent lookup overhead.
|
// Bind to prevent lookup overhead.
|
||||||
this.tick = this.tick.bind(this);
|
this.tick = this.tick.bind(this);
|
||||||
// Fast props.
|
// Fast props.
|
||||||
|
this.numericUid = numericUid++;
|
||||||
this.position = [0, 0];
|
this.position = [0, 0];
|
||||||
this.visibleAabb = [0, 0, 0, 0];
|
this.visibleAabb = [0, 0, 0, 0];
|
||||||
// Fast path for instance.
|
// Fast path for instance.
|
||||||
|
|
|
@ -6,11 +6,9 @@ export class EntityCreatePacket extends EntityPacket {
|
||||||
|
|
||||||
constructor(data, entity) {
|
constructor(data, entity) {
|
||||||
if ('undefined' !== typeof entity) {
|
if ('undefined' !== typeof entity) {
|
||||||
data.uuid = entity.instanceUuid;
|
|
||||||
data.layer = entity.layer.index;
|
data.layer = entity.layer.index;
|
||||||
}
|
}
|
||||||
super(data);
|
super(data, entity);
|
||||||
this.entity = entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static pack(packet) {
|
static pack(packet) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ export class EntityPacket extends Packet {
|
||||||
|
|
||||||
constructor(data, entity) {
|
constructor(data, entity) {
|
||||||
if ('undefined' !== typeof entity) {
|
if ('undefined' !== typeof entity) {
|
||||||
data.uuid = entity.instanceUuid;
|
data.uuid = entity.numericUid;
|
||||||
}
|
}
|
||||||
super(data);
|
super(data);
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
|
@ -14,7 +14,7 @@ export class EntityPacket extends Packet {
|
||||||
return {
|
return {
|
||||||
...super.schema,
|
...super.schema,
|
||||||
data: {
|
data: {
|
||||||
uuid: 'string',
|
uuid: 'uint32',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user