diff options
Diffstat (limited to 'engine/Components')
| -rw-r--r-- | engine/Components/ResourceManager.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/engine/Components/ResourceManager.go b/engine/Components/ResourceManager.go index 19f0315..3e62a6b 100644 --- a/engine/Components/ResourceManager.go +++ b/engine/Components/ResourceManager.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + coreobjects "github.com/DegustatorPonos/RuinesOfRafdolon/CoreObjects" settings "github.com/DegustatorPonos/RuinesOfRafdolon/Settings" rl "github.com/gen2brain/raylib-go/raylib" ) @@ -13,6 +14,7 @@ var Resources ResourceManager type ResourceManager struct { LoadedPackages map[string]*settings.AppVersion Textures TextrueManager + Objects map[string]*coreobjects.DynamicObject Worlds map[string]*World } @@ -20,6 +22,7 @@ func InitManager() { Resources = ResourceManager{ LoadedPackages: make(map[string]*settings.AppVersion), Worlds: make(map[string]*World), + Objects: make(map[string]*coreobjects.DynamicObject), Textures: TextrueManager{ Textures: make([]*rl.Texture2D, 0), NameToId: make(map[string]uint64), @@ -27,6 +30,15 @@ func InitManager() { } } +func (base *ResourceManager) RegisterObject(PackageName string, obejctName string, new *coreobjects.DynamicObject) error { + var displayName = fmt.Sprintf("%s/%s", PackageName, obejctName) + if _, exists := base.Objects[displayName]; exists { + return fmt.Errorf("Failed to register the obejct: another obejct with that name already exists") + } + base.Objects[displayName] = new + return nil +} + func (base *ResourceManager) String() string { var outp, jsonErr = json.Marshal(base) if jsonErr != nil { |
