fix: defer actions until connection entity exists

This commit is contained in:
cha0s 2024-07-02 18:01:50 -05:00
parent e65e9e30f6
commit e3ebe46bf4

View File

@ -51,15 +51,19 @@ export default class Engine {
}
}
this.server.addPacketListener('Action', (connection, payload) => {
this.incomingActions.push([this.connectedPlayers.get(connection).entity, payload]);
this.incomingActions.push([connection, payload]);
});
}
acceptActions() {
for (const [
entity,
connection,
payload,
] of this.incomingActions) {
if (!this.connectedPlayers.get(connection)) {
continue;
}
const {entity} = this.connectedPlayers.get(connection);
const {Controlled, Ecs, Interacts, Inventory, Wielder} = entity;
switch (payload.type) {
case 'changeSlot': {