2020-07-30 15:04:05 -04:00
|
|
|
package d2mapentity
|
|
|
|
|
|
|
|
import (
|
2020-08-02 21:26:07 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-07-30 15:04:05 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2item/diablo2item"
|
|
|
|
)
|
|
|
|
|
2020-08-02 21:26:07 -04:00
|
|
|
// static check that item implements map entity interface
|
|
|
|
var _ d2interface.MapEntity = &Item{}
|
|
|
|
|
2020-07-31 17:55:11 -04:00
|
|
|
// Item is a map entity for an item
|
2020-07-30 15:04:05 -04:00
|
|
|
type Item struct {
|
|
|
|
*AnimatedEntity
|
|
|
|
Item *diablo2item.Item
|
|
|
|
}
|
|
|
|
|
2020-08-05 21:27:45 -04:00
|
|
|
// ID returns the item uuid
|
|
|
|
func (i *Item) ID() string {
|
|
|
|
return i.AnimatedEntity.uuid
|
|
|
|
}
|
|
|
|
|
2020-07-31 17:55:11 -04:00
|
|
|
// GetPosition returns the item position vector
|
2020-07-30 15:04:05 -04:00
|
|
|
func (i *Item) GetPosition() d2vector.Position {
|
|
|
|
return i.AnimatedEntity.Position
|
|
|
|
}
|
|
|
|
|
2020-07-31 17:55:11 -04:00
|
|
|
// GetVelocity returns the item velocity vector
|
2020-07-30 15:04:05 -04:00
|
|
|
func (i *Item) GetVelocity() d2vector.Vector {
|
|
|
|
return i.AnimatedEntity.velocity
|
|
|
|
}
|
|
|
|
|
2020-07-31 17:55:11 -04:00
|
|
|
// Selectable always returns true for items
|
|
|
|
func (i *Item) Selectable() bool {
|
|
|
|
return true
|
|
|
|
}
|
2020-07-30 15:04:05 -04:00
|
|
|
|
2020-07-31 17:55:11 -04:00
|
|
|
// Highlight sets the highlight flag for a single render tick
|
|
|
|
func (i *Item) Highlight() {
|
|
|
|
i.AnimatedEntity.highlight = true
|
|
|
|
}
|
2020-07-30 15:04:05 -04:00
|
|
|
|
2020-09-12 16:25:09 -04:00
|
|
|
// Label returns the item label
|
2020-08-02 21:26:07 -04:00
|
|
|
func (i *Item) Label() string {
|
|
|
|
return i.Item.Label()
|
2020-07-30 15:04:05 -04:00
|
|
|
}
|
2020-08-01 19:03:09 -04:00
|
|
|
|
|
|
|
// GetSize returns the current frame size
|
|
|
|
func (i *Item) GetSize() (width, height int) {
|
|
|
|
w, h := i.animation.GetCurrentFrameSize()
|
|
|
|
|
|
|
|
if w < minHitboxSize {
|
|
|
|
w = minHitboxSize
|
|
|
|
}
|
|
|
|
|
|
|
|
if h < minHitboxSize {
|
|
|
|
h = minHitboxSize
|
|
|
|
}
|
|
|
|
|
|
|
|
return w, h
|
|
|
|
}
|