World reaction
The world reaction has no idea the director exists. Conditions come in, it spreads by rules, and it keeps the list of live events up to date.
One cell's state — ElementalState
The current state of a cell (or object). It's a lightweight struct because the grid processes many of them.
Fixed properties — flammability, conductivity, melting point — aren't stored in the state; they're
looked up from MaterialDef.
MaterialDef
Materials are registered once and shared by index. RuleData.ResolveMaterialId(name) finds one by name,
creating and registering it if missing.
Reaction rule — ReactionRule
Reactions are data, not code: "this element / touching this material / over this threshold → changes like this".
- Target materials go in one field separated by
;, not an array UI (a project convention). They're split once and cached. Leave it empty to match every material. - The three BotW rules are the starting point:
- an element changes a material — fire burns dry grass;
- an element changes another element — water quenches fire;
- depending on the situation an element creates a force — electricity shocks through metal.
The rule table comes from DataService<RuleData>.GetDataCenter().
Spread and results — WorldReaction
- How it spreads: rules are applied on a flat grid (a plain array /
Dictionary, never aSortedSet) so fire jumps to neighbor cells. It spreads each frame based on wind direction and how flammable the neighbor is. ActiveEvents: each entry is aReactionEvent(position, magnitude, time-to-live, kind). The director and tension model watch this list. Finished entries are cleared each frame, and nearby events of the same kind merge into one.
Laying down a grid
Seeding conditions directly
ApplyElement applies the rule table to the touched cells immediately (water touching fire quenches it
right there); Tick then carries the spread forward.
Performance: grid math also fits Jobs/Burst +
NativeArray. The default implementation uses a managed flat array so it runs with no dependencies.