refactor: surgical traitage

This commit is contained in:
cha0s 2021-02-05 02:10:49 -06:00
parent a7bf31715b
commit 960afcc46d
3 changed files with 20 additions and 5 deletions

View File

@ -15,7 +15,16 @@ export default () => {
if (!room) {
return;
}
setEntity(room.findEntity(selfEntity));
const augmentSelfEntity = async (entity) => {
if (entity) {
await entity.addTraits({
Controllable: {},
Followed: {},
});
}
setEntity(entity);
};
augmentSelfEntity(room.findEntity(selfEntity));
}, [room, selfEntity]);
return entity;
};

View File

@ -4,12 +4,14 @@ import {SenderSynchronizer} from '@avocado/s13n';
export default (latus) => class Informed extends Trait {
static type() {
return 'informed';
}
#synchronizer = new SenderSynchronizer(latus);
static dependencies() {
return [
'Followed',
];
}
destroy() {
this.#synchronizer.destroy();
}

View File

@ -29,6 +29,10 @@ export default (latus) => class ServerJoin extends Join() {
'cha0s',
'index.entity.json',
),
traits: {
Controllable: {},
Informed: {},
},
},
);
player = universe.addPlayer({