fix: control transfer

This commit is contained in:
cha0s 2024-09-13 17:54:40 -05:00
parent a54aed9b89
commit fc96f637ff

View File

@ -90,7 +90,13 @@ export default class Engine {
// dump entity state with updates for the transition
const dumped = {
...entity.toJSON(),
Controlled: entity.Controlled,
// manually transfer control
Controlled: {
moveUp: entity.Controlled.moveUp,
moveRight: entity.Controlled.moveRight,
moveDown: entity.Controlled.moveDown,
moveLeft: entity.Controlled.moveLeft,
},
Ecs: {path},
...updates,
};
@ -104,7 +110,7 @@ export default class Engine {
Promise.all(promises).then(async () => {
// recreate the entity in the new ECS and again associate it with the connection
connectedPlayer.entity = engine.ecses[path].get(await engine.ecses[path].create(dumped));
connectedPlayer.entity.Player.id = id
connectedPlayer.entity.Player.id = id;
});
}
}