feat(npc): add preset unit helper to retrieve npc from 1.13c map data

This commit is contained in:
Genqila
2026-01-21 11:11:06 +07:00
committed by guiyomu-dev
parent ba3d781a0b
commit 4162d16437
4 changed files with 274 additions and 0 deletions

View File

@@ -2,9 +2,11 @@ package data
import (
"github.com/hectorgimenez/d2go/pkg/data/mode"
"github.com/hectorgimenez/d2go/pkg/data/monplace"
"github.com/hectorgimenez/d2go/pkg/data/npc"
"github.com/hectorgimenez/d2go/pkg/data/stat"
"github.com/hectorgimenez/d2go/pkg/data/state"
"github.com/hectorgimenez/d2go/pkg/data/superunique"
)
type NPC struct {
@@ -39,6 +41,32 @@ func (n NPCs) FindOne(npcid npc.ID) (NPC, bool) {
return NPC{}, false
}
func (n NPCs) FindOneBySuperUniqueID(id superunique.ID) (NPC, bool) {
presetunit, found := npc.PresetUnitForSuperUniqueID(id)
if found {
for _, np := range n {
if np.ID == npc.ID(presetunit.PresetID) {
return np, true
}
}
}
return NPC{}, false
}
func (n NPCs) FindOneByMonPlaceID(id monplace.ID) (NPC, bool) {
presetunit, found := npc.PresetUnitForMonPlaceID(id)
if found {
for _, np := range n {
if np.ID == npc.ID(presetunit.PresetID) {
return np, true
}
}
}
return NPC{}, false
}
func (m Monsters) FindOne(id npc.ID, t MonsterType) (Monster, bool) {
for _, monster := range m {
if monster.Name == id {