Animators and coilhead animations

This commit is contained in:
2026-11-21 21:54:02 -03:00
parent 69ad4b80d0
commit 0c711b8163
21 changed files with 960 additions and 34 deletions
+18
View File
@@ -44,9 +44,11 @@ import { clear_hooks, expose_engine } from "@/common/hooks.ts";
import { common_engine } from "@/common/engine_modules.ts";
import { client_engine } from "./engine_modules.ts";
import { block_visuals } from "./rendering/visuals.ts";
import { entity_animators } from "./rendering/entity_animators.ts";
import { biome_season } from "@/common/worldgen/biomes.ts";
import { clock, farming_day } from "@/common/time.ts";
import type { LootTableJson } from "@/common/loot.ts";
import type { ClipJson } from "@/common/mod_data.ts";
// each loaded mod's credits file, for the credits screen
export const mod_credits: { name: string; version: string; text: string }[] = [];
@@ -206,6 +208,7 @@ export async function load_client_mods(listings: ModListing[], mods: Mod[]) {
menu_screens.clear();
net_handlers.clear();
block_visuals.clear();
entity_animators.clear();
mod_names.clear();
for (const listing of listings) mod_names.set(listing.id, listing.name);
@@ -429,6 +432,21 @@ function client_context(listing: ModListing): ClientContext {
if (other) register.fail(`${block} already has a visual, from ${other.mod}`);
block_visuals.set(nid, { mod, create, replaces_model: options?.replaces_model ?? false });
},
register_entity_animator(type, create) {
register.running("entity animator");
if (!EverythingRegistry.get("entities", type)) throw new Error(`[${mod}] unknown entity ${type}`);
if (typeof create !== "function") {
throw new Error(`[${mod}] an animator needs a function that makes it`);
}
const other = entity_animators.get(type);
if (other) register.fail(`${type} already has an animator, from ${other.mod}`);
entity_animators.set(type, { mod, create });
},
clip(id) {
const json = EverythingRegistry.get<ClipJson>("animations", id);
if (!json) throw new Error(`[${mod}] unknown clip ${id}`);
return Object.freeze({ id, length: json.length, loop: json.loop });
},
},
log: (...args) => console.log(`[${mod}]`, ...args),
};