1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-06 18:27:20 -05:00
OpenDiablo2/d2asset/animation_manager.go

30 lines
682 B
Go
Raw Normal View History

package d2asset
type animationManager struct {
cache *cache
}
func createAnimationManager() *animationManager {
return &animationManager{cache: createCache(AnimationBudget)}
}
func (sm *animationManager) loadAnimation(animationPath, palettePath string) (*Animation, error) {
cachePath := animationPath + palettePath
if animation, found := sm.cache.retrieve(cachePath); found {
return animation.(*Animation).clone(), nil
}
dc6, err := loadDC6(animationPath, palettePath)
if err != nil {
return nil, err
}
animation, err := createAnimationFromDC6(dc6)
if err != nil {
return nil, err
}
sm.cache.insert(cachePath, animation.clone(), 1)
return animation, err
}