blob: 1eb522363b060759267c06fc7dd7f0322c660959 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
game.nextId = 0;
game.Entity = (id=game.nextId++) => {
const components = {};
const addComponent = (component) => {
components[component.name] = component;
};
const hasComponent = (componentName) => components[componentName] !== undefined;
const removeComponent = (componentName) => {
if (hasComponent(componentName)) {
delete components[componentName];
}
};
return {
id,
components,
addComponent,
removeComponent,
hasComponent
};
}
|