d2asset

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: 31 Imported by: 0

Documentation

Overview

Package d2asset has behaviors to load and save assets from disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation

type Animation struct {
	// contains filtered or unexported fields
}

Animation has directionality, play modes, and frame counting

func (*Animation) Advance

func (a *Animation) Advance(elapsed float64) error

Advance advances the animation state

func (*Animation) BindRenderer

func (a *Animation) BindRenderer(r d2interface.Renderer)

BindRenderer binds the given renderer to the animation so that it can initialize the required surfaces

func (*Animation) Clone

func (a *Animation) Clone() d2interface.Animation

Clone creates a copy of the Animation

func (*Animation) GetCurrentFrame

func (a *Animation) GetCurrentFrame() int

GetCurrentFrame gets index of current frame in animation

func (*Animation) GetCurrentFrameSize

func (a *Animation) GetCurrentFrameSize() (width, height int)

GetCurrentFrameSize gets the Size(width, height) of the current frame.

func (*Animation) GetCurrentFrameSurface

func (a *Animation) GetCurrentFrameSurface() d2interface.Surface

GetCurrentFrameSurface returns the surface for the current frame of the animation

func (*Animation) GetDirection

func (a *Animation) GetDirection() int

GetDirection get the current animation direction

func (*Animation) GetDirectionCount

func (a *Animation) GetDirectionCount() int

GetDirectionCount gets the number of animation direction

func (*Animation) GetFrameBounds

func (a *Animation) GetFrameBounds() (maxWidth, maxHeight int)

GetFrameBounds gets maximum Size(width, height) of all frame.

func (*Animation) GetFrameCount

func (a *Animation) GetFrameCount() int

GetFrameCount gets number of frames in animation

func (*Animation) GetFrameSize

func (a *Animation) GetFrameSize(frameIndex int) (width, height int, err error)

GetFrameSize gets the Size(width, height) of a indexed frame.

func (*Animation) GetPlayedCount

func (a *Animation) GetPlayedCount() int

GetPlayedCount gets the number of times the application played

func (*Animation) IsOnFirstFrame

func (a *Animation) IsOnFirstFrame() bool

IsOnFirstFrame gets if the animation on its first frame

func (*Animation) IsOnLastFrame

func (a *Animation) IsOnLastFrame() bool

IsOnLastFrame gets if the animation on its last frame

func (*Animation) Pause

func (a *Animation) Pause()

Pause animation

func (*Animation) PlayBackward

func (a *Animation) PlayBackward()

PlayBackward plays animation backward

func (*Animation) PlayForward

func (a *Animation) PlayForward()

PlayForward plays animation forward

func (*Animation) Render

func (a *Animation) Render(target d2interface.Surface)

Render renders the animation to the given surface

func (*Animation) RenderFromOrigin

func (a *Animation) RenderFromOrigin(target d2interface.Surface, shadow bool)

RenderFromOrigin renders the animation from the animation origin

func (*Animation) RenderSection

func (a *Animation) RenderSection(target d2interface.Surface, bound image.Rectangle)

RenderSection renders the section of the animation frame enclosed by bounds

func (*Animation) ResetPlayedCount

func (a *Animation) ResetPlayedCount()

ResetPlayedCount resets the play count

func (*Animation) Rewind

func (a *Animation) Rewind()

Rewind animation to beginning

func (*Animation) SetColorMod

func (a *Animation) SetColorMod(colorMod color.Color)

SetColorMod sets the Animation's color mod

func (*Animation) SetCurrentFrame

func (a *Animation) SetCurrentFrame(frameIndex int) error

SetCurrentFrame sets animation at a specific frame

func (*Animation) SetDirection

func (a *Animation) SetDirection(directionIndex int) error

SetDirection places the animation in the direction of an animation

func (*Animation) SetEffect

func (a *Animation) SetEffect(e d2enum.DrawEffect)

SetEffect sets the draw effect for the animation

func (*Animation) SetPlayLength

func (a *Animation) SetPlayLength(playLength float64)

SetPlayLength sets the Animation's play length in seconds

func (*Animation) SetPlayLoop

func (a *Animation) SetPlayLoop(loop bool)

SetPlayLoop sets whether to loop the animation

func (*Animation) SetPlaySpeed

