diff --git a/d2common/d2fileformats/d2cof/helpers.go b/d2common/d2fileformats/d2cof/helpers.go index 0cc7f73b..0b3b7fb2 100644 --- a/d2common/d2fileformats/d2cof/helpers.go +++ b/d2common/d2fileformats/d2cof/helpers.go @@ -14,3 +14,14 @@ func (c *COF) SpeedToFPS() float64 { return fps } + +// Duration returns animation's duration +func (c *COF) Duration() float64 { + const ( + milliseconds = 1000 + ) + + frameDelay := milliseconds / c.SpeedToFPS() + + return float64(c.FramesPerDirection) * frameDelay +}