protected override void OnButtonClicked(UIComponent comp) { object objectUserData = comp.objectUserData; BuildingInfo buildingInfo = objectUserData as BuildingInfo; NetInfo netInfo = objectUserData as NetInfo; TreeInfo treeInfo = objectUserData as TreeInfo; PropInfo propInfo = objectUserData as PropInfo; if (buildingInfo != null) { BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>(); if (buildingTool != null) { if (base.pathsOptionPanel != null) { base.pathsOptionPanel.Hide(); } buildingTool.m_prefab = buildingInfo; buildingTool.m_relocate = 0; } } if (netInfo != null) { NetToolFine netTool = ToolsModifierControl.SetTool <NetToolFine>(); if (netTool != null) { if (base.pathsOptionPanel != null) { base.pathsOptionPanel.Show(); } netTool.m_prefab = netInfo; } } if (treeInfo != null) { TreeTool treeTool = ToolsModifierControl.SetTool <TreeTool>(); if (treeTool != null) { if (base.pathsOptionPanel != null) { base.pathsOptionPanel.Hide(); } treeTool.m_prefab = treeInfo; treeTool.m_mode = TreeTool.Mode.Single; } } if (propInfo != null) { PropTool propTool = ToolsModifierControl.SetTool <PropTool>(); if (propTool != null) { if (base.pathsOptionPanel != null) { base.pathsOptionPanel.Hide(); } propTool.m_prefab = propInfo; propTool.m_mode = PropTool.Mode.Single; } } }
protected override void OnButtonClicked(UIComponent comp) { object objectUserData = comp.objectUserData; NetInfo netInfo = objectUserData as NetInfo; BuildingInfo buildingInfo = objectUserData as BuildingInfo; if ((UnityEngine.Object)netInfo != (UnityEngine.Object)null) { if ((UnityEngine.Object) this.roadsOptionPanel != (UnityEngine.Object)null) { this.roadsOptionPanel.Show(); } NetToolFine netTool = ToolsModifierControl.SetTool <NetToolFine>(); if ((UnityEngine.Object)netTool != (UnityEngine.Object)null) { netTool.m_prefab = netInfo; } } if (!((UnityEngine.Object)buildingInfo != (UnityEngine.Object)null)) { return; } if ((UnityEngine.Object) this.roadsOptionPanel != (UnityEngine.Object)null) { this.roadsOptionPanel.Hide(); } BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>(); if (!((UnityEngine.Object)buildingTool != (UnityEngine.Object)null)) { return; } buildingTool.m_prefab = buildingInfo; buildingTool.m_relocate = 0; }
void Update() { //FineRoadHeightsLoadingExtension.ReplacePanels(); NetTool netTool = ToolsModifierControl.GetCurrentTool <NetTool>(); if (netTool == null) { return; } NetToolFine netToolFine = ToolsModifierControl.SetTool <NetToolFine>(); if (netToolFine == null) { return; } netToolFine.m_mode = netTool.m_mode; netToolFine.m_placementCursor = netTool.m_placementCursor; netToolFine.m_prefab = netTool.m_prefab; netToolFine.m_snap = netTool.m_snap; netToolFine.m_upgradeCursor = netTool.m_upgradeCursor; }
public override void OnLevelLoaded(LoadMode mode) { //Turns out this is the wrong way to do it. //ReplacePanels(); //And finally with the road options panel. RoadsOptionPanel[] roadsOptionPanels = UnityEngine.Object.FindObjectsOfType <RoadsOptionPanel>(); foreach (RoadsOptionPanel roadsOptionPanel in roadsOptionPanels) { GameObject roadsOptionsPanelObject = roadsOptionPanel.gameObject; RoadsOptionFinePanel roadsOptionFinePanel = roadsOptionsPanelObject.AddComponent <RoadsOptionFinePanel>(); Object.Destroy(roadsOptionPanel); } //Find the tool controller, re-make its tool list, and force a re-make of the ToolsModifierControl tool list. ToolController toolController = UnityEngine.Object.FindObjectOfType <ToolController>(); if (toolController != null) { NetToolFine netToolFine = toolController.gameObject.AddComponent <NetToolFine>(); NetTool netTool = toolController.gameObject.GetComponent <NetTool>(); FieldInfo toolControllerField = typeof(ToolController).GetField("m_tools", BindingFlags.Instance | BindingFlags.NonPublic); if (toolControllerField != null) { toolControllerField.SetValue(toolController, toolController.GetComponents <ToolBase>()); } FieldInfo toolModifierDictionary = typeof(ToolsModifierControl).GetField("m_Tools", BindingFlags.Static | BindingFlags.NonPublic); if (toolModifierDictionary != null) { toolModifierDictionary.SetValue(null, null); } } //if(mode == LoadMode.LoadAsset || mode == LoadMode.NewAsset) // || mode == LoadMode.LoadMap || mode == LoadMode.NewMap) { GameObject panelReplacer = UnityEngine.Object.Instantiate(new GameObject()); panelReplacer.AddComponent <PanelReplacer>(); panelReplacer.name = "PanelReplacer"; } }
protected override void OnButtonClicked(UIComponent comp) { object objectUserData = comp.objectUserData; BuildingInfo buildingInfo = objectUserData as BuildingInfo; NetInfo netInfo = objectUserData as NetInfo; TransportInfo transportInfo = objectUserData as TransportInfo; if ((UnityEngine.Object)buildingInfo != (UnityEngine.Object)null) { BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>(); if ((UnityEngine.Object)buildingTool != (UnityEngine.Object)null) { if ((UnityEngine.Object) this.roadsOptionPanel != (UnityEngine.Object)null) { this.roadsOptionPanel.isVisible = false; } if ((UnityEngine.Object) this.tunnelsOptionPanel != (UnityEngine.Object)null) { this.tunnelsOptionPanel.isVisible = false; } if ((UnityEngine.Object) this.tracksOptionPanel != (UnityEngine.Object)null) { this.tracksOptionPanel.isVisible = false; } buildingTool.m_prefab = buildingInfo; buildingTool.m_relocate = 0; } } if ((UnityEngine.Object)transportInfo != (UnityEngine.Object)null) { TransportTool transportTool = ToolsModifierControl.SetTool <TransportTool>(); if ((UnityEngine.Object)transportTool != (UnityEngine.Object)null) { if ((UnityEngine.Object) this.roadsOptionPanel != (UnityEngine.Object)null) { this.roadsOptionPanel.isVisible = false; } if ((UnityEngine.Object) this.tunnelsOptionPanel != (UnityEngine.Object)null) { this.tunnelsOptionPanel.isVisible = false; } if ((UnityEngine.Object) this.tracksOptionPanel != (UnityEngine.Object)null) { this.tracksOptionPanel.isVisible = false; } transportTool.m_prefab = transportInfo; } } if (!((UnityEngine.Object)netInfo != (UnityEngine.Object)null)) { return; } NetToolFine netTool = ToolsModifierControl.SetTool <NetToolFine>(); if (!((UnityEngine.Object)netTool != (UnityEngine.Object)null)) { return; } ItemClass.SubService subService = netInfo.GetSubService(); if (subService == ItemClass.SubService.PublicTransportMetro && (UnityEngine.Object) this.tunnelsOptionPanel != (UnityEngine.Object)null) { this.tunnelsOptionPanel.isVisible = true; } else if (subService == ItemClass.SubService.PublicTransportTrain && (UnityEngine.Object) this.tracksOptionPanel != (UnityEngine.Object)null) { this.tracksOptionPanel.isVisible = true; } else if ((UnityEngine.Object) this.roadsOptionPanel != (UnityEngine.Object)null) { this.roadsOptionPanel.isVisible = true; } netTool.m_prefab = netInfo; }
private void Awake() { this.Hide(); NetTool netTool = ToolsModifierControl.GetTool <NetTool>(); if (netTool != null) { UITabstrip strip = base.Find <UITabstrip>("ToolMode"); if (strip != null) { strip.eventSelectedIndexChanged += delegate(UIComponent sender, int index) { netTool.m_mode = (NetTool.Mode)index; }; base.component.eventVisibilityChanged += delegate(UIComponent sender, bool visible) { netTool.m_mode = (NetTool.Mode)((!visible) ? 0 : strip.selectedIndex); }; } UIMultiStateButton snap = base.Find <UIMultiStateButton>("SnappingToggle"); if (snap != null) { snap.activeStateIndex = ((!netTool.m_snap) ? 0 : 1); snap.eventActiveStateIndexChanged += delegate(UIComponent sender, int index) { netTool.m_snap = (index == 1); }; base.component.eventVisibilityChanged += delegate(UIComponent sender, bool visible) { netTool.m_snap = (!visible || snap.activeStateIndex == 1); }; } } NetToolFine netToolFine = ToolsModifierControl.GetTool <NetToolFine>(); if (netToolFine != null) { UITabstrip strip = base.Find <UITabstrip>("ToolMode"); if (strip != null) { strip.eventSelectedIndexChanged += delegate(UIComponent sender, int index) { netToolFine.m_mode = (NetTool.Mode)index; }; base.component.eventVisibilityChanged += delegate(UIComponent sender, bool visible) { netToolFine.m_mode = (NetTool.Mode)((!visible) ? 0 : strip.selectedIndex); }; } UIMultiStateButton snap = base.Find <UIMultiStateButton>("SnappingToggle"); if (snap != null) { snap.activeStateIndex = ((!netToolFine.m_snap) ? 0 : 1); snap.eventActiveStateIndexChanged += delegate(UIComponent sender, int index) { netToolFine.m_snap = (index == 1); }; base.component.eventVisibilityChanged += delegate(UIComponent sender, bool visible) { netToolFine.m_snap = (!visible || snap.activeStateIndex == 1); }; } } }