silphius/app/ecs/components/emitter.js
2024-07-24 09:28:35 -05:00

25 lines
569 B
JavaScript

import Component from '@/ecs/component.js';
export default class Emitter extends Component {
instanceFromSchema() {
const Component = this;
return class EmitterInstance extends super.instanceFromSchema() {
emitting = {};
id = 0;
emit(specification) {
Component.markChange(this.entity, 'emit', {[this.id++]: specification});
}
};
}
mergeDiff(original, update) {
const merged = {};
if (update.emit) {
merged.emit = {
...original.emit,
...update.emit,
}
}
return merged;
}
}