/// <summary> /// Sets the target prefab. /// </summary> /// <param name="targetPrefabInfo">Target prefab to set</param> internal override void SetTarget(PrefabInfo targetPrefabInfo) { // Base setup. base.SetTarget(targetPrefabInfo); // Title label. SetTitle(Translations.Translate("BOB_NAM")); // Replace text label. UILabel replaceLabel = AddUIComponent <UILabel>(); replaceLabel.text = Translations.Translate("BOB_PNL_REP"); replaceLabel.relativePosition = new Vector2(MidControlX, ReplaceLabelY); // Set trees/props. propCheck.isChecked = !InitialTreeCheckedState; treeCheck.isChecked = InitialTreeCheckedState; // Populate target list and select target item. TargetList(); targetList.FindTargetItem(targetPrefabInfo); // Update button states. UpdateButtonStates(); // Apply Harmony rendering patches. Patcher.PatchMapOverlays(true); }
/// <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) { // Base setup. base.Setup(parentTransform, targetPrefabInfo); // Populate target list and select target item. TargetList(); targetList.FindTargetItem(targetPrefabInfo); // Update button states. UpdateButtonStates(); // Apply Harmony rendering patches. Patcher.PatchMapOverlays(true); }
/// <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; }
/// <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>(); } } }