d2animdata

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: 4 Imported by: 3

Documentation

Overview

Package d2animdata provides a file parser for AnimData files. AnimData files have the '.d2' file extension, but we do not call this package `d2d2` because multiple file types share this extension, and because the project namespace prefix makes it sound terrible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimationData

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

AnimationData is a representation of the binary data from `data/global/AnimData.d2`

func Load

func Load(data []byte) (*AnimationData, error)

Load loads the data into an AnimationData struct

func (*AnimationData) AddEntry

func (ad *AnimationData) AddEntry(name string) error

AddEntry adds a new animation entry with name given

func (*AnimationData) DeleteEntry

func (ad *AnimationData) DeleteEntry(name string) error

DeleteEntry deltees entry with specified name

func (*AnimationData) DeleteRecord

func (ad *AnimationData) DeleteRecord(name string, recordIdx int) error

DeleteRecord teletes specified index from specified entry

func (*AnimationData) GetRecord

func (ad *AnimationData) GetRecord(name string) *AnimationDataRecord

GetRecord returns a single AnimationDataRecord with the given name string. If there is more than one record with the given name string, the last record entry will be returned.

func (*AnimationData) GetRecordNames

func (ad *AnimationData) GetRecordNames() []string

GetRecordNames returns a slice of all record name strings

func (*AnimationData) GetRecords

func (ad *AnimationData) GetRecords(name string) []*AnimationDataRecord

GetRecords returns all records that have the given name string. The AnimData.d2 files have multiple records with the same name, but other values in the record are different.

func (*AnimationData) GetRecordsCount

func (ad *AnimationData) GetRecordsCount() int

GetRecordsCount returns number of animation data records

func (*AnimationData) Marshal

func (ad *AnimationData) Marshal() []byte

Marshal encodes animation data back into byte slice basing on AnimationData.records

func (*AnimationData) PushRecord

func (ad *AnimationData) PushRecord(name string)

PushRecord adds a new record to entry named 'name'

type AnimationDataRecord

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

AnimationDataRecord represents a single record from the AnimData.d2 file

func (*AnimationDataRecord) Event

func (r *AnimationDataRecord) Event(idx int) AnimationEvent

Event returns specific event

func (*AnimationDataRecord) Events

func (r *AnimationDataRecord) Events() map[int]AnimationEvent

Events returns events map

func (*AnimationDataRecord) FPS

func (r *AnimationDataRecord) FPS() float64

FPS returns the frames per second for this animation record

func (*AnimationDataRecord) FrameDurationMS

func (r *AnimationDataRecord) FrameDurationMS() float64

FrameDurationMS returns the duration in milliseconds that a frame is displayed

func (*AnimationDataRecord) FramesPerDirection

func (r *AnimationDataRecord) FramesPerDirection() int

FramesPerDirection returns frames per direction value

func (*AnimationDataRecord) SetEvent

func (r *AnimationDataRecord) SetEvent(index int, event AnimationEvent)

SetEvent sets event on specific index to given

func (*AnimationDataRecord) SetFramesPerDirection

func (r *AnimationDataRecord) SetFramesPerDirection(fpd uint32)

SetFramesPerDirection sets frames per direction value

func (*AnimationDataRecord) SetSpeed

func (r *AnimationDataRecord) SetSpeed(s uint16)

SetSpeed sets record's speed

func (*AnimationDataRecord) Speed

func (r *AnimationDataRecord) Speed() int

Speed returns animation's speed

type AnimationEvent

type AnimationEvent byte

AnimationEvent represents an event that can happen on a frame of animation

const (
	AnimationEventNone AnimationEvent = iota
	AnimationEventAttack
	AnimationEventMissile
	AnimationEventSound
	AnimationEventSkill
)

Animation events

Jump to

Keyboard shortcuts

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