1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-04 23:10:42 +00:00

animation data: methods for editing

This commit is contained in:
M. Sz 2021-02-27 17:06:19 +01:00
parent fa4276156c
commit 90f13724cf

View File

@ -13,11 +13,21 @@ func (r *AnimationDataRecord) FramesPerDirection() int {
return int(r.framesPerDirection)
}
// SetFramesPerDirection sets frames per direction value
func (r *AnimationDataRecord) SetFramesPerDirection(fpd uint32) {
r.framesPerDirection = fpd
}
// Speed returns animation's speed
func (r *AnimationDataRecord) Speed() int {
return int(r.speed)
}
// SetSpeed sets record's speed
func (r *AnimationDataRecord) SetSpeed(s uint16) {
r.speed = s
}
// FPS returns the frames per second for this animation record
func (r *AnimationDataRecord) FPS() float64 {
speedf := float64(r.speed)
@ -31,3 +41,23 @@ func (r *AnimationDataRecord) FPS() float64 {
func (r *AnimationDataRecord) FrameDurationMS() float64 {
return milliseconds / r.FPS()
}
// Events returns events map
func (r *AnimationDataRecord) Events() map[int]AnimationEvent {
return r.events
}
// Event returns specific event
func (r *AnimationDataRecord) Event(idx int) AnimationEvent {
event, found := r.events[idx]
if found {
return event
}
return AnimationEventNone
}
// SetEvent sets event on specific index to given
func (r *AnimationDataRecord) SetEvent(index int, event AnimationEvent) {
r.events[index] = event
}