33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { ClientWorld } from "../client/client_world.ts";
|
|
import { Tile } from "../client/components/dimension.ts";
|
|
import { ItemStack } from "../client/inventory.ts";
|
|
|
|
export class EverythingRegistry {
|
|
static #registries = new Map<string, unknown>();
|
|
|
|
static register<T>(registry_name: string, key: string, value: T) {
|
|
this.#registries.set(`${registry_name}__${key}`, value);
|
|
}
|
|
|
|
static get<T>(registry_name: string, key: string): T {
|
|
return this.#registries.get(`${registry_name}__${key}`) as T;
|
|
}
|
|
}
|
|
|
|
export interface TileRegistry<T = unknown | undefined> {
|
|
texture_id: string | ((tile: Tile<T>) => string);
|
|
has_collision: boolean;
|
|
|
|
on_create?(world: ClientWorld, tile: Tile<T>): void;
|
|
on_click?(world: ClientWorld, tile: Tile<T>): void;
|
|
on_interact?(world: ClientWorld, tile: Tile<T>): void;
|
|
on_tick?(world: ClientWorld, tile: Tile<T>, tick_delta: number): void;
|
|
on_second?(world: ClientWorld, tile: Tile<T>, second_delta: number): void;
|
|
}
|
|
|
|
export interface ItemRegistry<T = unknown | undefined> {
|
|
texture_id: string | ((item: ItemStack<T>) => string);
|
|
on_create?(item: ItemStack<T>): void;
|
|
get_lore?(item: ItemStack<T>): string;
|
|
}
|