private ZoningTool11 CreateZoningTool()
 {
     if (Object.op_Inequality((Object)this.buildTool, (Object)null))
     {
         return(this.buildTool);
     }
     this.buildTool = (ZoningTool11)((Component)ToolsModifierControl.get_toolController()).get_gameObject().GetComponent <ZoningTool11>();
     if (Object.op_Equality((Object)this.buildTool, (Object)null))
     {
         this.buildTool = (ZoningTool11)((Component)ToolsModifierControl.get_toolController()).get_gameObject().AddComponent <ZoningTool11>();
     }
     return(this.buildTool);
 }
 private void DestroyZoningTool()
 {
     Logger.DebugData((object)Object.op_Equality((Object)ToolsModifierControl.get_toolController(), (Object)null));
     if (Object.op_Inequality((Object)ToolsModifierControl.get_toolController(), (Object)null) && (Object.op_Equality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)this.buildTool) || Object.op_Equality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)null)))
     {
         ToolsModifierControl.get_toolController().set_CurrentTool((ToolBase)this.netTool);
     }
     if (Object.op_Inequality((Object)this.buildTool, (Object)null))
     {
         Logger.Debug("Destroying tool: " + ((object)this.buildTool).GetType().Name + " it is: " + (object)this.buildTool);
         Object.Destroy((Object)this.buildTool);
         this.buildTool = (ZoningTool11)null;
     }
     else
     {
         Logger.Debug("Destroying tool: " + typeof(ZoningTool11).Name + " it is: " + (object)this.buildTool);
     }
 }
 public void SetToolEnabled(bool enabled, bool resetNetToolModeToStraight = false)
 {
     if (enabled)
     {
         ToolsModifierControl.get_toolController().set_CurrentTool((ToolBase)this.CreateZoningTool());
     }
     else
     {
         if (Object.op_Equality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)this.buildTool) || Object.op_Equality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)null))
         {
             ToolsModifierControl.get_toolController().set_CurrentTool((ToolBase)this.netTool);
         }
         this.DestroyZoningTool();
     }
     LoadingExtension.Ui.UpdateSelectedIndex(enabled);
     if (!resetNetToolModeToStraight)
     {
         return;
     }
     LoadingExtension.Ui.updateZoneButton.set_activeStateIndex(0);
 }
 public virtual void OnUpdate(float realTimeDelta, float simulationTimeDelta)
 {
     if (ThreadingExtension.loadingLevel)
     {
         return;
     }
     this.ctrlDown = this.ctrlDown ? !Input.GetKeyUp((KeyCode)306) && !Input.GetKeyUp((KeyCode)305) : Input.GetKeyDown((KeyCode)306) || Input.GetKeyDown((KeyCode)305);
     if (LoadingExtension.Ui != null && !LoadingExtension.Ui.selectedModeChangedSet)
     {
         LoadingExtension.Ui.selectedToolModeChanged += (Action <bool>)(enabled => this.SetToolEnabled(enabled));
     }
     if (Object.op_Equality((Object)this.roadsPanel, (Object)null))
     {
         this.roadsPanel = (UIPanel)UIView.Find <UIPanel>("RoadsPanel");
     }
     if (Object.op_Equality((Object)this.roadsPanel, (Object)null) || !((UIComponent)this.roadsPanel).get_isVisible())
     {
         if (!this.enabled)
         {
             return;
         }
         this.SetToolEnabled(false, true);
     }
     else
     {
         if (Object.op_Equality((Object)this.netTool, (Object)null))
         {
             foreach (ToolBase tool in ToolsModifierControl.get_toolController().get_Tools())
             {
                 NetTool netTool = tool as NetTool;
                 if (Object.op_Inequality((Object)netTool, (Object)null) && Object.op_Inequality((Object)netTool.m_prefab, (Object)null))
                 {
                     this.netTool = netTool;
                     break;
                 }
             }
             if (Object.op_Equality((Object)this.netTool, (Object)null))
             {
                 return;
             }
             this.raycastService = new ToolBase.RaycastService((ItemClass.Service)((ItemClass)((NetInfo)this.netTool.m_prefab).m_class).m_service, (ItemClass.SubService)((ItemClass)((NetInfo)this.netTool.m_prefab).m_class).m_subService, (ItemClass.Layer)((ItemClass)((NetInfo)this.netTool.m_prefab).m_class).m_layer);
         }
         if (this.enabled)
         {
             this.mouseDown      = Input.GetMouseButton(0);
             this.mouseRayValid  = !ToolsModifierControl.get_toolController().get_IsInsideUI() && Cursor.get_visible();
             this.mouseRay       = Camera.get_main().ScreenPointToRay(Input.get_mousePosition());
             this.mouseRayLength = Camera.get_main().get_farClipPlane();
             if (!Object.op_Inequality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)this.buildTool))
             {
                 return;
             }
             this.SetToolEnabled(false, true);
         }
         else
         {
             if (!Object.op_Equality((Object)ToolsModifierControl.get_toolController().get_CurrentTool(), (Object)this.buildTool))
             {
                 return;
             }
             ToolsModifierControl.get_toolController().set_CurrentTool((ToolBase)this.netTool);
         }
     }
 }