29 lines
745 B
JavaScript
29 lines
745 B
JavaScript
import Component from '@/ecs/component.js';
|
|
|
|
export default class Interlocutor extends Component {
|
|
mergeDiff(original, update) {
|
|
const merged = {};
|
|
if (original.dialogue || 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();
|
|
}
|
|
}
|
|
dialogue(specification) {
|
|
Component.markChange(this.entity, 'dialogue', {[this.id++]: specification});
|
|
}
|
|
};
|
|
}
|
|
} |