refactor: remove packers

This commit is contained in:
cha0s 2024-11-15 22:33:00 -06:00
parent b773f44c31
commit 0c234de26d
2 changed files with 1 additions and 40 deletions

View File

@ -15,12 +15,4 @@ export default class Packet {
return new DataView(encoder.bytes.buffer, 0, encoder.pos);
}
static pack(payload) {
return payload;
}
static unpack(packed) {
return packed;
}
}

View File

@ -1,34 +1,3 @@
import Packet from '@/silphius/net/packet.js';
const WIRE_MAP = {
'moveUp': 0,
'moveRight': 1,
'moveDown': 2,
'moveLeft': 3,
'use': 4,
'changeSlot': 5,
'interact': 6,
};
Object.entries(WIRE_MAP)
.forEach(([k, v]) => {
WIRE_MAP[v] = k;
});
export default class Action extends Packet {
static pack(payload) {
return super.pack({
type: WIRE_MAP[payload.type],
value: payload.value,
});
}
static unpack(packed) {
const unpacked = super.unpack(packed);
return {
type: WIRE_MAP[unpacked.type],
value: unpacked.value,
};
}
}
export default class Action extends Packet {}