aboutsummaryrefslogtreecommitdiff
path: root/internal/game/game.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-09 22:15:54 -0400
committerhistoria <[not public]>2026-07-09 22:15:54 -0400
commitecba7f726f70b37126d852c38c7e3eec7b04d730 (patch)
tree9129215c6e5015336fde1116395336d82bb952d1 /internal/game/game.go
parentb3d4c616f59ad2519f3a0b77e3b47d6571cd2486 (diff)
downloadthehouseoficarus-ecba7f726f70b37126d852c38c7e3eec7b04d730.tar.gz
feat: old standalone trigger systems completely unified into trigger->condition->action system
Diffstat (limited to 'internal/game/game.go')
-rw-r--r--internal/game/game.go33
1 files changed, 11 insertions, 22 deletions
diff --git a/internal/game/game.go b/internal/game/game.go
index f34e649..eed61f5 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -50,9 +50,9 @@ type Game struct {
Deps
Hub *net.Hub
- GlobalFlags *GlobalFlagStore
+ GlobalFlags *GlobalFlagStore
Combat *combat.Tracker
- TriggerStore *world.TriggerStore
+ flagIndex *flagTriggerIndex
queue *CommandQueue
safespot *SafespotManager
ValidationConfig config.ValidationConfig
@@ -66,8 +66,9 @@ type Game struct {
hackingStates map[string]*hacking.Session
pendingDepletions []pendingDepletion
farmTickCounter int
- enterMu sync.Mutex
- enterSeqs map[string]*enterSeq
+ seqMu sync.Mutex
+ sequences map[string]*sequence
+ globalSeqs []*sequence
shutdownCancel chan struct{}
shutdownActive bool
@@ -88,9 +89,9 @@ func New(dataDir string, colorConfig *config.ColorsConfig, valConfig config.Vali
ColorConfig: colorConfig,
DataDir: dataDir,
},
- GlobalFlags: NewGlobalFlagStore(),
+ GlobalFlags: NewGlobalFlagStore(),
Combat: combat.NewTracker(),
- TriggerStore: world.NewTriggerStore(),
+ flagIndex: newFlagTriggerIndex(),
queue: NewCommandQueue(),
safespot: NewSafespotManager(),
ValidationConfig: valConfig,
@@ -99,14 +100,14 @@ func New(dataDir string, colorConfig *config.ColorsConfig, valConfig config.Vali
restTimers: make(map[string]uint64),
guardWatchTimers: make(map[string]int),
hackingStates: make(map[string]*hacking.Session),
- enterSeqs: make(map[string]*enterSeq),
+ sequences: make(map[string]*sequence),
}
g.CourseStore.SetWorld(g.World)
g.CourseStore.LoadAll()
g.LoadMods()
g.LoadTechs()
g.buildCraftIndex()
- g.seedRoomTriggers()
+ g.loadAllFlagTriggers()
g.ValidateAndLog()
return g
}
@@ -116,9 +117,9 @@ func (g *Game) SetHub(hub *net.Hub) {
hub.OnRemove(func(sess *net.Session) {
if p := sess.Player; p != nil {
g.restoreGodPlayer(p)
+ g.persistLockedOnDisconnect(p)
g.AccountStore.SaveCharacter(p)
p.DeactivateAllTechs()
- g.cancelEnterSeq(p.Name)
g.charsMu.Lock()
delete(g.loggedInChars, p.Name)
g.charsMu.Unlock()
@@ -129,7 +130,7 @@ func (g *Game) SetHub(hub *net.Hub) {
}
})
g.GlobalFlags.OnChange(func(name string, value any) {
- g.TriggerStore.FireGlobal(name, value)
+ g.fireGlobalFlagTriggers(name, value)
})
}
@@ -353,18 +354,6 @@ func (g *Game) buildCraftIndex() {
g.CraftIndex.Build(items)
}
-func (g *Game) seedRoomTriggers() {
- g.TriggerStore.LoadGlobal(g.DataDir)
- roomIndex := g.World.RoomIndex()
- for id := range roomIndex {
- room, err := g.World.LoadRoom(id)
- if err != nil || len(room.Triggers) == 0 {
- continue
- }
- g.TriggerStore.SeedRoomTriggers(id, room.Triggers)
- }
-}
-
type pendingDepletion struct {
instanceKey string
objDefID string