2020-06-23 14:12:30 -04:00
|
|
|
package d2player
|
|
|
|
|
2020-07-11 11:25:34 -04:00
|
|
|
import (
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2020-09-20 17:52:01 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
2020-07-11 11:25:34 -04:00
|
|
|
)
|
2020-06-23 14:12:30 -04:00
|
|
|
|
2020-06-30 09:58:53 -04:00
|
|
|
// EquipmentSlot represents an equipment slot for a player
|
2020-06-23 14:12:30 -04:00
|
|
|
type EquipmentSlot struct {
|
|
|
|
item InventoryItem
|
|
|
|
x int
|
|
|
|
y int
|
|
|
|
width int
|
|
|
|
height int
|
|
|
|
}
|
|
|
|
|
2020-09-20 17:52:01 -04:00
|
|
|
func genEquipmentSlotsMap(record *d2records.InventoryRecord) map[d2enum.EquippedSlot]EquipmentSlot {
|
2020-07-11 11:25:34 -04:00
|
|
|
slotMap := map[d2enum.EquippedSlot]EquipmentSlot{}
|
|
|
|
|
|
|
|
slots := []d2enum.EquippedSlot{
|
|
|
|
d2enum.EquippedSlotHead,
|
|
|
|
d2enum.EquippedSlotTorso,
|
|
|
|
d2enum.EquippedSlotLegs,
|
|
|
|
d2enum.EquippedSlotRightArm,
|
|
|
|
d2enum.EquippedSlotLeftArm,
|
|
|
|
d2enum.EquippedSlotLeftHand,
|
|
|
|
d2enum.EquippedSlotRightHand,
|
|
|
|
d2enum.EquippedSlotNeck,
|
|
|
|
d2enum.EquippedSlotBelt,
|
|
|
|
d2enum.EquippedSlotGloves,
|
|
|
|
}
|
2020-09-12 16:25:09 -04:00
|
|
|
|
2020-07-11 11:25:34 -04:00
|
|
|
for _, slot := range slots {
|
|
|
|
box := record.Slots[slot]
|
|
|
|
equipmentSlot := EquipmentSlot{
|
|
|
|
nil,
|
|
|
|
box.Left,
|
|
|
|
box.Bottom + cellPadding,
|
|
|
|
box.Width,
|
|
|
|
box.Height,
|
|
|
|
}
|
|
|
|
slotMap[slot] = equipmentSlot
|
2020-06-23 14:12:30 -04:00
|
|
|
}
|
2020-07-11 11:25:34 -04:00
|
|
|
|
|
|
|
return slotMap
|
2020-06-23 14:12:30 -04:00
|
|
|
}
|