aboutsummaryrefslogtreecommitdiff
path: root/internal/game/tick_systems.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-17 20:15:57 -0400
committerhistoria <[not public]>2026-07-17 20:15:57 -0400
commit9898d42f2d4ef61b5cbec7e212914d1495e04772 (patch)
treeafa604ad77a7a03832ebbd60e77c47d4961b9d77 /internal/game/tick_systems.go
parentc23c87b56fd568956d263bb8b8c5d26fbd8d01ee (diff)
downloadthehouseoficarus-9898d42f2d4ef61b5cbec7e212914d1495e04772.tar.gz
feat: add deterministic order to mob/player tick processing, document how tick processing works
Diffstat (limited to 'internal/game/tick_systems.go')
-rw-r--r--internal/game/tick_systems.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/game/tick_systems.go b/internal/game/tick_systems.go
new file mode 100644
index 0000000..4d8d4b6
--- /dev/null
+++ b/internal/game/tick_systems.go
@@ -0,0 +1,60 @@
+package game
+
+// tickSystem is one step of the canonical per-tick system sequence. Name is
+// the human-readable identifier also encoded in building_guide/tick_order.md;
+// Run invokes the underlying system. The slice tickSystemOrder is the single
+// executable source of truth for the order in which per-tick systems fire.
+//
+// The order is what callers like the master subscriber in cmd/thoi/main.go
+// (registered as engine subscription ID 1, which the engine fires before all
+// dynamically-registered combat/aggro/respawn callbacks per processTick's
+// registration-ID sort) depend on. Reordering this slice is a breaking change
+// to game behavior; keep building_guide/tick_order.md in sync.
+type tickSystem struct {
+ Name string
+ Run func(*Game)
+}
+
+// TickSystemOrder returns the canonical per-tick system sequence. It is a
+// copy of the internal slice so callers cannot mutate the canonical order.
+func TickSystemOrder() []struct{ Name string } {
+ out := make([]struct{ Name string }, len(tickSystemOrder))
+ for i, s := range tickSystemOrder {
+ out[i] = struct{ Name string }{s.Name}
+ }
+ return out
+}
+
+var tickSystemOrder = []tickSystem{
+ {"ProcessQueuedCommands", (*Game).ProcessQueuedCommands},
+ {"MoveTick", (*Game).MoveTick},
+ {"SequenceTick", (*Game).SequenceTick},
+ {"TransientMobTick", (*Game).TransientMobTick},
+ {"World.Tick", func(g *Game) { g.World.Tick() }},
+ {"MobStore.Tick", func(g *Game) { g.MobStore.Tick() }},
+ {"RegenTick", (*Game).RegenTick},
+ {"EnergyRegenTick", (*Game).EnergyRegenTick},
+ {"DisconnectTick", (*Game).DisconnectTick},
+ {"WanderTick", (*Game).WanderTick},
+ {"SharedDepletionTick", (*Game).SharedDepletionTick},
+ {"FireTick", (*Game).FireTick},
+ {"AdvanceActions", (*Game).AdvanceActions},
+ {"TechTick", (*Game).TechTick},
+ {"ConsumeTick", (*Game).ConsumeTick},
+ {"BroadcastRespawns", (*Game).BroadcastRespawns},
+ {"VisualTick", (*Game).VisualTick},
+ {"SneakTick", (*Game).SneakTick},
+ {"FarmTick", (*Game).FarmTick},
+ {"BuffTick", (*Game).BuffTick},
+ {"SafespotTick", (*Game).SafespotTick},
+ {"HazardTick", (*Game).HazardTick},
+}
+
+// RunTickSystems fires every canonical per-tick system in registration order.
+// It is the body of the master per-tick subscriber in cmd/thoi/main.go and the
+// single place that encodes per-tick system execution order.
+func (g *Game) RunTickSystems() {
+ for _, s := range tickSystemOrder {
+ s.Run(g)
+ }
+} \ No newline at end of file