Log inGet started
World

Fly Circus — The Living Simulation

Branchmain
Branchesmain
Commitff727ce6b1

README.md

larder

Where the food is. One shared store of what there is to eat in Fly Circus, so a fly's brain and the director's controls are looking at the same world.

A fly does not scan the scene for food every frame — that would be thousands of entity reads a second for six creatures. It asks the larder, which is a short list, and the director places and removes from the same list.

Using it

CallWhat it does
M.configure({ materials = {...}, sphere = meshRef })hand it the artwork to draw food with
M.place({ x, z, kind, amount })put a site on the ground; returns its record
M.nearest(x, z, radius)the closest site to a point within a radius — this is a fly's sense of smell
M.consume(id, amount)take a helping out; the site is removed at zero
M.remove(id) / M.clear()take a site, or all of them, away
M.all(), M.count(), M.get(id), M.kinds()read what is there

Kinds are sugar, fruit and jam, each drawn as a splash with its own size and colour.

Why the scene hands it its artwork

The three food materials are authored by the scene build with build.asset, which files them under the scene's own path (scenes.main.food_sugar). A shared module should not be spelling out one scene's asset paths, and it must not resolve them when it loads — a component that requires this file may well be registered before the scene's build has run. So the scene configures the larder, and place says plainly if it is called before that.

M.place returns nil rather than raising when it has no artwork, so a caller that has already spawned the entities it needs does not end up half-done.