1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
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},
{"CasinoTick", (*Game).CasinoTick},
{"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)
}
}
|