fix: defer actions until connection entity exists
This commit is contained in:
parent
e65e9e30f6
commit
e3ebe46bf4
|
@ -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': {
|
||||
|
|
Loading…
Reference in New Issue
Block a user