silphius/app/ecs/components/sound.js

24 lines
543 B
JavaScript
Raw Normal View History

2024-06-26 21:08:09 -05:00
import Component from '@/ecs/component.js';
2024-06-25 12:29:09 -05:00
2024-06-26 21:08:09 -05:00
export default class Sound extends Component {
mergeDiff(original, update) {
const merged = {};
if (update.play) {
merged.play = [
...(original.play ?? []),
...update.play,
];
2024-06-25 12:29:09 -05:00
}
2024-06-26 21:08:09 -05:00
return merged;
}
instanceFromSchema() {
const Component = this;
const Instance = super.instanceFromSchema();
return class SoundInstance extends Instance {
play(source) {
Component.markChange(this.entity, 'play', [source]);
}
};
2024-06-25 12:29:09 -05:00
}
}