func (a *Animation) SetPlaySpeed(playSpeed float64)

SetPlaySpeed sets play speed of the animation

func (*Animation) SetShadow

func (a *Animation) SetShadow(shadow bool)

SetShadow sets bool for whether or not to draw a shadow

func (*Animation) SetSubLoop

func (a *Animation) SetSubLoop(startFrame, endFrame int)

SetSubLoop sets a sub loop for the animation

type AssetManager

type AssetManager struct {
	*d2util.Logger
	*d2loader.Loader

	Records *d2records.RecordManager
	// contains filtered or unexported fields
}

AssetManager loads files and game objects

func NewAssetManager

func NewAssetManager(logLevel d2util.LogLevel) (*AssetManager, error)

NewAssetManager creates and assigns all necessary dependencies for the AssetManager top-level functions to work correctly

func (*AssetManager) BindTerminalCommands

func (am *AssetManager) BindTerminalCommands(term d2interface.Terminal) error

BindTerminalCommands binds the in-game terminal comands for the asset manager.

func (*AssetManager) FileExists

func (am *AssetManager) FileExists(filePath string) (bool, error)

FileExists checks if a file exists on the underlying file system at the given file path.

func (*AssetManager) LoadAnimation

func (am *AssetManager) LoadAnimation(animationPath, palettePath string) (d2interface.Animation, error)

LoadAnimation loads an Animation by its resource path and its palette path

func (*AssetManager) LoadAnimationWithEffect

func (am *AssetManager) LoadAnimationWithEffect(animationPath, palettePath string,
	effect d2enum.DrawEffect) (d2interface.Animation, error)

LoadAnimationWithEffect loads an Animation by its resource path and its palette path with a given transparency value

func (*AssetManager) LoadAsset

func (am *AssetManager) LoadAsset(filePath string) (io.ReadSeeker, error)

LoadAsset loads an asset

func (*AssetManager) LoadCOF

func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error)

LoadCOF loads and returns the given path as a COF

func (*AssetManager) LoadComposite

func (am *AssetManager) LoadComposite(baseType d2enum.ObjectType, token, palettePath string) (*Composite, error)

LoadComposite creates a composite object from a ObjectLookupRecord and palettePath describing it

func (*AssetManager) LoadDCC

func (am *AssetManager) LoadDCC(dccPath string) (*d2dcc.DCC, error)

LoadDCC loads and returns the given path as a DCC

func (*AssetManager) LoadDS1

func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error)

LoadDS1 loads and returns the given path as a DS1

func (*AssetManager) LoadDT1

func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error)

LoadDT1 loads and returns the given path as a DT1

func (*AssetManager) LoadDataDictionary

func (am *AssetManager) LoadDataDictionary(path string) (*d2txt.DataDictionary, error)

LoadDataDictionary loads a txt data file

func (*AssetManager) LoadFile

func (am *AssetManager) LoadFile(filePath string) ([]byte, error)

LoadFile loads an entire file from a source file path as a []byte

func (*AssetManager) LoadFileStream

func (am *AssetManager) LoadFileStream(filePath string) (io.ReadSeeker, error)

LoadFileStream streams an MPQ file from a source file path

func (*AssetManager) LoadFont

func (am *AssetManager) LoadFont(tablePath, spritePath, palettePath string) (*d2font.Font, error)

LoadFont loads a font the resource files

func (*AssetManager) LoadLanguage

func (am *AssetManager) LoadLanguage(languagePath string) string

LoadLanguage loads language from resource path

func (*AssetManager) LoadPalette

func (am *AssetManager) LoadPalette(palettePath string) (d2interface.Palette, error)

LoadPalette loads a palette from a given palette path

func (*AssetManager) LoadPaletteTransform

func (am *AssetManager) LoadPaletteTransform(path string) (*d2pl2.PL2, error)

LoadPaletteTransform loads a palette transform file

func (*AssetManager) LoadRecords

func (am *AssetManager) LoadRecords(path string) error

LoadRecords will load the records for the given path into the record manager. This is dependant on the record manager having bound a loader for the given path.

func (*AssetManager) LoadStringTable

func (am *AssetManager) LoadStringTable(tablePath string) (d2tbl.TextDictionary, error)

LoadStringTable loads a string table from the given path

