Merge pull request #1079 from gucio321/anim-data-encoder

animation data: methods for editing
This commit is contained in:
gravestench 2021-03-03 11:13:35 -08:00 committed by GitHub
commit b72017dbd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

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
}