From 90f13724cf8f08a23ef8b8f390e53ded53bc1378 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Sat, 27 Feb 2021 17:06:19 +0100 Subject: [PATCH] animation data: methods for editing --- d2common/d2fileformats/d2animdata/record.go | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/d2common/d2fileformats/d2animdata/record.go b/d2common/d2fileformats/d2animdata/record.go index 013981a2..ff843277 100644 --- a/d2common/d2fileformats/d2animdata/record.go +++ b/d2common/d2fileformats/d2animdata/record.go @@ -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 +}