// public bool[] CreateIObjsWithSwitchesState(
    //     bool[] switchesStates,
    //     bool isActivated,
    //     bool isForceSortingLayer,
    //     bool isSortingLayerAxisZ = true,
    //     int offset = 0
    // )
    // {
    //     if (isActivated)
    //     {
    //         game.CreateInteractableObjects(
    //             switchesStates,
    //             isForceSortingLayer,
    //             isSortingLayerAxisZ,
    //             offset
    //         );
    //     }
    //     else
    //     {
    //         game.CreateInteractableObjects(
    //             null,
    //             isForceSortingLayer,
    //             isSortingLayerAxisZ,
    //             offset
    //         );

    //         switchesStates = new bool[game.GetSwitchesCount()];
    //         SetInitialSwitchesState(switchesStates);
    //     }

    //     return switchesStates;
    // }

    public bool[] SetupSwitchesState(
        Transform lightSwitchesParent,
        bool[] switchesStates,
        bool isInitialize
        )
    {
        /// Initialization of switches state is done in InteractableObjectCreator
        Script_Utils.PrintArray(switchesStates, "setting up with switchesState");

        switchesStates = game.SetupSwitches(
            lightSwitchesParent,
            switchesStates,
            isInitialize
            );

        return(switchesStates);
    }
    /// <summary>
    /// Handles ALL switches types here to have a combined switchesState
    /// This currently gives a switches
    /// </summary>
    public bool[] SetupSwitches(
        Transform allSwitchesParent,
        List <Script_InteractableObject> interactableObjects,
        List <Script_Switch> switches,
        bool[] switchesState,
        bool isInitialize
        )
    {
        /// Initializing level for the first time with no loaded state data
        bool isEmptySwitchesState = false;

        Script_Switch[] switchesChildren = allSwitchesParent.GetComponentsInChildren <Script_Switch>(true);

        if (switchesState == null || switchesState.Length == 0)
        {
            switchesState        = new bool[switchesChildren.Length];
            isEmptySwitchesState = true;
        }

        for (int i = 0; i < switchesChildren.Length; i++)
        {
            Script_LightSwitch lightSwitch = null;
            Script_Switch      switchObj   = null;

            Script_Switch child = switchesChildren[i];
            if (child is Script_LightSwitch)
            {
                lightSwitch = (Script_LightSwitch)child;
                interactableObjects.Add(lightSwitch);
                switches.Add(lightSwitch);
            }
            else if (child is Script_Switch)
            {
                switchObj = (Script_Switch)child;
                interactableObjects.Add(switchObj);
                switches.Add(switchObj);
            }

            if (isInitialize)
            {
                child.Id       = interactableObjects.Count - 1;
                child.switchId = switches.Count - 1;

                /// Set the switch with the state in switchesState
                /// if no loaded switchesState is provided, then default to the setting
                /// of the light itself
                if (child is Script_LightSwitch)
                {
                    if (isEmptySwitchesState)
                    {
                        lightSwitch.SetupSceneLights(child.isOn);
                        switchesState[i] = child.isOn;
                    }
                    else
                    {
                        lightSwitch.SetupSceneLights(switchesState[i]);
                    }
                }
                else if (child is Script_Switch)
                {
                    if (isEmptySwitchesState)
                    {
                        switchObj.SetupSwitch(child.isOn, null, null);
                        switchesState[i] = child.isOn;
                    }
                    else
                    {
                        switchObj.SetupSwitch(switchesState[i], null, null);
                    }
                }

                child.Setup(false, true, 0);
            }
        }

        if (Debug.isDebugBuild && Const_Dev.IsDevMode)
        {
            if (isEmptySwitchesState)
            {
                Script_Utils.PrintArray(switchesState, "no switches data; init switches state based on switches...");
            }
            else
            {
                Script_Utils.PrintArray(switchesState, "loaded switchesState");
            }
        }

        return(switchesState);
    }