30 lines
695 B
JavaScript
30 lines
695 B
JavaScript
|
import Schema from '@/ecs/schema.js';
|
||
|
|
||
|
export default function(Component) {
|
||
|
return 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]);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
static schema = new Schema({
|
||
|
type: 'object',
|
||
|
properties: {},
|
||
|
});
|
||
|
}
|
||
|
}
|