aboutsummaryrefslogtreecommitdiff
path: root/internal/world/world.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-14 22:38:23 -0400
committerhistoria <[not public]>2026-06-14 22:38:23 -0400
commita6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77 (patch)
tree89601a502bbfcb50302cf03f09b6febc6040eeb0 /internal/world/world.go
parent1aba2bdd23aebed4032333e74aa553c40a31fcbd (diff)
downloadthehouseoficarus-a6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77.tar.gz
feat: fractional ticks and server game_speed implemented. potentially insanely janky.
Diffstat (limited to 'internal/world/world.go')
-rw-r--r--internal/world/world.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/internal/world/world.go b/internal/world/world.go
index ac5345e..a554432 100644
--- a/internal/world/world.go
+++ b/internal/world/world.go
@@ -54,18 +54,18 @@ type ObjMove struct {
type ObjState struct {
Depleted bool
- DepleteTimer int
+ DepleteTimer float64
DefID string
Name string
Index int
RoomID int
JustRespawned bool
WanderRooms []int
- WanderInterval int
+ WanderInterval float64
WanderCounter int
- SharedMax int
+ SharedMax float64
SharedTimer int
- Quality int
+ Quality float64
}
func (w *World) ObjStateKey(roomID int, defID string, index int) string {
@@ -102,7 +102,7 @@ func (w *World) ensureObjectStatesLocked(roomID int, defIDs []string) {
}
}
-func (w *World) AddObjInstance(roomID int, defID string, quality int) {
+func (w *World) AddObjInstance(roomID int, defID string, quality float64) {
w.mu.Lock()
defer w.mu.Unlock()
if w.objStates == nil {
@@ -250,7 +250,7 @@ func (w *World) SetObjName(roomID int, defID string, name string) {
}
}
-func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval int) {
+func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval float64) {
w.mu.Lock()
defer w.mu.Unlock()
for _, st := range w.objStates {
@@ -261,13 +261,13 @@ func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval int
}
}
-func (w *World) SetObjDepleteTimer(roomID int, defID string, max int) {
+func (w *World) SetObjDepleteTimer(roomID int, defID string, max float64) {
w.mu.Lock()
defer w.mu.Unlock()
for _, st := range w.objStates {
if st.RoomID == roomID && st.DefID == defID && st.SharedMax == 0 {
st.SharedMax = max
- st.SharedTimer = max
+ st.SharedTimer = int(max)
}
}
}
@@ -284,7 +284,7 @@ func (w *World) AllSharedObjStates() []*ObjState {
return out
}
-func (w *World) SetObjDepleted(roomID int, defID string, index int, delay int) {
+func (w *World) SetObjDepleted(roomID int, defID string, index int, delay float64) {
w.mu.Lock()
defer w.mu.Unlock()
key := w.objStateKey(roomID, defID, index)
@@ -486,7 +486,7 @@ func (w *World) SeedGroundItems(roomID int) {
e.quantity += s.Quantity
e.respawnQty += s.Quantity
e.isSpawn = true
- e.respawnDelay = s.RespawnTicks
+ e.respawnDelay = int(s.RespawnTicks)
merged = true
break
}
@@ -496,7 +496,7 @@ func (w *World) SeedGroundItems(roomID int) {
itemID: s.ItemID,
quantity: s.Quantity,
isSpawn: true,
- respawnDelay: s.RespawnTicks,
+ respawnDelay: int(s.RespawnTicks),
respawnQty: s.Quantity,
}
w.groundItems[roomID] = append(w.groundItems[roomID], e)
@@ -545,7 +545,7 @@ func (w *World) Tick() {
st.Depleted = false
st.JustRespawned = true
if st.SharedMax > 0 {
- st.SharedTimer = st.SharedMax
+ st.SharedTimer = int(st.SharedMax)
}
}
}
@@ -577,7 +577,7 @@ func (w *World) TickObjWander() {
continue
}
st.WanderCounter++
- if st.WanderCounter >= st.WanderInterval {
+ if float64(st.WanderCounter) >= st.WanderInterval {
st.WanderCounter = 0
toRoom := st.WanderRooms[rand.Intn(len(st.WanderRooms))]
if toRoom == st.RoomID {