public T FindComponent <T>(string name, UIComponent parent = null, FindOptions options = FindOptions.None) where T : UIComponent
        {
            if (uiRoot == null)
            {
                FindUIRoot();
                if (uiRoot == null)
                {
                    ModDebug.Warning("UIRoot not found");
                    return(null);
                }
            }

            foreach (T component in UIComponent.FindObjectsOfType <T>())
            {
                bool nameMatches;
                if ((options & FindOptions.NameContains) != 0)
                {
                    nameMatches = component.name.Contains(name);
                }
                else
                {
                    nameMatches = component.name == name;
                }

                if (!nameMatches)
                {
                    continue;
                }

                Transform parentTransform;
                if (parent != null)
                {
                    parentTransform = parent.transform;
                }
                else
                {
                    parentTransform = uiRoot.transform;
                }

                Transform t = component.transform.parent;
                while (t != null && t != parentTransform)
                {
                    t = t.parent;
                }

                if (t == null)
                {
                    continue;
                }

                return(component);
            }

            ModDebug.Warning(typeof(T) + " not found: " + name);

            return(null);
        }
        void FindUIRoot()
        {
            ModDebug.Log("Finding UIRoot");
            uiRoot = null;

            foreach (UIView view in UIView.FindObjectsOfType <UIView>())
            {
                if (view.transform.parent == null && view.name == "UIView")
                {
                    ModDebug.Log("Found UIRoot");
                    uiRoot = view;
                    break;
                }
            }
        }
        //public static ToolBase.ToolErrors CreateNode(NetInfo info, NetTool.ControlPoint startPoint, NetTool.ControlPoint middlePoint, NetTool.ControlPoint endPoint, FastList<NetTool.NodePosition> nodeBuffer,
        //                                             int maxSegments, bool test, bool visualize, bool autoFix, bool needMoney, bool invert, bool switchDir, ushort relocateBuildingID,
        //                                             out ushort node, out ushort segment, out int cost, out int productionRate)

        public override void SimulationStep()
        {
            ModDebug.LogClassAndMethodName(this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name);
            base.SimulationStep();

            if (isHoveringSegment)
            {
                ushort node;
                ushort outSegment;
                int    cost;
                int    productionRate;
                // Initializes colliding arrays
                ToolErrors errors = NetTool.CreateNode(newPrefab != null ? newPrefab : segment.Info, startPoint, middlePoint, endPoint,
                                                       NetTool.m_nodePositionsSimulation, 1000, true, false, true, false, false, false, (ushort)0, out node, out outSegment, out cost, out productionRate);
            }
        }