summaryrefslogtreecommitdiff
path: root/engine/Components
diff options
context:
space:
mode:
authorPhyscik <mynameisgennadiy@vk.com>2026-01-25 01:11:59 +0500
committerPhyscik <mynameisgennadiy@vk.com>2026-01-25 01:11:59 +0500
commit3ba197732d13d84eca0d706218b38d4f84cecba9 (patch)
treebcb9a967cb648277325ea60ba45905c024a2f8d6 /engine/Components
parentaa35ce4db5326928cf13c7604014fb7aaaedf203 (diff)
Object scene registry
Diffstat (limited to 'engine/Components')
-rw-r--r--engine/Components/ResourceManager.go16
-rw-r--r--engine/Components/World.go4
2 files changed, 16 insertions, 4 deletions
diff --git a/engine/Components/ResourceManager.go b/engine/Components/ResourceManager.go
index 3e62a6b..cbccf5f 100644
--- a/engine/Components/ResourceManager.go
+++ b/engine/Components/ResourceManager.go
@@ -14,7 +14,7 @@ var Resources ResourceManager
type ResourceManager struct {
LoadedPackages map[string]*settings.AppVersion
Textures TextrueManager
- Objects map[string]*coreobjects.DynamicObject
+ objects map[string]*coreobjects.DynamicObject
Worlds map[string]*World
}
@@ -22,7 +22,7 @@ func InitManager() {
Resources = ResourceManager{
LoadedPackages: make(map[string]*settings.AppVersion),
Worlds: make(map[string]*World),
- Objects: make(map[string]*coreobjects.DynamicObject),
+ objects: make(map[string]*coreobjects.DynamicObject),
Textures: TextrueManager{
Textures: make([]*rl.Texture2D, 0),
NameToId: make(map[string]uint64),
@@ -32,13 +32,21 @@ 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 {
+ 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
+ base.objects[displayName] = new
return nil
}
+func (base *ResourceManager) GetObject(name string) (*coreobjects.DynamicObject, error) {
+ var obj, exists = base.objects[name]
+ if !exists {
+ return nil, fmt.Errorf("An object '%s' was not found", name)
+ }
+ return obj, nil
+}
+
func (base *ResourceManager) String() string {
var outp, jsonErr = json.Marshal(base)
if jsonErr != nil {
diff --git a/engine/Components/World.go b/engine/Components/World.go
index 2b7954a..397cbb7 100644
--- a/engine/Components/World.go
+++ b/engine/Components/World.go
@@ -10,6 +10,7 @@ type World struct {
Manager coreobjects.SceneManager
Name string
Floor []FloorTile
+ StaticObjects []coreobjects.GameObject
Player *Player
@@ -58,6 +59,9 @@ func (base *World) Draw() {
for _, v := range base.Floor {
v.Draw()
}
+ for _, v := range base.StaticObjects {
+ v.Draw()
+ }
base.Player.Draw()
}