1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-09 19:57:20 -05:00
OpenDiablo2/d2core/d2map/d2mapentity/item.go
lord 8b2b991b12
D2mapengine remove entity, minor edits (#694)
* implement entity removal

* add rgba color func, fix some lint errors in d2map

* bugfix for map entity tests
2020-08-05 21:27:45 -04:00

66 lines
1.4 KiB
Go

package d2mapentity
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2math/d2vector"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2item/diablo2item"
)
// static check that item implements map entity interface
var _ d2interface.MapEntity = &Item{}
const (
errInvalidItemCodes = "invalid item codes supplied"
)
// Item is a map entity for an item
type Item struct {
*AnimatedEntity
Item *diablo2item.Item
}
// ID returns the item uuid
func (i *Item) ID() string {
return i.AnimatedEntity.uuid
}
// GetPosition returns the item position vector
func (i *Item) GetPosition() d2vector.Position {
return i.AnimatedEntity.Position
}
// GetVelocity returns the item velocity vector
func (i *Item) GetVelocity() d2vector.Vector {
return i.AnimatedEntity.velocity
}
// Selectable always returns true for items
func (i *Item) Selectable() bool {
return true
}
// Highlight sets the highlight flag for a single render tick
func (i *Item) Highlight() {
i.AnimatedEntity.highlight = true
}
// Name returns the item name
func (i *Item) Label() string {
return i.Item.Label()
}
// 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
}