Start making serializable components

This commit is contained in:
2026-02-27 17:24:08 -03:00
parent b52b7f4c44
commit 0f3f8de735
4 changed files with 114 additions and 35 deletions
+10
View File
@@ -1,3 +1,13 @@
import { EverythingRegistry } from "../everything_registry.ts";
EverythingRegistry.add_registry("components");
export abstract class Component {
__component = true;
}
export abstract class SerializableComponent extends Component {
abstract serialize(): unknown;
// right, this is static you cant do this,,
// abstract deserialize<T>(data: unknown): T;
}
+15
View File
@@ -0,0 +1,15 @@
export class EverythingRegistry {
static #registries = new Map<string, Map<string, unknown>>();
static add_registry(name: string) {
this.#registries.set(name, new Map());
}
static register<T>(registry_name: string, key: string, value: T) {
this.#registries.get(registry_name)?.set(key, value);
}
static get<T>(registry_name: string, key: string): T {
return this.#registries.get(registry_name)?.get(key) as T;
}
}