Documentation ¶
Overview ¶
Package d2mapentity provides representations of map entities
Package d2mapentity implements map entities
Index ¶
- type AnimatedEntity
- func (ae *AnimatedEntity) Advance(elapsed float64)
- func (m *AnimatedEntity) ClearPath()
- func (ae *AnimatedEntity) GetDirection() int
- func (m *AnimatedEntity) GetLayer() int
- func (m *AnimatedEntity) GetPosition() (x, y float64)
- func (m *AnimatedEntity) GetPositionF() (x, y float64)
- func (m *AnimatedEntity) GetSize() (width, height int)
- func (m *AnimatedEntity) GetSpeed() float64
- func (m *AnimatedEntity) Highlight()
- func (m *AnimatedEntity) Label() string
- func (ae *AnimatedEntity) Render(target d2interface.Surface)
- func (m *AnimatedEntity) Selectable() bool
- func (ae *AnimatedEntity) SetHighlight(set bool)
- func (m *AnimatedEntity) SetPath(path []d2vector.Position, done func())
- func (m *AnimatedEntity) SetSpeed(speed float64)
- func (m *AnimatedEntity) Step(tickTime float64)
- func (m *AnimatedEntity) StopMoving()
- type CastOverlay
- func (co *CastOverlay) Advance(tickTime float64)
- func (m CastOverlay) ClearPath()
- func (m CastOverlay) GetLayer() int
- func (co *CastOverlay) GetPosition() d2vector.Position
- func (m CastOverlay) GetPositionF() (x, y float64)
- func (m CastOverlay) GetSize() (width, height int)
- func (m CastOverlay) GetSpeed() float64
- func (co *CastOverlay) GetVelocity() d2vector.Vector
- func (m CastOverlay) Highlight()
- func (co *CastOverlay) ID() string
- func (m CastOverlay) Label() string
- func (m CastOverlay) Selectable() bool
- func (co *CastOverlay) SetOnDoneFunc(onDoneFunc func())
- func (m CastOverlay) SetPath(path []d2vector.Position, done func())
- func (co *CastOverlay) SetRadians(angle float64, done func())
- func (m CastOverlay) SetSpeed(speed float64)
- func (m CastOverlay) Step(tickTime float64)
- func (m CastOverlay) StopMoving()
- type Item
- func (m Item) ClearPath()
- func (m Item) GetLayer() int
- func (i *Item) GetPosition() d2vector.Position
- func (m Item) GetPositionF() (x, y float64)
- func (i *Item) GetSize() (width, height int)
- func (m Item) GetSpeed() float64
- func (i *Item) GetVelocity() d2vector.Vector
- func (i *Item) Highlight()
- func (i *Item) ID() string
- func (i *Item) Label() string
- func (i *Item) Selectable() bool
- func (m Item) SetPath(path []d2vector.Position, done func())
- func (m Item) SetSpeed(speed float64)
- func (m Item) Step(tickTime float64)
- func (m Item) StopMoving()
- type MapEntityFactory
- func (f *MapEntityFactory) NewCastOverlay(x, y int, overlayRecord *d2records.OverlayRecord) (*CastOverlay, error)
- func (f *MapEntityFactory) NewItem(x, y int, codes ...string) (*Item, error)
- func (f *MapEntityFactory) NewMissile(x, y int, record *d2records.MissileRecord) (*Missile, error)
- func (f *MapEntityFactory) NewNPC(x, y int, monstat *d2records.MonStatRecord, direction int) (*NPC, error)
- func (f *MapEntityFactory) NewObject(x, y int, objectRec *d2records.ObjectDetailRecord, palettePath string) (*Object, error)
- func (f *MapEntityFactory) NewPlayer(id, name string, x, y, direction int, heroType d2enum.Hero, ...) *Player
- type Missile
- func (m *Missile) Advance(tickTime float64)
- func (m Missile) ClearPath()
- func (m Missile) GetLayer() int
- func (m *Missile) GetPosition() d2vector.Position
- func (m Missile) GetPositionF() (x, y float64)
- func (m Missile) GetSize() (width, height int)
- func (m Missile) GetSpeed() float64
- func (m *Missile) GetVelocity() d2vector.Vector
- func (m Missile) Highlight()
- func (m *Missile) ID() string
- func (m Missile) Label() string
- func (m Missile) Selectable() bool
- func (m Missile) SetPath(path []d2vector.Position, done func())
- func (m *Missile) SetRadians(angle float64, done func())
- func (m Missile) SetSpeed(speed float64)
- func (m Missile) Step(tickTime float64)
- func (m Missile) StopMoving()
- type NPC
- func (v *NPC) Advance(tickTime float64)
- func (m *NPC) ClearPath()
- func (m *NPC) GetLayer() int
- func (v *NPC) GetPosition() d2vector.Position
- func (m *NPC) GetPositionF() (x, y float64)
- func (v *NPC) GetSize() (width, height int)
- func (m *NPC) GetSpeed() float64
- func (v *NPC) GetVelocity() d2vector.Vector
- func (m *NPC) Highlight()
- func (v *NPC) ID() string
- func (v *NPC) Label() string
- func (v *NPC) NextPath() d2path.Path
- func (v *NPC) Path() d2path.Path
- func (v *NPC) Render(target d2interface.Surface)
- func (v *NPC) Selectable() bool
- func (m *NPC) SetPath(path []d2vector.Position, done func())
- func (v *NPC) SetPaths(paths []d2path.Path)
- func (m *NPC) SetSpeed(speed float64)
- func (m *NPC) Step(tickTime float64)
- func (m *NPC) StopMoving()
- type Object
- func (ob *Object) Advance(elapsed float64)
- func (ob *Object) GetLayer() int
- func (ob *Object) GetPosition() d2vector.Position
- func (ob *Object) GetPositionF() (x, y float64)
- func (ob *Object) GetSize() (width, height int)
- func (ob *Object) GetVelocity() d2vector.Vector
- func (ob *Object) Highlight()
- func (ob *Object) ID() string
- func (ob *Object) Label() string
- func (ob *Object) Render(target d2interface.Surface)
- func (ob *Object) Selectable() bool
- type Player
- func (p *Player) Advance(tickTime float64)
- func (m *Player) ClearPath()
- func (p *Player) GetAnimationMode() d2enum.PlayerAnimationMode
- func (m *Player) GetLayer() int
- func (p *Player) GetPosition() d2vector.Position
- func (m *Player) GetPositionF() (x, y float64)
- func (p *Player) GetSize() (width, height int)
- func (m *Player) GetSpeed() float64
- func (p *Player) GetVelocity() d2vector.Vector
- func (m *Player) Highlight()
- func (p *Player) ID() string
- func (p *Player) IsCasting() bool
- func (p *Player) IsInTown() bool
- func (p *Player) IsRunToggled() bool
- func (p *Player) IsRunning() bool
- func (m *Player) Label() string
- func (p *Player) Name() string
- func (p *Player) Render(target d2interface.Surface)
- func (p *Player) Selectable() bool
- func (p *Player) SetAnimationMode(animationMode d2enum.PlayerAnimationMode) error
- func (p *Player) SetDirection(direction int)
- func (p *Player) SetIsInTown(isInTown bool)
- func (p *Player) SetIsRunning(isRunning bool)
- func (m *Player) SetPath(path []d2vector.Position, done func())
- func (m *Player) SetSpeed(speed float64)
- func (p *Player) StartCasting(animMode d2enum.PlayerAnimationMode, onFinishedCasting func())
- func (m *Player) Step(tickTime float64)
- func (m *Player) StopMoving()
- func (p *Player) ToggleRunWalk()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnimatedEntity ¶
type AnimatedEntity struct {
// contains filtered or unexported fields
}
AnimatedEntity represents an animation that can be projected onto the map. nolint:structcheck,unused // variables are unused because it is incomplete
func NewAnimatedEntity ¶
func NewAnimatedEntity(x, y int, animation d2interface.Animation) *AnimatedEntity
NewAnimatedEntity creates an instance of AnimatedEntity
func (*AnimatedEntity) Advance ¶
func (ae *AnimatedEntity) Advance(elapsed float64)
Advance is called once per frame and processes a single game tick.
func (*AnimatedEntity) ClearPath ¶
func (m *AnimatedEntity) ClearPath()
ClearPath clears the entity movement path.
func (*AnimatedEntity) GetDirection ¶
func (ae *AnimatedEntity) GetDirection() int
GetDirection returns the current facing direction of this entity.
func (*AnimatedEntity) GetLayer ¶
func (m *AnimatedEntity) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*AnimatedEntity) GetPosition ¶
func (m *AnimatedEntity) GetPosition() (x, y float64)
GetPosition returns the entity's current tile position, always a whole number.
func (*AnimatedEntity) GetPositionF ¶
func (m *AnimatedEntity) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (*AnimatedEntity) GetSize ¶
func (m *AnimatedEntity) GetSize() (width, height int)
GetSize returns the current frame size
func (*AnimatedEntity) GetSpeed ¶
func (m *AnimatedEntity) GetSpeed() float64
GetSpeed returns the entity movement speed.
func (*AnimatedEntity) Highlight ¶
func (m *AnimatedEntity) Highlight()
Highlight is not currently implemented.
func (*AnimatedEntity) Label ¶
func (m *AnimatedEntity) Label() string
Label returns the NPC's in-game name (e.g. "Deckard Cain") or an empty string if it does not have a name
func (*AnimatedEntity) Render ¶
func (ae *AnimatedEntity) Render(target d2interface.Surface)
Render draws this animated entity onto the target
func (*AnimatedEntity) Selectable ¶
func (m *AnimatedEntity) Selectable() bool
Selectable returns true if the object can be highlighted/selected.
func (*AnimatedEntity) SetHighlight ¶
func (ae *AnimatedEntity) SetHighlight(set bool)
SetHighlight sets the highlight state of the animated entity
func (*AnimatedEntity) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (*AnimatedEntity) SetSpeed ¶
func (m *AnimatedEntity) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (*AnimatedEntity) Step ¶
func (m *AnimatedEntity) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (*AnimatedEntity) StopMoving ¶
func (m *AnimatedEntity) StopMoving()
StopMoving will clear the path and target of the entity.
type CastOverlay ¶
type CastOverlay struct { *AnimatedEntity // contains filtered or unexported fields }
CastOverlay is an animated entity representing a projectile that is a result of a skill cast.
func (*CastOverlay) Advance ¶
func (co *CastOverlay) Advance(tickTime float64)
Advance is called once per frame and processes a single game tick.
func (CastOverlay) ClearPath ¶
func (m CastOverlay) ClearPath()
ClearPath clears the entity movement path.
func (CastOverlay) GetLayer ¶
func (m CastOverlay) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*CastOverlay) GetPosition ¶
func (co *CastOverlay) GetPosition() d2vector.Position
GetPosition returns the position of the overlay
func (CastOverlay) GetPositionF ¶
func (m CastOverlay) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (CastOverlay) GetSize ¶
func (m CastOverlay) GetSize() (width, height int)
GetSize returns the current frame size
func (CastOverlay) GetSpeed ¶
func (m CastOverlay) GetSpeed() float64
GetSpeed returns the entity movement speed.
func (*CastOverlay) GetVelocity ¶
func (co *CastOverlay) GetVelocity() d2vector.Vector
GetVelocity returns the velocity vector of the overlay
func (CastOverlay) Highlight ¶
func (m CastOverlay) Highlight()
Highlight is not currently implemented.
func (CastOverlay) Label ¶
func (m CastOverlay) Label() string
Label returns the NPC's in-game name (e.g. "Deckard Cain") or an empty string if it does not have a name
func (CastOverlay) Selectable ¶
func (m CastOverlay) Selectable() bool
Selectable returns true if the object can be highlighted/selected.
func (*CastOverlay) SetOnDoneFunc ¶
func (co *CastOverlay) SetOnDoneFunc(onDoneFunc func())
SetOnDoneFunc changes the handler func that gets called when the overlay finishes playing.
func (CastOverlay) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (*CastOverlay) SetRadians ¶
func (co *CastOverlay) SetRadians(angle float64, done func())
SetRadians adjusts the entity target based on it's range, rotating it's current destination by the value of angle in radians.
func (CastOverlay) SetSpeed ¶
func (m CastOverlay) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (CastOverlay) Step ¶
func (m CastOverlay) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (CastOverlay) StopMoving ¶
func (m CastOverlay) StopMoving()
StopMoving will clear the path and target of the entity.
type Item ¶
type Item struct { *AnimatedEntity Item *diablo2item.Item }
Item is a map entity for an item
func (Item) GetLayer ¶
func (m Item) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*Item) GetPosition ¶
GetPosition returns the item position vector
func (Item) GetPositionF ¶
func (m Item) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (*Item) GetVelocity ¶
GetVelocity returns the item velocity vector
func (*Item) Highlight ¶
func (i *Item) Highlight()
Highlight sets the highlight flag for a single render tick
func (Item) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (Item) SetSpeed ¶
func (m Item) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (Item) Step ¶
func (m Item) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (Item) StopMoving ¶
func (m Item) StopMoving()
StopMoving will clear the path and target of the entity.
type MapEntityFactory ¶
type MapEntityFactory struct { *d2hero.HeroStateFactory // contains filtered or unexported fields }
MapEntityFactory creates map entities for the MapEngine
func NewMapEntityFactory ¶
func NewMapEntityFactory(asset *d2asset.AssetManager) (*MapEntityFactory, error)
NewMapEntityFactory creates a MapEntityFactory instance with the given asset manager
func (*MapEntityFactory) NewCastOverlay ¶
func (f *MapEntityFactory) NewCastOverlay(x, y int, overlayRecord *d2records.OverlayRecord) (*CastOverlay, error)
NewCastOverlay creates a cast overlay map entity
func (*MapEntityFactory) NewItem ¶
func (f *MapEntityFactory) NewItem(x, y int, codes ...string) (*Item, error)
NewItem creates an item map entity
func (*MapEntityFactory) NewMissile ¶
func (f *MapEntityFactory) NewMissile(x, y int, record *d2records.MissileRecord) (*Missile, error)
NewMissile creates a new Missile and initializes it's animation.
func (*MapEntityFactory) NewNPC ¶
func (f *MapEntityFactory) NewNPC(x, y int, monstat *d2records.MonStatRecord, direction int) (*NPC, error)
NewNPC creates a new NPC and returns a pointer to it.
func (*MapEntityFactory) NewObject ¶
func (f *MapEntityFactory) NewObject(x, y int, objectRec *d2records.ObjectDetailRecord, palettePath string) (*Object, error)
NewObject creates an instance of AnimatedComposite
func (*MapEntityFactory) NewPlayer ¶
func (f *MapEntityFactory) NewPlayer(id, name string, x, y, direction int, heroType d2enum.Hero, stats *d2hero.HeroStatsState, skills map[int]*d2hero.HeroSkill, equipment *d2inventory.CharacterEquipment, leftSkill, rightSkill, gold int) *Player
NewPlayer creates a new player entity and returns a pointer to it.
type Missile ¶
type Missile struct { *AnimatedEntity // contains filtered or unexported fields }
Missile is a simple animated entity representing a projectile, such as a spell or arrow.
func (Missile) GetLayer ¶
func (m Missile) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*Missile) GetPosition ¶
GetPosition returns the position of the missile
func (Missile) GetPositionF ¶
func (m Missile) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (Missile) GetSize ¶
func (m Missile) GetSize() (width, height int)
GetSize returns the current frame size
func (Missile) GetSpeed ¶
func (m Missile) GetSpeed() float64
GetSpeed returns the entity movement speed.
func (*Missile) GetVelocity ¶
GetVelocity returns the velocity vector of the missile
func (Missile) Label ¶
func (m Missile) Label() string
Label returns the NPC's in-game name (e.g. "Deckard Cain") or an empty string if it does not have a name
func (Missile) Selectable ¶
func (m Missile) Selectable() bool
Selectable returns true if the object can be highlighted/selected.
func (Missile) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (*Missile) SetRadians ¶
SetRadians adjusts the entity target based on it's range, rotating it's current destination by the value of angle in radians.
func (Missile) SetSpeed ¶
func (m Missile) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (Missile) Step ¶
func (m Missile) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (Missile) StopMoving ¶
func (m Missile) StopMoving()
StopMoving will clear the path and target of the entity.
type NPC ¶
NPC is a passive complex entity with which the player can interact. For example, Deckard Cain.
func (*NPC) GetLayer ¶
func (m *NPC) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*NPC) GetPosition ¶
GetPosition returns the NPC's position
func (*NPC) GetPositionF ¶
func (m *NPC) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (*NPC) GetVelocity ¶
GetVelocity returns the NPC's velocity vector
func (*NPC) Label ¶
Label returns the NPC's in-game name (e.g. "Deckard Cain") or an empty string if it does not have a name.
func (*NPC) Render ¶
func (v *NPC) Render(target d2interface.Surface)
Render renders this entity's animated composite.
func (*NPC) Selectable ¶
Selectable returns true if the object can be highlighted/selected.
func (*NPC) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (*NPC) SetPaths ¶
SetPaths sets the entity's paths to the given slice. It also sets flags on the entity indicating that it has paths and has completed the previous none.
func (*NPC) SetSpeed ¶
func (m *NPC) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (*NPC) Step ¶
func (m *NPC) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (*NPC) StopMoving ¶
func (m *NPC) StopMoving()
StopMoving will clear the path and target of the entity.
type Object ¶
Object represents a composite of animations that can be projected onto the map.
func (*Object) GetPosition ¶
GetPosition returns the object's position
func (*Object) GetPositionF ¶
GetPositionF of the object but differently
func (*Object) GetVelocity ¶
GetVelocity returns the object's velocity vector
func (*Object) Highlight ¶
func (ob *Object) Highlight()
Highlight sets the entity highlighted flag to true.
func (*Object) Render ¶
func (ob *Object) Render(target d2interface.Surface)
Render draws this animated entity onto the target
func (*Object) Selectable ¶
Selectable returns if the object is selectable or not
type Player ¶
type Player struct { Equipment *d2inventory.CharacterEquipment Stats *d2hero.HeroStatsState Skills map[int]*d2hero.HeroSkill LeftSkill *d2hero.HeroSkill RightSkill *d2hero.HeroSkill Class d2enum.Hero Gold int Act int // contains filtered or unexported fields }
Player is the player character entity.
func (*Player) GetAnimationMode ¶
func (p *Player) GetAnimationMode() d2enum.PlayerAnimationMode
GetAnimationMode returns the current animation mode based on what the player is doing and where they are.
func (*Player) GetLayer ¶
func (m *Player) GetLayer() int
GetLayer returns the draw layer for this entity.
func (*Player) GetPosition ¶
GetPosition returns the entity's position
func (*Player) GetPositionF ¶
func (m *Player) GetPositionF() (x, y float64)
GetPositionF returns the entity's current tile position where 0.2 is one sub tile.
func (*Player) GetSpeed ¶
func (m *Player) GetSpeed() float64
GetSpeed returns the entity movement speed.
func (*Player) GetVelocity ¶
GetVelocity returns the entity's velocity vector
func (*Player) IsRunToggled ¶
IsRunToggled returns true if the UI button to toggle running is, toggled i.e. not in it's default state.
func (*Player) Label ¶
func (m *Player) Label() string
Label returns the NPC's in-game name (e.g. "Deckard Cain") or an empty string if it does not have a name
func (*Player) Render ¶
func (p *Player) Render(target d2interface.Surface)
Render renders the animated composite for this entity.
func (*Player) Selectable ¶
Selectable returns true if the player is in town.
func (*Player) SetAnimationMode ¶
func (p *Player) SetAnimationMode(animationMode d2enum.PlayerAnimationMode) error
SetAnimationMode sets the Composite's animation mode weapon class and direction.
func (*Player) SetDirection ¶
SetDirection will rotate the player and change the animation
func (*Player) SetIsInTown ¶
SetIsInTown sets a flag indicating that the player is in town.
func (*Player) SetIsRunning ¶
SetIsRunning alters the player speed and sets a flag indicating that the player is running.
func (*Player) SetPath ¶
SetPath sets the entity movement path. done() is called when the entity reaches it's path destination. For example, when the player entity reaches the point a player clicked.
func (*Player) SetSpeed ¶
func (m *Player) SetSpeed(speed float64)
SetSpeed sets the entity movement speed.
func (*Player) StartCasting ¶
func (p *Player) StartCasting(animMode d2enum.PlayerAnimationMode, onFinishedCasting func())
StartCasting sets a flag indicating the player is casting a skill and sets the animation mode to the casting animation. This handles all types of skills - melee, ranged, kick, summon, etc. NB: onFinishedCasting is called when the casting animation is >50% complete
func (*Player) Step ¶
func (m *Player) Step(tickTime float64)
Step moves the entity along it's path by one tick. If the path is complete it calls entity.done() then returns.
func (*Player) StopMoving ¶
func (m *Player) StopMoving()
StopMoving will clear the path and target of the entity.
func (*Player) ToggleRunWalk ¶
func (p *Player) ToggleRunWalk()
ToggleRunWalk sets a flag indicating whether the player is running.