1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-10 06:16:27 -05:00
OpenDiablo2/d2core/d2asset/asset_manager.go
2020-06-28 22:32:34 -04:00

56 lines
1.2 KiB
Go

package d2asset
import (
"errors"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2cof"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dc6"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dcc"
)
var (
ErrWasInit = errors.New("asset system is already initialized")
ErrNotInit = errors.New("asset system is not initialized")
)
type assetManager struct {
archiveManager *archiveManager
fileManager *fileManager
paletteManager *paletteManager
paletteTransformManager *paletteTransformManager
animationManager *animationManager
fontManager *fontManager
}
func loadDC6(dc6Path string) (*d2dc6.DC6, error) {
dc6Data, err := LoadFile(dc6Path)
if err != nil {
return nil, err
}
dc6, err := d2dc6.Load(dc6Data)
if err != nil {
return nil, err
}
return dc6, nil
}
func loadDCC(dccPath string) (*d2dcc.DCC, error) {
dccData, err := LoadFile(dccPath)
if err != nil {
return nil, err
}
return d2dcc.Load(dccData)
}
func loadCOF(cofPath string) (*d2cof.COF, error) {
cofData, err := LoadFile(cofPath)
if err != nil {
return nil, err
}
return d2cof.Load(cofData)
}