Compare commits

...

3 Commits

Author SHA1 Message Date
cha0s
e3ebe46bf4 fix: defer actions until connection entity exists 2024-07-02 18:01:50 -05:00
cha0s
e65e9e30f6 fix: off-by-one 2024-07-02 18:01:31 -05:00
cha0s
69c3a87da3 fix: omega derp 2024-07-02 17:51:58 -05:00
3 changed files with 10 additions and 5 deletions

View File

@ -268,6 +268,7 @@ export default class Ecs {
markChange(entityId, components) {
if (this.deferredChanges[entityId]) {
this.deferredChanges[entityId].push(components);
return;
}
// Deleted?
if (false === components) {

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': {

View File

@ -13,9 +13,9 @@ if (projected?.length > 0) {
bodies: [
[
{x: -8, y: -8},
{x: 8, y: -8},
{x: -8, y: 8},
{x: 8, y: 8},
{x: 7, y: -8},
{x: -8, y: 7},
{x: 7, y: 7},
],
],
},