silphius/app/ecs/components/interlocutor.js

29 lines
724 B
JavaScript
Raw Normal View History

2024-07-12 02:10:22 -05:00
import Component from '@/ecs/component.js';
export default class Interlocutor extends Component {
mergeDiff(original, update) {
const merged = {};
if (update.dialogue) {
merged.dialogue = {
...original.dialogue,
...update.dialogue,
}
}
return merged;
}
instanceFromSchema() {
const Component = this;
return class InterlocutorInstance extends super.instanceFromSchema() {
dialogues = {};
id = 0;
destroy() {
for (const key in this.dialogues) {
this.dialogues[key].onClose();
}
}
2024-07-12 02:10:22 -05:00
dialogue(specification) {
Component.markChange(this.entity, 'dialogue', {[this.id++]: specification});
}
};
}
}