I am currently trying to refactor my game's script file layouts and classes, here is what I'm trying to do:

1.Add a " master" node to initialize all other singleton nodes in scene's root node, the master node stores player units in multidimensional arrays.
2.Add a few singleton class to handle most fundamental functions like input/ resource data loading/camera management etc
3.used a simple ecs plugin to integrate different scripts as "system" component child in tscn scene object.

Though I found some problems and drawbacks with this script layout:
1.The master script become enormously heavy and relatively hard to maintain, due to large number of variable or class initialization functions and object arrays.
2.Some function involving camera and IO need to be attached to objects, rendering them impossible to work independently, thus cannot be loaded via master script node directly.
3.The lacking of a namespace feature makes it hard to avoid enumeration name conflicts or variable shadowing when I am intergrating too many script as component child inside a tscn.

So what is a the proper way of organizing scripts classes in GDS?
It seems to me the object oriented programming design patterns don't fit GDS's python–like language nature well.

Thanks in advance.

    14 days later

    MagickPanda
    I wouldn't know about any "proper" way. Without seeing exactly what you are up to its hard to give adequate opinion.
    In my project I have an input handling script. But it isn't a singleton. It is instantiated in every scene wherein user input is needed.
    Maybe the approach of having singletons handle all aspects is the mistake in your refactoring.
    Here is my input handler (albeit not 100% complete).

    extends Node2D
    class_name InputHandler
    
    signal mouse_button_left_released(event:Variant)
    signal mouse_button_left_double_click(event:Variant)
    signal escape_pressed
    signal enter_pressed
    signal left_pressed
    signal tab_pressed
    signal right_pressed
    signal up_pressed
    signal down_pressed 
    signal backspace_pressed
    signal space_pressed
    signal key_pressed(key:Variant)
    
    func _ready(): 
    	handle_inputs_stop()
    
    func handle_inputs_start()->void: 
    	set_process_input(true)
    	
    func handle_inputs_stop()->void: 
    	set_process_input(false)
    
    func _validate_key_press(event)->Variant:
    	if event is InputEventKey:
    		if event.is_pressed() == true: 
    			if event.shift_pressed: 
    				if event.is_echo() == false:
    					return [event.keycode, true]
    			if event.is_echo() == false: 
    				return [event.keycode, false]
    	return [0, false]
    
    func _handle_mouse_button(event): 
    	if event.is_double_click():
    		emit_signal("mouse_button_left_double_click", event)
    	else: 		
    		if event.is_action_released("MouseButtonLeft"):
    			emit_signal("mouse_button_left_released", event)
    
    func _input(event):
    	if event is InputEventMouseButton:
    		_handle_mouse_button(event)
    		return
    	var key = _validate_key_press(event)
    	if key[0] != 0: 
    		match key[0]:
    			KEY_ESCAPE: 
    				emit_signal("escape_pressed")
    			KEY_LEFT:
    				emit_signal("left_pressed")
    			KEY_RIGHT: 
    				emit_signal("right_pressed")
    			KEY_UP: 
    				emit_signal("up_pressed")
    			KEY_DOWN: 			
    				emit_signal("down_pressed")
    			KEY_TAB:
    				emit_signal("tab_pressed")
    			KEY_BACKSPACE: 
    				emit_signal("backspace_pressed")
    			KEY_SPACE: 
    				emit_signal("space_pressed")
    			KEY_ENTER, KEY_KP_ENTER:
    				emit_signal("enter_pressed")
    			_:
    				var c := char(event.unicode)
    				var ascii:int = c.unicode_at(0)
    				emit_signal("key_pressed", ascii)
    

    In any scene that needs user input I just plop it in as inherited child scene and:

    @onready var _ih = $InputHandler  

    and respond to the signals I need for that scenes UI.

    Thanks for the detailed reply.
    My major concern is plugging godot high-speed-level multiplayer into my game would break alot of things if I don't design the hierarchical structure of different script carefully.

    I looked at official and 3rd-party multiplayer demo, their layout of nodes is like:
    root
    -gamestate
    -input
    -world
    --world objects such as camera

    But I can't seem to find proper way to make my game scripts organized in a way(Preloaded singletons/globals vs initialization in each game instance) that is multiplayer ready.