update item owner

This commit is contained in:
vietdungdev
2026-05-24 22:37:32 +07:00
parent 41abbe5217
commit e8a41dc79c
3 changed files with 18 additions and 14 deletions

View File

@@ -82,15 +82,12 @@ func (gd *GameReader) GetData() data.Data {
gd.monstersLastUpdate = now
}
merc, foundMerc := gd.OwnMercenary()
merc.Found = foundMerc
// Conditionally update inventory 500ms
// Except when hovering over an item
inventory := gd.cachedInventory
if now.Sub(gd.inventoryLastUpdate) > 250*time.Millisecond ||
(hover.IsHovered && hover.UnitType == 4) { // 4 = Item type
inventory = gd.Inventory(rawPlayerUnits, merc, hover)
inventory = gd.Inventory(rawPlayerUnits, hover)
gd.cachedInventory = inventory
gd.inventoryLastUpdate = now
}
@@ -150,6 +147,8 @@ func (gd *GameReader) GetData() data.Data {
ActiveWeaponSlot: gd.GetActiveWeaponSlot(),
}
merc, foundMerc := gd.OwnMercenary()
merc.Found = foundMerc
d.Mercenary = data.OwnMercenary(merc)
return d
}
@@ -157,9 +156,7 @@ func (gd *GameReader) GetData() data.Data {
func (gd *GameReader) GetInventory() data.Inventory {
rawPlayerUnits := gd.GetRawPlayerUnits()
hover := gd.HoveredData()
merc, foundMerc := gd.OwnMercenary()
merc.Found = foundMerc
return gd.Inventory(rawPlayerUnits, merc, hover)
return gd.Inventory(rawPlayerUnits, hover)
}
func (gd *GameReader) InGame() bool {