silphius/app/ecs/component.js

15 lines
494 B
JavaScript
Raw Normal View History

2024-06-10 22:42:30 -05:00
import Arbitrary from './arbitrary.js';
import Base from './base.js';
import Schema from './schema.js';
export default function Component(specificationOrClass) {
if (specificationOrClass instanceof Base) {
return specificationOrClass;
}
// Why the rigamarole? Maybe we'll implement a flat component for direct binary storage
// eventually.
return class AdhocComponent extends Arbitrary {
2024-06-12 01:38:05 -05:00
static schema = new Schema({type: 'object', properties: specificationOrClass});
2024-06-10 22:42:30 -05:00
};
}