func (*AssetManager) SetLogLevel

func (am *AssetManager) SetLogLevel(level d2util.LogLevel)

SetLogLevel sets the log level for the asset manager, record manager, and file loader

func (*AssetManager) TranslateString

func (am *AssetManager) TranslateString(input interface{}) string

TranslateString returns the translation of the given string. The string is retrieved from the loaded string tables. If input value is int (e.g. from d2enum/numeric_labels.go) output string is translation for # + input

func (*AssetManager) UnbindTerminalCommands

func (am *AssetManager) UnbindTerminalCommands(term d2interface.Terminal) error

UnbindTerminalCommands unbinds commands from the terminal

type Composite

type Composite struct {
	*AssetManager
	// contains filtered or unexported fields
}

Composite is a composite entity animation

func (*Composite) Advance

func (c *Composite) Advance(elapsed float64) error

Advance moves the composite animation forward for a given elapsed time in nanoseconds.

func (*Composite) Equip

func (c *Composite) Equip(equipment *[d2enum.CompositeTypeMax]string) error

Equip changes the current layer configuration

func (*Composite) GetAnimationMode

func (c *Composite) GetAnimationMode() string

GetAnimationMode returns the animation mode the Composite should render with.

func (*Composite) GetCurrentFrame

func (c *Composite) GetCurrentFrame() int

GetCurrentFrame returns the frame index in the current animation mode.

func (*Composite) GetDirection

func (c *Composite) GetDirection() int

GetDirection returns the current direction the composite is facing

func (*Composite) GetFrameCount

func (c *Composite) GetFrameCount() int

GetFrameCount returns the number of frames in the current animation mode.

func (*Composite) GetPlayedCount

func (c *Composite) GetPlayedCount() int

GetPlayedCount returns the number of times the current animation mode has completed all its distinct frames

func (*Composite) GetSize

func (c *Composite) GetSize() (w, h int)

GetSize returns the size of the composite

func (*Composite) GetWeaponClass

func (c *Composite) GetWeaponClass() string

GetWeaponClass returns the currently loaded weapon class

func (*Composite) ObjectAnimationMode

func (c *Composite) ObjectAnimationMode() d2enum.ObjectAnimationMode

ObjectAnimationMode returns the object animation mode

func (*Composite) Render

func (c *Composite) Render(target d2interface.Surface) error

Render performs drawing of the Composite on the rendered d2interface.Surface.

func (*Composite) SetAnimSpeed

func (c *Composite) SetAnimSpeed(speed int)

SetAnimSpeed sets the speed at which the Composite's animation should advance through its frames

func (*Composite) SetCurrentFrame

func (c *Composite) SetCurrentFrame(frame int)

SetCurrentFrame sets the current frame index of the animation

func (*Composite) SetDirection

func (c *Composite) SetDirection(direction int)

SetDirection sets the direction of the composite and its layers

func (*Composite) SetMode

func (c *Composite) SetMode(animationMode animationMode, weaponClass string) error

SetMode sets the Composite's animation mode weapon class and direction

func (*Composite) SetPlayLoop

func (c *Composite) SetPlayLoop(loop bool)

SetPlayLoop turns on or off animation looping

func (*Composite) SetSubLoop

func (c *Composite) SetSubLoop(startFrame, endFrame int)

SetSubLoop sets a loop to be between the specified frame indices

type DC6Animation

type DC6Animation struct {
	Animation
	// contains filtered or unexported fields
}

DC6Animation is an animation made from a DC6 file

func (*DC6Animation) Clone

func (a *DC6Animation) Clone() d2interface.Animation

Clone creates a copy of the animation

func (*DC6Animation) SetDirection

func (a *DC6Animation) SetDirection(directionIndex int) error

SetDirection decodes and sets the direction

type DCCAnimation

type DCCAnimation struct {
	Animation
	// contains filtered or unexported fields
}

DCCAnimation represents an animation decoded from DCC

func (*DCCAnimation) Clone

func (a *DCCAnimation) Clone() d2interface.Animation

Clone creates a copy of the animation

func (*DCCAnimation) SetDirection

func (a *DCCAnimation) SetDirection(directionIndex int) error

SetDirection places the animation in the direction of an animation

Jump to

Keyboard shortcuts

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