refactor: no resize

This commit is contained in:
cha0s 2021-01-10 03:38:34 -06:00
parent 757573f039
commit 21a223f943
2 changed files with 1 additions and 47 deletions

View File

@ -1,25 +0,0 @@
import {Vector} from '@avocado/math';
import {SynchronizedUpdatePacket} from '@avocado/s13n';
export default class RoomUpdateSizePacket extends SynchronizedUpdatePacket {
static pack(packet) {
const data = packet.data[1];
data.size = Vector.packToUint32(data.size);
return super.pack(packet);
}
static get synchronizationSchema() {
return {
size: 'uint32',
};
}
static unpack(packet) {
const unpacked = super.unpack(packet);
const {data} = unpacked;
data.size = Vector.unpackFromUint32(data.size);
return unpacked;
}
}

View File

@ -21,7 +21,6 @@ const decorate = compose(
}),
Vector.Mixin('size', 'width', 'height', {
default: [0, 0],
track: true,
}),
);
@ -32,7 +31,6 @@ export default (latus) => class Room extends decorate(JsonResource) {
constructor({layers, size} = {}) {
super();
this.bounds = [];
this._sizeChanged = false;
this._synchronizationId = synchronizationId++;
this.layers = layers;
// Listeners.
@ -43,7 +41,6 @@ export default (latus) => class Room extends decorate(JsonResource) {
for (let i = 0; i < allEntities.length; i++) {
this.onEntityAddedToRoom(allEntities[i]);
}
this.on('sizeChanged', this.onSizeChanged, this);
this.on('worldChanged', this.onWorldChanged, this);
if (size) {
this.size = size;
@ -51,10 +48,6 @@ export default (latus) => class Room extends decorate(JsonResource) {
}
acceptPacket(packet) {
// Size update.
if ('RoomUpdateSize' === packet.constructor.type) {
this.size = packet.data.size;
}
// Layer updates.
if ('RoomUpdateLayers' === packet.constructor.type) {
const {layersPackets} = packet.data;
@ -74,7 +67,6 @@ export default (latus) => class Room extends decorate(JsonResource) {
cleanPackets() {
super.cleanPackets();
this._sizeChanged = false;
this.layers.cleanPackets();
}
@ -118,11 +110,6 @@ export default (latus) => class Room extends decorate(JsonResource) {
layer.world = this.world;
}
onSizeChanged() {
this._sizeChanged = true;
this.updateBounds();
}
onWorldChanged() {
this.layers.world = this.world;
// Update bounds.
@ -131,19 +118,11 @@ export default (latus) => class Room extends decorate(JsonResource) {
packets(informed) {
const payload = [];
if (this._sizeChanged) {
payload.push([
'RoomUpdateSizePacket',
{
size: this.size,
},
]);
}
// Layer updates.
const layersPackets = normalize(this.layers.packets(informed));
if (layersPackets.length > 0) {
payload.push([
'RoomUpdateLayersPacket',
'RoomUpdateLayers',
{
layersPackets,
},