/// <summary> /// Sets the target prefab. /// </summary> /// <param name="targetPrefabInfo">Target prefab to set</param> internal override void SetTarget(PrefabInfo targetPrefabInfo) { // Don't do anything if invalid target, or target hasn't changed. if (!(targetPrefabInfo is BuildingInfo) || selectedPrefab == targetPrefabInfo) { return; } // Base setup. base.SetTarget(targetPrefabInfo); // Set target reference. currentBuilding = SelectedBuilding; // Does this building have sub-buildings? if (currentBuilding.m_subBuildings != null && currentBuilding.m_subBuildings.Length > 0) { // Yes - create lists of sub-buildings (names and infos). int numSubs = currentBuilding.m_subBuildings.Length; int numChoices = numSubs + 1; SubBuildingNames = new string[numChoices]; subBuildings = new BuildingInfo[numChoices]; SubBuildingNames[0] = PrefabLists.GetDisplayName(currentBuilding); subBuildings[0] = currentBuilding; object[] subBuildingIndexes = new object[numChoices]; subBuildingIndexes[0] = 0; for (int i = 0; i < numSubs; ++i) { SubBuildingNames[i + 1] = PrefabLists.GetDisplayName(currentBuilding.m_subBuildings[i].m_buildingInfo); subBuildings[i + 1] = currentBuilding.m_subBuildings[i].m_buildingInfo; subBuildingIndexes[i + 1] = i + 1; } // Add sub-building menu, if it doesn't already exist. if (subBuildingPanel == null) { subBuildingPanel = this.AddUIComponent <UIPanel>(); // Basic behaviour. subBuildingPanel.autoLayout = false; subBuildingPanel.canFocus = true; subBuildingPanel.isInteractive = true; // Appearance. subBuildingPanel.backgroundSprite = "MenuPanel2"; subBuildingPanel.opacity = PanelOpacity; // Size and position. subBuildingPanel.size = new Vector2(200f, PanelHeight - TitleHeight); subBuildingPanel.relativePosition = new Vector2(-205f, TitleHeight); // Heading. UILabel subTitleLabel = UIControls.AddLabel(subBuildingPanel, 5f, 5f, Translations.Translate("BOB_PNL_SUB"), 190f); subTitleLabel.textAlignment = UIHorizontalAlignment.Center; subTitleLabel.relativePosition = new Vector2(5f, (TitleHeight - subTitleLabel.height) / 2f); // List panel. UIPanel subBuildingListPanel = subBuildingPanel.AddUIComponent <UIPanel>(); subBuildingListPanel.relativePosition = new Vector2(Margin, TitleHeight); subBuildingListPanel.width = subBuildingPanel.width - (Margin * 2f); subBuildingListPanel.height = subBuildingPanel.height - TitleHeight - (Margin * 2f); subBuildingList = UIFastList.Create <UISubBuildingRow>(subBuildingListPanel); ListSetup(subBuildingList); // Create return fastlist from our filtered list. subBuildingList.rowsData = new FastList <object> { m_buffer = subBuildingIndexes, m_size = subBuildingIndexes.Length }; } else { // If the sub-building panel has already been created. just make sure it's visible. subBuildingPanel.Show(); } } else { // Otherwise, hide the sub-building panel (if it exists). subBuildingPanel?.Hide(); } // Populate target list and select target item. TargetList(); // Apply Harmony rendering patches. RenderOverlays.CurrentBuilding = selectedPrefab as BuildingInfo; Patcher.PatchBuildingOverlays(true); }