New modding system

This commit is contained in:
2026-09-26 17:33:07 -03:00
parent 86d5c39eab
commit 243ff52063
25 changed files with 1089 additions and 512 deletions
+1 -3
View File
@@ -24,7 +24,7 @@ import {
PROTOCOL_VERSION,
ServerMessage,
} from "$/common/protocol.ts";
import type { AtlasListing, ModListing, RecipeBook } from "$/common/mod_loader.ts";
import type { ModListing, RecipeBook } from "$/common/mod_loader.ts";
import type { WorldgenSetup } from "$/common/generation.ts";
import { CYCLE_TICKS, format_clock, time_of_day, TIMES_OF_DAY } from "$/common/time.ts";
import { ModRuntime, run_guarded } from "./mod_runtime.ts";
@@ -91,7 +91,6 @@ interface SavedTile {
// the loaded mods, see load_mods.ts
export interface GameMods {
listings: ModListing[];
atlas: AtlasListing;
recipes: RecipeBook;
worldgen?: WorldgenSetup;
runtime: ModRuntime;
@@ -485,7 +484,6 @@ export class GameServer {
type: "welcome",
protocol: PROTOCOL_VERSION,
seed: this.world.seed,
atlas: this.#mods.atlas,
mods: this.#mods.listings,
} satisfies ServerMessage,
),
+1 -2
View File
@@ -1,4 +1,4 @@
import type { AtlasListing, ModData, ModListing } from "$/common/mod_loader.ts";
import type { ModData, ModListing } from "$/common/mod_loader.ts";
// messages between server/main.ts (the host) and the game server worker
@@ -7,7 +7,6 @@ export type HostToGame =
type: "init";
save: string | undefined;
default_seed: string;
atlas: AtlasListing;
// in load order, with the scripts' code since the worker can't read files
mods: { listing: ModListing; data: ModData; server_code?: string; worldgen_code?: string }[];
}
+1 -3
View File
@@ -1,7 +1,7 @@
// starts a game server with its mods: registers their data, then imports worldgen and server scripts.
// the worker loads built mods, tests can load mods straight from their source folders
import { register_mod_data } from "$/common/mod_loader.ts";
import type { AtlasListing, ModData, ModListing } from "$/common/mod_loader.ts";
import type { ModData, ModListing } from "$/common/mod_loader.ts";
import { load_worldgen } from "$/common/worldgen_loader.ts";
import { GameHost, GameServer } from "./game_server.ts";
import { ModRuntime } from "./mod_runtime.ts";
@@ -18,7 +18,6 @@ export async function start_game(
host: GameHost,
save: string | undefined,
default_seed: string,
atlas: AtlasListing,
mods: ServerModSource[],
): Promise<GameServer> {
const recipes = register_mod_data(mods.map((mod) => ({ id: mod.listing.id, data: mod.data })));
@@ -31,7 +30,6 @@ export async function start_game(
const runtime = new ModRuntime();
const game = new GameServer(host, save, default_seed, {
listings: mods.map((mod) => mod.listing),
atlas,
recipes,
worldgen,
runtime,
-1
View File
@@ -54,7 +54,6 @@ async function init(message: Extract<HostToGame, { type: "init" }>) {
},
message.save,
message.default_seed,
message.atlas,
message.mods.map((mod) => ({
listing: mod.listing,
data: mod.data,