Example #1
0
        /// <summary>
        /// Sets the target network.
        /// </summary>
        /// <param name="targetPrefabInfo">Target network to set</param>
        internal override void SetTarget(PrefabInfo targetPrefabInfo)
        {
            // Don't do anything if target hasn't changed.
            if (SelectedNet == targetPrefabInfo)
            {
                return;
            }

            // Base setup.
            base.SetTarget(targetPrefabInfo);

            // Populate target list and select target item.
            TargetList();

            // Apply Harmony rendering patches.
            RenderOverlays.CurrentNet = SelectedNet;
            Patcher.PatchNetworkOverlays(true);
        }
Example #2
0
        /// <summary>
        /// Performs initial setup
        /// </summary>
        /// <param name="parentTransform">Parent transform</param>
        /// <param name="targetPrefabInfo">Currently selected target prefab</param>
        internal override void Setup(Transform parentTransform, PrefabInfo targetPrefabInfo)
        {
            // Set target reference.
            currentNet = targetPrefabInfo as NetInfo;

            // Base setup.
            base.Setup(parentTransform, targetPrefabInfo);

            // Add pack button.
            UIButton packButton = UIControls.EvenSmallerButton(this, RightX - 200f, TitleHeight + (Margin / 2f), Translations.Translate("BOB_PNL_PKB"));

            packButton.eventClicked += (component, clickEvent) => PackPanelManager.Create();

            // Populate target list and select target item.
            TargetList();

            // Apply Harmony rendering patches.
            Patcher.PatchNetworkOverlays(true);
        }
Example #3
0
        /// <summary>
        /// Closes the panel by destroying the object (removing any ongoing UI overhead).
        /// </summary>
        internal static void Close()
        {
            // Stop highlighting.
            panel.CurrentTargetItem        = null;
            RenderOverlays.CurrentBuilding = null;

            // Revert overlay patches.
            Patcher.PatchBuildingOverlays(false);
            Patcher.PatchNetworkOverlays(false);
            Patcher.PatchMapOverlays(false);

            // Store previous position.
            lastX = Panel.relativePosition.x;
            lastY = Panel.relativePosition.y;

            // Destroy game objects.
            GameObject.Destroy(Panel);
            GameObject.Destroy(uiGameObject);

            // Let the garbage collector do its work (and also let us know that we've closed the object).
            panel        = null;
            uiGameObject = null;
        }
Example #4
0
        /// <summary>
        /// Closes the panel by destroying the object (removing any ongoing UI overhead).
        /// </summary>
        /// <param name="resetTool">True to reset to default tool; false to leave current tool untouched (default true)</param>
        internal static void Close(bool resetTool = true)
        {
            // Check for null, just in case - this is also called by pressing Esc when BOB tool is active.
            if (panel != null)
            {
                // Perform any panel actions on close.
                panel.Close();

                // Stop highlighting.
                panel.CurrentTargetItem        = null;
                RenderOverlays.CurrentBuilding = null;

                // Revert overlay patches.
                Patcher.PatchBuildingOverlays(false);
                Patcher.PatchNetworkOverlays(false);
                Patcher.PatchMapOverlays(false);

                // Store previous position.
                lastX = Panel.relativePosition.x;
                lastY = Panel.relativePosition.y;

                // Destroy game objects.
                GameObject.Destroy(Panel);
                GameObject.Destroy(uiGameObject);

                // Let the garbage collector do its work (and also let us know that we've closed the object).
                panel        = null;
                uiGameObject = null;

                // Restore default tool if needed.
                if (resetTool)
                {
                    ToolsModifierControl.SetTool <DefaultTool>();
                }
            }
        }