aboutsummaryrefslogtreecommitdiff
path: root/internal/world
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-20 03:20:01 -0400
committerhistoria <[not public]>2026-06-20 03:20:01 -0400
commite4400c5f1e84c18d2126f2cb502ae10685977cbb (patch)
tree0523e9d68f1cfdc6f81b862e3068fe12c1a85054 /internal/world
parent5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff)
downloadthehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz
refactor: combined all station crafting
Diffstat (limited to 'internal/world')
-rw-r--r--internal/world/ground.go10
-rw-r--r--internal/world/objects.go4
-rw-r--r--internal/world/room.go4
-rw-r--r--internal/world/world.go2
4 files changed, 9 insertions, 11 deletions
diff --git a/internal/world/ground.go b/internal/world/ground.go
index 6c3ecf3..879cc71 100644
--- a/internal/world/ground.go
+++ b/internal/world/ground.go
@@ -63,7 +63,7 @@ func (w *World) GroundItems(roomID int) map[string]int {
return out
}
-func (w *World) AddReservedGroundItem(roomID int, itemID string, qty int, owner string) {
+func (w *World) AddReservedItem(roomID int, itemID string, qty int, owner string) {
w.mu.Lock()
defer w.mu.Unlock()
e := &groundEntry{
@@ -87,7 +87,7 @@ func (w *World) AddGroundItem(roomID int, itemID string, qty int) {
w.groundItems[roomID] = append(w.groundItems[roomID], e)
}
-func (w *World) RemoveReservedGroundItem(roomID int, itemID string, qty int, owner string) (int, bool) {
+func (w *World) RemoveReservedItem(roomID int, itemID string, qty int, owner string) (int, bool) {
w.mu.Lock()
defer w.mu.Unlock()
removed := 0
@@ -151,14 +151,14 @@ func (w *World) RemoveGroundItem(roomID int, itemID string, qty int) int {
return removed
}
-func (w *World) tickGroundItemsLocked() {
+func (w *World) tickGroundItems() {
for _, entries := range w.groundItems {
for _, e := range entries {
if e.respawnTimer > 0 {
e.respawnTimer--
if e.respawnTimer <= 0 {
e.quantity = e.respawnQty
- w.mergeNearbyItemsLocked(entries, e)
+ w.mergeNearbyItems(entries, e)
}
}
if e.despawnTimer > 0 {
@@ -177,7 +177,7 @@ func (w *World) tickGroundItemsLocked() {
}
}
-func (w *World) mergeNearbyItemsLocked(entries []*groundEntry, target *groundEntry) {
+func (w *World) mergeNearbyItems(entries []*groundEntry, target *groundEntry) {
for _, other := range entries {
if other != target && other.quantity > 0 && strings.EqualFold(other.itemID, target.itemID) &&
(other.reserveTimer <= 0 || other.reservedFor == "") &&
diff --git a/internal/world/objects.go b/internal/world/objects.go
index 568ea40..72e4a6d 100644
--- a/internal/world/objects.go
+++ b/internal/world/objects.go
@@ -39,10 +39,10 @@ func (w *World) ObjStateKey(roomID int, defID string, index int) string {
func (w *World) EnsureObjectStates(roomID int, defIDs []string) {
w.mu.Lock()
defer w.mu.Unlock()
- w.ensureObjectStatesLocked(roomID, defIDs)
+ w.ensureObjStates(roomID, defIDs)
}
-func (w *World) ensureObjectStatesLocked(roomID int, defIDs []string) {
+func (w *World) ensureObjStates(roomID int, defIDs []string) {
if w.objStates == nil {
w.objStates = make(map[string]*ObjState)
}
diff --git a/internal/world/room.go b/internal/world/room.go
index f006acc..9226a16 100644
--- a/internal/world/room.go
+++ b/internal/world/room.go
@@ -35,9 +35,7 @@ var OppositeExit = map[ExitDir]ExitDir{
}
var ExitOrder = []ExitDir{
- "northwest", North, "northeast",
- East, "southeast", South, "southwest",
- West, Up, Down,
+ North, South, East, West, Up, Down,
}
type SpawnDef struct {
diff --git a/internal/world/world.go b/internal/world/world.go
index 0b40918..b305c4b 100644
--- a/internal/world/world.go
+++ b/internal/world/world.go
@@ -124,6 +124,6 @@ func (w *World) RoomIndex() map[int]bool {
func (w *World) Tick() {
w.mu.Lock()
defer w.mu.Unlock()
- w.tickGroundItemsLocked()
+ w.tickGroundItems()
w.tickObjStatesLocked()
}