#how on earth is this a cyclical reference?

4 messages · Page 1 of 1 (latest)

outer willow
#

I'm attempting to write a service-based game framework so i can stop writing the same 3 systems over and over again for each project, I've tried a few different architectures and settled on this one which i think both works perfectly and looks great too.

But how the hell am i getting this circular reference error here? (attached)

[Main.gd]

extends Node

func _ready() -> void:
    Game.register_service("SceneManager", SceneManager.new());

[Game.gd (abridged)]

class_name Game extends RefCounted

static var _services:Dictionary[String, Service];

static func register_service(name:String, service:Service) -> void:
    if(_services.has(name)):
        __log_service_warning("duplicate service registration (%s), overriding" % name);
        unregister_service(name);
    _services[name] = service;
    __log_service_info("registered service %s" % name);

[Service.gd]

class_name Service extends RefCounted

func _service_init() -> void: pass;
func _service_exit() -> void: pass;

[SceneManager.gd]

class_name SceneManager extends Service
south shuttle
#

Unless there's some code you didn't show then it's just godot having caching issues. But regardless this is a redundant system

#

A redundant system that is also less robust