This commit is contained in:
33333-33333 2026-06-20 02:07:01 +09:00
commit 46258a83eb
15 changed files with 1303 additions and 446 deletions

View file

@ -1,27 +1,25 @@
# Code Map
# Code map
Use this map to open the smallest relevant file first.
Use this as the first lookup table before opening large files.
## Simulation
- `js/sim_core.js`: shared simulation helpers, personality definitions, `Effect`, `SpatialGrid`, and small drawing helpers used by simulation classes.
- `js/items.js`: `Item` lifecycle, item save/load restore, grass and zunchi behavior, and item drawing.
- `js/tarinai.js`: `Tarinai` state, AI, movement, eating, fighting, panic, reproduction-adjacent behavior, and drawing.
- `js/world.js`: `World` state, save/load, spawning, family registry normalization, spatial queries, tools, weather, and update loop coordination.
| Need | File / symbol |
|---|---|
| Script order / DOM shell | `index.html` |
| Global config, sprites, object metrics | `js/data.js` / `CONFIG`, `SPRITES`, `IMAGE_METRICS` |
| Lazy image loading | `js/assets.js` / `loadInitialImages`, `loadDeferredImages`, `getRenderableImage` |
| UI Japanese text catalog | `js/text_catalog.js` / `TEXT_CATALOG` |
| Core agent state | `js/tarinai.js` / `class Tarinai` constructor |
| Agent AI target choice | `js/tarinai.js` / `resolveNeeds`, target helpers |
| Disease state transitions | `js/tarinai.js` / `infect*`, `recover*`, `update*Disease*` |
| Damage/death cause rules | `js/health.js` / `HEALTH` |
| Item creation/lifecycle/draw | `js/items.js` / `class Item` |
| Cleaning, rain, placement | `js/world.js` / placement/update interaction helpers |
| Fence collision | `js/world.js` / `resolveFenceCollision` |
| Logs/archive/save | `js/world.js` |
| Main renderer | `js/render.js` / `render` helpers |
| Agent drawing | `js/tarinai.js` / `draw` |
| Input/tools/dialogs | `js/ui.js` |
| Statistics UI | `js/ui_charts.js` |
| Family tree UI | `js/ui_family.js` |
## UI And Rendering
- `js/render.js`: canvas scene rendering, lighting, weather visuals, HUD, and selected-card overlay.
- `js/ui.js`: DOM references, selected/log panels, labels, save/load buttons, tool controls, canvas input, and UI event binding.
- `js/ui_charts.js`: colony history aggregation and chart rendering.
- `js/ui_family.js`: family tree components, layout, archive rendering, and validation helper.
## Common Tasks
- Change hunger, sleep, fighting, panic, eating, or movement: start with `js/tarinai.js`.
- Change item growth, zunchi lifecycle, grass spread, or item visuals: start with `js/items.js`.
- Change save/load, population, spawning, weather, tools, or family data correctness: start with `js/world.js`.
- Change family tree display only: start with `js/ui_family.js`.
- Change colony charts: start with `js/ui_charts.js`.
- Change buttons, selected info, logs, or input handling: start with `js/ui.js`.
- Change the garden canvas visuals: start with `js/render.js`.
## Loading Order
`index.html` loads plain browser scripts in dependency order. Do not convert to ES modules or add a build step unless the project intentionally adopts one later.
Refactor guidance: extract isolated rule sets into small helper files, then delegate from `Tarinai`/`World`. Keep shared domain terms centralized (`HEALTH`, `TEXT_CATALOG`, `CONFIG`) to reduce repeated prompt context.