d2mapentity

package
v0.0.0-...-7f92c57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package d2mapentity provides representations of map entities

Package d2mapentity implements map entities

Index

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

func (m *AnimatedEntity) SetPath(path []d2vector.Position, done func())

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) ID

func (co *CastOverlay) ID() string

ID returns the overlay uuid

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

func (m CastOverlay) SetPath(path []d2vector.Position, done func())

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) ClearPath

func (m Item) ClearPath()

ClearPath clears the entity movement path.

func (Item) GetLayer

func (m Item) GetLayer() int

GetLayer returns the draw layer for this entity.

func (*Item) GetPosition

func (i *Item) GetPosition() d2vector.Position

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) GetSize

func (i *Item) GetSize() (width, height int)

GetSize returns the current frame size

func (Item) GetSpeed

func (m Item) GetSpeed() float64

GetSpeed returns the entity movement speed.

func (*Item) GetVelocity

func (i *Item) GetVelocity() d2vector.Vector

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) ID

func (i *Item) ID() string

ID returns the item uuid

func (*Item) Label

func (i *Item) Label() string

Label returns the item label

func (*Item) Selectable

func (i *Item) Selectable() bool

Selectable always returns true for items

func (Item) SetPath

func (m Item) SetPath(path []d2vector.Position, done func())

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) Advance

func (m *Missile) Advance(tickTime float64)

Advance is called once per frame and processes a single game tick.

func (Missile) ClearPath

func (m Missile) ClearPath()

ClearPath clears the entity movement path.

func (Missile) GetLayer

func (m Missile) GetLayer() int

GetLayer returns the draw layer for this entity.

func (*Missile) GetPosition

func (m *Missile) GetPosition() d2vector.Position

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

func (m *Missile) GetVelocity() d2vector.Vector

GetVelocity returns the velocity vector of the missile

func (Missile) Highlight

func (m Missile) Highlight()

Highlight is not currently implemented.

func (*Missile) ID

func (m *Missile) ID() string

ID returns the missile uuid

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

func (m Missile) SetPath(path []d2vector.Position, done func())

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

func (m *Missile) 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 (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

type NPC struct {
	Paths []d2path.Path

	HasPaths bool
	// contains filtered or unexported fields
}

NPC is a passive complex entity with which the player can interact. For example, Deckard Cain.

func (*NPC) Advance

func (v *NPC) Advance(tickTime float64)

Advance is called once per frame and processes a single game tick.

func (*NPC) ClearPath

func (m *NPC) ClearPath()

ClearPath clears the entity movement path.

func (*NPC) GetLayer

func (m *NPC) GetLayer() int

GetLayer returns the draw layer for this entity.

func (*NPC) GetPosition

func (v *NPC) GetPosition() d2vector.Position

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) GetSize

func (v *NPC) GetSize() (width, height int)

GetSize returns the current frame size

func (*NPC) GetSpeed

func (m *NPC) GetSpeed() float64

GetSpeed returns the entity movement speed.

func (*NPC) GetVelocity

func (v *NPC) GetVelocity() d2vector.Vector

GetVelocity returns the NPC's velocity vector

func (*NPC) Highlight

func (m *NPC) Highlight()

Highlight is not currently implemented.

func (*NPC) ID

func (v *NPC) ID() string

ID returns the NPC uuid

func (*NPC) Label

func (v *NPC) 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 (*NPC) NextPath

func (v *NPC) NextPath() d2path.Path

NextPath returns the next part of the entity's path.

func (*NPC) Path

func (v *NPC) Path() d2path.Path

Path returns the current part of the entity's path.

func (*NPC) Render

func (v *NPC) Render(target d2interface.Surface)

Render renders this entity's animated composite.

func (*NPC) Selectable

func (v *NPC) Selectable() bool

Selectable returns true if the object can be highlighted/selected.

func (*NPC) SetPath

func (m *NPC) SetPath(path []d2vector.Position, done func())

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

func (v *NPC) SetPaths(paths []d2path.Path)

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

type Object struct {
	Position d2vector.Position
	// contains filtered or unexported fields
}

Object represents a composite of animations that can be projected onto the map.

func (*Object) Advance

func (ob *Object) Advance(elapsed float64)

Advance updates the animation

func (*Object) GetLayer

func (ob *Object) GetLayer() int

GetLayer returns which layer of the map the object is drawn

func (*Object) GetPosition

func (ob *Object) GetPosition() d2vector.Position

GetPosition returns the object's position

func (*Object) GetPositionF

func (ob *Object) GetPositionF() (x, y float64)

GetPositionF of the object but differently

func (*Object) GetSize

func (ob *Object) GetSize() (width, height int)

GetSize returns the current frame size

func (*Object) GetVelocity

func (ob *Object) GetVelocity() d2vector.Vector

GetVelocity returns the object's velocity vector

func (*Object) Highlight

func (ob *Object) Highlight()

Highlight sets the entity highlighted flag to true.

func (*Object) ID

func (ob *Object) ID() string

ID returns the object uuid

func (*Object) Label

func (ob *Object) Label() string

Label gets the name of the object

func (*Object) Render

func (ob *Object) Render(target d2interface.Surface)

Render draws this animated entity onto the target

func (*Object) Selectable

func (ob *Object) Selectable() bool

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) Advance

func (p *Player) Advance(tickTime float64)

Advance is called once per frame and processes a single game tick.

func (*Player) ClearPath

func (m *Player) ClearPath()

ClearPath clears the entity movement path.

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

func (p *Player) GetPosition() d2vector.Position

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) GetSize

func (p *Player) GetSize() (width, height int)

GetSize returns the current frame size

func (*Player) GetSpeed

func (m *Player) GetSpeed() float64

GetSpeed returns the entity movement speed.

func (*Player) GetVelocity

func (p *Player) GetVelocity() d2vector.Vector

GetVelocity returns the entity's velocity vector

func (*Player) Highlight

func (m *Player) Highlight()

Highlight is not currently implemented.

func (*Player) ID

func (p *Player) ID() string

ID returns the Player uuid

func (*Player) IsCasting

func (p *Player) IsCasting() bool

IsCasting returns true if

func (*Player) IsInTown

func (p *Player) IsInTown() bool

IsInTown returns true if the player is currently in town.

func (*Player) IsRunToggled

func (p *Player) IsRunToggled() bool

IsRunToggled returns true if the UI button to toggle running is, toggled i.e. not in it's default state.

func (*Player) IsRunning

func (p *Player) IsRunning() bool

IsRunning returns true if the player is currently

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) Name

func (p *Player) Name() string

Name returns the player name.

func (*Player) Render

func (p *Player) Render(target d2interface.Surface)

Render renders the animated composite for this entity.

func (*Player) Selectable

func (p *Player) Selectable() bool

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

func (p *Player) SetDirection(direction int)

SetDirection will rotate the player and change the animation

func (*Player) SetIsInTown

func (p *Player) SetIsInTown(isInTown bool)

SetIsInTown sets a flag indicating that the player is in town.

func (*Player) SetIsRunning

func (p *Player) SetIsRunning(isRunning bool)

SetIsRunning alters the player speed and sets a flag indicating that the player is running.

func (*Player) SetPath

func (m *Player) SetPath(path []d2vector.Position, done func())

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL