summaryrefslogtreecommitdiff
path: root/engine/Components
diff options
context:
space:
mode:
authorPhyscik <mynameisgennadiy@vk.com>2026-01-24 00:25:45 +0500
committerPhyscik <mynameisgennadiy@vk.com>2026-01-24 00:25:45 +0500
commitaa35ce4db5326928cf13c7604014fb7aaaedf203 (patch)
tree12cfdb8020220c9f9727a58c41afd9bf49b27d63 /engine/Components
parent5e7333315ed55c237b28013711c4edefc0b56201 (diff)
Dynamic object loading
Diffstat (limited to 'engine/Components')
-rw-r--r--engine/Components/ResourceManager.go12
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 {