diff options
Diffstat (limited to 'building_guide/tick_order.md')
| -rw-r--r-- | building_guide/tick_order.md | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/building_guide/tick_order.md b/building_guide/tick_order.md index b4d1f1e..b1246dd 100644 --- a/building_guide/tick_order.md +++ b/building_guide/tick_order.md @@ -107,9 +107,10 @@ stores initialized (`World`, `MobStore`, `Hub`, `queue`, etc. via - Systems that touch the hub: guard with `if g.Hub == nil { return }` at the top, *or* guard each `Hub.*` call with `if g.Hub != nil`. Either is fine. - (Note: `Ticks.Start` runs *before* `SetHub` in `main.go`, so the master - subscriber can fire with `Hub == nil` during startup — guards are not - optional.) + (`main.go` now calls `SetHub` *before* `Ticks.Start`, so the production + server never ticks with a nil hub; the guards are belt-and-braces for a + `*Game` that tests construct without `SetHub`, such as + `newRunTickSystemsTestGame`.) - Systems that iterate over maps/slices held on `*Game` (`sequences`, `restTimers`, `guardWatchTimers`, `hackingStates`, …) must tolerate empty / freshly-initialized maps. `game.New` initializes all of them; tests that @@ -126,16 +127,16 @@ When writing content that depends on per-tick ordering (a trigger that should fire *after* regen, a sequence whose step messages should appear *before* the move completes, etc.), consult the table above and remember: -- `MoveTick` (step 2) runs before `SequenceTick` (step 3) — the table +- `MoveTick` (table #3) runs before `SequenceTick` (table #4) — the table fires top-to-bottom, so a move that completes this tick will have its - enter-room knock-on triggers fire (inside step 1 or step 2) before - trigger `sequences` advance in step 3. + enter-room knock-on triggers fire (inside `ProcessQueuedCommands`, #1, or + `MoveTick`, #3) before trigger `sequences` advance in #4. - `on_enter` / `on_exit` room triggers fire from command execution, not - from a per-tick system; they run inside `ProcessQueuedCommands` (step 1) - or `MoveTick` (step 2) when the move actually completes. -- Shop restock (step 6) happens *before* `RegenTick` (step 7) and *before* - `AdvanceActions` (step 13); if a gathering action completes this tick - it does so in step 13, by which point shop state for this tick has + from a per-tick system; they run inside `ProcessQueuedCommands` (#1) + or `MoveTick` (#3) when the move actually completes. +- Shop restock (`MobStore.Tick`, #7) happens *before* `RegenTick` (#8) and + *before* `AdvanceActions` (#14); if a gathering action completes this tick + it does so in #14, by which point shop state for this tick has already advanced. When in doubt, the test in `tick_systems_test.go` is the executable |
