Its almost generation time

This commit is contained in:
2026-11-17 22:11:59 -03:00
parent 8c2364fa91
commit c0c728c066
3 changed files with 40 additions and 5 deletions
Binary file not shown.
Binary file not shown.
+40 -5
View File
@@ -1,6 +1,7 @@
import type { ClientContext } from "cubi/client";
import type { ServerContext } from "cubi/server";
import type { ClientContext, Color } from "cubi/client";
import type { Position, ServerContext } from "cubi/server";
import { DOOR, FACILITY_DOOR } from "./shared.ts";
import { Alea } from "@paulaboks/rng";
export { shared } from "./shared.ts";
@@ -13,7 +14,23 @@ export function server(ctx: ServerContext) {
register_commands(ctx);
}
export function client(_ctx: ClientContext) {
export function client(ctx: ClientContext) {
register_hud(ctx);
}
// a small 5x5 ring in the middle of the screen to aim with, its corners and middle left empty, in gui pixels
function register_hud(ctx: ClientContext) {
const color: Color = [1, 1, 1, 1];
ctx.hud.register("dangerous_business:crosshair", {
on_render(g) {
const x = Math.floor(g.width / 2) - 2;
const y = Math.floor(g.height / 2) - 2;
g.rect(x + 1, y, 3, 1, color);
g.rect(x + 1, y + 4, 3, 1, color);
g.rect(x, y + 1, 1, 3, color);
g.rect(x + 4, y + 1, 1, 3, color);
},
});
}
// doors are two blocks, a lower and an upper half, see register_door in shared.ts. one is only placed with air above
@@ -126,7 +143,13 @@ function register_commands(ctx: ServerContext) {
);
}
const interior_tiles = [];
interface Tile {
tile: string;
position: Position;
rotation: number;
}
let interior_tiles: Tile[] = [];
function clear_map(ctx: ServerContext) {
// theres no need to clear the surface but we do need to clear each tile
@@ -139,5 +162,17 @@ function place_surface(ctx: ServerContext) {
);
}
function generate_interior(ctx: ServerContext) {
interface InteriorGenerationConfig {
size_multipler: number;
}
function plan_interior(rng: Alea, config: InteriorGenerationConfig): Tile[] {
const tiles: Tile[] = [];
return tiles;
}
function generate_interior(ctx: ServerContext, config: InteriorGenerationConfig) {
interior_tiles = plan_interior(new Alea(), config);
// generate main
// generate other rooms
}