add entity metadata.
This commit is contained in:
parent
1e23765533
commit
b367c4b3a3
|
@ -52,6 +52,17 @@ export function is_visible (entity) {
|
|||
|
||||
|
||||
|
||||
const metadata = new Map();
|
||||
|
||||
export function get_meta (entity) {
|
||||
if (!metadata.has(entity.id)) {
|
||||
metadata.set(entity.id, new Map());
|
||||
}
|
||||
return metadata.get(entity.id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TESTS
|
||||
|
||||
assert("entity creation works.", _ => {
|
||||
|
@ -123,3 +134,10 @@ assert("creating entities with preset visibility works.", _ => {
|
|||
});
|
||||
return e2.visible;
|
||||
});
|
||||
|
||||
assert("entity `get_meta` works.", _ => {
|
||||
const e = create();
|
||||
const meta = get_meta(e);
|
||||
meta.set("test", "gay");
|
||||
return get_meta(e).get("test") === "gay";
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue