This commit is contained in:
2026-03-07 16:26:12 -03:00
parent 5218fab55a
commit 5ad4188567
12 changed files with 245 additions and 197 deletions
+27 -2
View File
@@ -1,21 +1,46 @@
import { Component } from "$/common/ecs/mod.ts";
import { EverythingRegistry, TileRegistry } from "$/common/everything_registry.ts";
import { AssetManager } from "../assets.ts";
import { ClientWorld } from "../client_world.ts";
import { Texture } from "../renderer.ts";
export interface Tile {
export interface Tile<T = unknown> {
x: number;
y: number;
id: string;
data?: Record<string, unknown> | undefined;
data?: T;
tickable?: boolean;
}
export class Dimension extends Component {
image: Texture;
tiles: Tile[];
second_timer = 0;
tick_timer = 0;
constructor(tiles: Tile[]) {
super();
this.image = AssetManager.instance.get("bworld:textures");
this.tiles = tiles;
}
add_tile(world: ClientWorld, tile: Tile) {
this.tiles.push(tile);
const tile_info = EverythingRegistry.get<TileRegistry>("tiles", tile.id);
if (tile_info?.on_create) {
tile_info?.on_create(world, tile);
}
}
delete_tile(_world: ClientWorld, tile: Tile) {
const index = this.tiles.indexOf(tile);
if (index !== -1) {
this.tiles.splice(index, 1);
}
// const tile_info = EverythingRegistry.get<TileRegistry>("tiles", tile.id);
// if (tile_info?.on_delete) {
// tile_info?.on_delete(world, tile);
// }
}
}