/// <summary> /// Called by game when tool is disabled. /// Used to close the BOB info panel. /// </summary> protected override void OnDisable() { base.OnDisable(); // Is a BOB info panel already open? if (InfoPanelManager.Panel != null) { // Yes - close it. InfoPanelManager.Close(); } }
/// <summary> /// Tool GUI event processing. /// Called by game every GUI update. /// </summary> /// <param name="e">Event</param> protected override void OnToolGUI(Event e) { // Check for escape key. if (e.type == EventType.keyDown && e.keyCode == KeyCode.Escape) { // Escape key pressed - disable tool. e.Use(); ToolsModifierControl.SetTool <DefaultTool>(); // Close window, if open. InfoPanelManager.Close(); } // Don't do anything if mouse is inside UI or if there are any errors other than failed raycast. if (m_toolController.IsInsideUI || (m_selectErrors != ToolErrors.None && m_selectErrors != ToolErrors.RaycastFailed)) { return; } // Try to get a hovered building instance. ushort building = m_hoverInstance.Building; if (building != 0) { // Check for mousedown events with button zero. if (e.type == EventType.MouseDown && e.button == 0) { // Got one; use the event. UIInput.MouseUsed(); // Create the info panel with the hovered building prefab. InfoPanelManager.SetTarget(Singleton <BuildingManager> .instance.m_buildings.m_buffer[building].Info); } } else { ushort segment = m_hoverInstance.NetSegment; // Try to get a hovered network instance. if (segment != 0) { // Check for mousedown events with button zero. if (e.type == EventType.MouseDown && e.button == 0) { // Got one; use the event. UIInput.MouseUsed(); // Create the info panel with the hovered network prefab. InfoPanelManager.SetTarget(Singleton <NetManager> .instance.m_segments.m_buffer[segment].Info); } } else { uint tree = m_hoverInstance.Tree; // Try to get a hovered tree instance. if (tree != 0) { // Check for mousedown events with button zero. if (e.type == EventType.MouseDown && e.button == 0) { // Got one; use the event. UIInput.MouseUsed(); // Create the info panel with the hovered network prefab. InfoPanelManager.SetTarget(Singleton <TreeManager> .instance.m_trees.m_buffer[tree].Info); } } else { uint prop = PropAPI.GetPropID(m_hoverInstance); // Try to get a hovered prop instance. if (prop != 0) { // Check for mousedown events with button zero. if (e.type == EventType.MouseDown && e.button == 0) { // Got one; use the event. UIInput.MouseUsed(); // Create the info panel with the hovered network prefab. InfoPanelManager.SetTarget(PropAPI.Wrapper.GetInfo(prop)); } } } } } }