/palladius-public-goodies:niccolo-game-designfrom palladius-public-goodies
Provides a game architecture pattern using Managers + Event Bus, based on Niccolò's code-review feedback and Game Programming Patterns. Use when refactoring god-object game loops, scattered win/lose logic, ad-hoc loot, or GLB asset pipelines in TypeScript/Three.js, Godot, or Unity.
Ships in palladius-public-goodies. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
"Not many managers in this PR — lots of code all in one place. Usually people use the game's
mainto handle menus, death screens… The smart way is a MapManager that triggers Game Over because it finds no living characters on the map. You can do that with everything, even Drops: a DropManager whose drops get better as you kill, and reset when you find something important." — Niccolò, code review
This skill turns that advice into a repeatable architecture, cross-checked against Game Programming Patterns (free online) and common Unity/Godot practice.
Activate when ANY of these is true:
update() / animate() / _process() function is longer than ~100 lines or mixes physics,
AI, pickups, UI, audio, and win/lose checks.SomeService.getInstance() (or autoload globals) dozens of times.main/UI code instead of by game rules.Math.random() with no memory..glb game pieces locally from 2D portraits/turnarounds (when cloud 3D GPU quota is unavailable) or graft a clean 2D portrait face onto an existing 3D .glb mesh.EnemyManager owns
enemies, MapManager owns the map and its rules. Target ≤ ~300 lines. If it grows, split it.GameManager that does everything is the same god-object with a new name.
The top-level object (Engine/Game) only orders managers; it contains no gameplay rules.MapManager emits it. Unsealing a reward is a map rule too. main/UI only react.ENEMY_DEFEATED, ALL_HEROES_DOWN)
on a typed Event Bus. Read-only queries (enemies.aliveCount()) go through an injected
GameContext. A manager never calls another manager's mutating methods directly.Sound.play() or Profile.addScore() directly.*View adapters. Result: unit-testable in Node, and runnable on a game server.if (type === 'x') … else if … chains.| Manager | Owns | Emits (examples) | Typical queries |
|---|---|---|---|
GameFlowManager | State machine: Lobby → Loading → Playing ⇄ Downed → Victory / GameOver | FLOW_STATE_CHANGED | state() |
MapManager | Level load/unload, rooms/zones, objectives, win/lose rules | MAP_LOADED, MAP_VICTORY, ALL_HEROES_DOWN, ZONE_ENTERED | roomAt(pos), isObjectiveSealed() |
PlayerManager (a.k.a. MainCharacterManager) | Local + remote heroes, companions, respawn, shields | PLAYER_DOWN, PLAYER_RESPAWNED | livingHeroes() |
EnemyManager | Spawning, AI tick, pooling, guardians/bosses | ENEMY_SPAWNED, GUARDIANS_CLEARED | aliveCount(), nearest(pos) |
CombatManager | The single damage path: hits, shields, kills | DAMAGE_DEALT, ENEMY_DEFEATED, PLAYER_DOWN | — |
ProjectileManager | Projectiles with an object pool | PROJECTILE_HIT | active() |
PickupManager | Collectibles on the map + effect registry | PICKUP_COLLECTED | nearby(pos) |
DropManager | Loot rolls with pity/luck meter | DROP_SPAWNED, LUCK_CHANGED, LUCK_RESET | luck() |
| Listeners | AudioListener, ScoreListener, HudListener, TelemetryListener | — (consume only) | — |
Not every game needs all of them. Start with the ones your god-loop already contains.
init(ctx) // receive GameContext (bus + other managers + services). Subscribe to events here.
onMapLoaded(map) // build per-level state (spawn enemies, place pickups)
update(dt) // fixed-timestep simulation tick. NO rendering here.
lateUpdate(dt) // optional: things that must run after everyone moved (camera, minimap feed)
onMapUnloaded() // free per-level state, return objects to pools
dispose() // unsubscribe, release everything
The top-level loop becomes boring, which is the point:
accumulator += frameDt
while accumulator >= STEP: // fixed step, e.g. 1/30 s (same code runs on a server)
for m in managers: m.update(STEP)
bus.flush() // deliver queued events once per tick, in order
accumulator -= STEP
for m in managers: m.lateUpdate(frameDt)
renderer.render()
Update order matters and must be declared once (typical): Input → Players → Enemies → Projectiles → Combat → Pickups → Drops → Map (rules) → GameFlow.
GameEvent = { type: 'ENEMY_DEFEATED', enemyId, weight, pos } | ….ENEMY_DEFEATED ✅, PLAY_DEATH_SOUND ❌.emit() enqueues; flush() once per tick. Prevents
re-entrancy bugs (a handler that emits while being dispatched) and makes ordering deterministic.DropManager reacts to ENEMY_DEFEATED by asking PickupManager to place a drop).dispose() (memory leaks are the #1 event-bus bug).luck += enemy.weight per kill, odds shift towards rarer tiers (soft pity), a guaranteed rare at the
cap (hard pity), reset to 0 on an important find. Seeded RNG + Monte-Carlo tests.1024×1024 UV texture baking when replacing untextured primitive meshes without cloud GPU quota) and Mode B (projecting/grafting a true 2D portrait face onto an existing TRELLIS.2 / Hunyuan3D .glb mesh whose 3D face was distorted)..tmp_*.glb avoiding Blender glTF extension appending), variant-first LOD resolution, and decoupling player UI (Auto/Alta/Media/Bassa) from internal polygon budgets (10k/50k/100k).horizonYaw = Math.atan2(cam.x - target.x, cam.z - target.z)) so the observer always stays strictly between the playfield and the backdrop at 0°, 90°, 180°, and 270° (enforced by a 4-angle THREE.Raycaster test).RingGeometry or canvas arc bullseyes) centered on the playfield origin (0, 0, 0) — it creates an artificial "giant vinyl record" look. Instead, animate the 3D water surface with gentle non-radial swells (sin(x) + cos(z)) and break the equilibrium every 2–3 seconds with small, localized concentric ripples (r < 0.45m) originating at random localized coordinates $(x_0, z_0)$ where an insect, frog, or fish touches the water.--use-gl=angle --use-angle=swiftshader) capture scripts on macOS, exit with os._exit(0) after encoding PNG/GIF/MP4 outputs so browser.close() / server.shutdown() never hang on GPU context teardown.GameEventBus, IGameManager, GameContext; wire the loop to iterate an
empty manager list. Ship it. Zero behavior change.EnemyManager → MapManager → PlayerManager → GameFlowManager → CombatManager →
ProjectileManager → PickupManager → DropManager.Sound.play() → AudioListener on ENEMY_DEFEATED).getInstance() in the loop ≈ 0.*View adapter.if/else chain on a string "type"? → registry/table.dispose()?ifs)| Smell | Fix |
|---|---|
400-line animate() | Extract managers (recipe above) |
X.getInstance() everywhere | Inject via GameContext (Service Locator / DI) |
| Victory check inline in render loop | MapManager rule + MAP_VICTORY event |
main.ts toggling death/menu screens | GameFlowManager state machine reacting to events |
applyPowerup(type) if/else ladder | PICKUP_EFFECTS[type](ctx) registry |
new Projectile() per shot | ProjectileManager pool |
Math.random() < 0.1 loot | DropManager with luck meter + seeded RNG |
EverythingManager | Split by owned data |
1024×1024 UV baking (Mode A) and 2D portrait face-grafting onto existing 3D .glb meshes (Mode B).CHANGELOG.md (opens in a new tab)DEPENDENCIES.md (opens in a new tab)references/2d-to-3d-sdf-uv-baking.md (opens in a new tab)references/drop-manager-pity.md (opens in a new tab)references/glb-lod-decimation-blender.md (opens in a new tab)references/godot-mapping.md (opens in a new tab)references/map-manager-win-lose.md (opens in a new tab)references/patterns.md (opens in a new tab)references/typescript-skeletons.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
palladius-public-goodies@palladius-skills is listed by palladius/skills — review the source before installing
npx claudepluginhub palladius/skills --plugin palladius-public-goodies68 skills in this plugin
/a2ui(💛) Build and render portable, declarative Generative UIs with Google A2UI (Agent-to-User Interface). Use whenever the user asks to generate, design, or wire interactive UI widgets, cards, forms, or dashboards using A2UI./add-to-portfolio-app(💛) Adds or syncs Talks, Keynotes, Workshops, Articles, Codelabs, Slides, and Videos in Riccardo's personal portfolio application (apps-portfolio) and companion bio repo (my-sessions-and-bio), including SQLite sync, TDD checks, default speaker images, and automated Cloud Run deployment./adk-python(💛) Create and manage AI agents using Google's Agent Development Kit (ADK) for Python. Use when the user wants to build single or multi-agent systems, evaluate agents, or deploy them. Includes instructions for fetching fresh ADK documentation and links for TypeScript and Go development.Other plugins' skills for the same job