2024-06-26 21:08:09 -05:00
|
|
|
import Component from '@/ecs/component.js';
|
2024-06-26 04:18:46 -05:00
|
|
|
|
2024-06-26 21:08:09 -05:00
|
|
|
export default class Emitter extends Component {
|
|
|
|
mergeDiff(original, update) {
|
|
|
|
const merged = {};
|
|
|
|
if (update.emit) {
|
|
|
|
merged.emit = {
|
|
|
|
...original.emit,
|
|
|
|
...update.emit,
|
2024-06-26 04:18:46 -05:00
|
|
|
}
|
|
|
|
}
|
2024-06-26 21:08:09 -05:00
|
|
|
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});
|
|
|
|
}
|
|
|
|
};
|
2024-06-26 04:18:46 -05:00
|
|
|
}
|
2024-06-26 21:08:09 -05:00
|
|
|
}
|