mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-02 17:27:23 -04:00
65cce60eab
* adding animdata loader * utility methods, more tests, export record struct - added methods for fps and frame duration calculation to the AnimationDataRecord - exported AnimationDataRecord - split the various structs into their own files - added getter methods for retrieving records by name - added tests for the new utility methods
24 lines
672 B
Go
24 lines
672 B
Go
package d2animdata
|
|
|
|
// AnimationDataRecord represents a single record from the AnimData.d2 file
|
|
type AnimationDataRecord struct {
|
|
name string
|
|
framesPerDirection uint32
|
|
speed uint16
|
|
events map[int]AnimationEvent
|
|
}
|
|
|
|
// FPS returns the frames per second for this animation record
|
|
func (r *AnimationDataRecord) FPS() float64 {
|
|
speedf := float64(r.speed)
|
|
divisorf := float64(speedDivisor)
|
|
basef := float64(speedBaseFPS)
|
|
|
|
return basef * speedf / divisorf
|
|
}
|
|
|
|
// FrameDurationMS returns the duration in milliseconds that a frame is displayed
|
|
func (r *AnimationDataRecord) FrameDurationMS() float64 {
|
|
return milliseconds / r.FPS()
|
|
}
|