2019-11-10 08:51:02 -05:00
|
|
|
package d2core
|
2019-11-10 03:36:53 -05:00
|
|
|
|
|
|
|
import (
|
2019-11-17 00:16:33 -05:00
|
|
|
"github.com/OpenDiablo2/D2Shared/d2common"
|
|
|
|
"github.com/OpenDiablo2/D2Shared/d2common/d2enum"
|
|
|
|
"github.com/OpenDiablo2/D2Shared/d2common/d2interface"
|
|
|
|
"github.com/OpenDiablo2/D2Shared/d2data/d2datadict"
|
2019-11-10 08:51:02 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2render"
|
2019-11-10 03:36:53 -05:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
|
|
|
)
|
|
|
|
|
|
|
|
type NPC struct {
|
2019-11-10 10:44:13 -05:00
|
|
|
AnimatedEntity d2render.AnimatedEntity
|
2019-11-10 03:36:53 -05:00
|
|
|
Paths []d2common.Path
|
|
|
|
}
|
|
|
|
|
2019-11-11 23:48:55 -05:00
|
|
|
func CreateNPC(x, y int32, object *d2datadict.ObjectLookupRecord, fileProvider d2interface.FileProvider, direction int) *NPC {
|
2019-11-10 03:36:53 -05:00
|
|
|
result := &NPC{
|
2019-11-11 23:48:55 -05:00
|
|
|
AnimatedEntity: d2render.CreateAnimatedEntity(x, y, object, fileProvider, d2enum.Units),
|
2019-11-10 03:36:53 -05:00
|
|
|
}
|
2019-11-14 22:20:01 -05:00
|
|
|
result.AnimatedEntity.SetMode(object.Mode, object.Class, direction)
|
2019-11-10 03:36:53 -05:00
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-11-11 23:48:55 -05:00
|
|
|
func (v *NPC) SetPaths(paths []d2common.Path) {
|
|
|
|
v.Paths = paths
|
|
|
|
}
|
|
|
|
|
2019-11-10 03:36:53 -05:00
|
|
|
func (v *NPC) Render(target *ebiten.Image, offsetX, offsetY int) {
|
|
|
|
v.AnimatedEntity.Render(target, offsetX, offsetY)
|
|
|
|
}
|