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