silphius/app/ecs-components/sound.js
2024-06-26 21:36:45 -05:00

24 lines
543 B
JavaScript

import Component from '@/ecs/component.js';
export default class Sound extends Component {
mergeDiff(original, update) {
const merged = {};
if (update.play) {
merged.play = [
...(original.play ?? []),
...update.play,
];
}
return merged;
}
instanceFromSchema() {
const Component = this;
const Instance = super.instanceFromSchema();
return class SoundInstance extends Instance {
play(source) {
Component.markChange(this.entity, 'play', [source]);
}
};
}
}