private static bool TechRequirementsMet(TechItem techItem) { return(DebugHandler.InstantBuildMode || Game.Instance.SandboxModeActive || techItem == null || techItem.IsComplete()); }
private void RefreshToggle(ToggleInfo info) { if (info != null && !((UnityEngine.Object)info.toggle == (UnityEngine.Object)null)) { UserData userData = info.userData as UserData; BuildingDef def = userData.def; TechItem techItem = Db.Get().TechItems.TryGet(def.PrefabID); bool flag = DebugHandler.InstantBuildMode || techItem == null || techItem.IsComplete(); bool flag2 = flag || techItem == null || techItem.parentTech.ArePrerequisitesComplete(); KToggle toggle = info.toggle; if (toggle.gameObject.activeSelf != flag2) { toggle.gameObject.SetActive(flag2); } if (!((UnityEngine.Object)toggle.bgImage == (UnityEngine.Object)null)) { Image image = toggle.bgImage.GetComponentsInChildren <Image>()[1]; Sprite sprite = image.sprite = def.GetUISprite("ui", false); image.SetNativeSize(); image.rectTransform().sizeDelta /= 4f; ToolTip component = toggle.gameObject.GetComponent <ToolTip>(); component.ClearMultiStringTooltip(); string text = def.Name; string effect = def.Effect; if (def.HotKey != Action.NumActions) { text = GameUtil.AppendHotkeyString(text, def.HotKey); } component.AddMultiStringTooltip(text, buildingToolTipSettings.BuildButtonName); component.AddMultiStringTooltip(effect, buildingToolTipSettings.BuildButtonDescription); LocText componentInChildren = toggle.GetComponentInChildren <LocText>(); if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null) { componentInChildren.text = def.Name; } PlanScreen.RequirementsState requirementsState = BuildMenu.Instance.BuildableState(def); ImageToggleState.State state = (requirementsState == PlanScreen.RequirementsState.Complete) ? ImageToggleState.State.Inactive : ImageToggleState.State.Disabled; state = ((!((UnityEngine.Object)def == (UnityEngine.Object)selectedBuilding) || (requirementsState != PlanScreen.RequirementsState.Complete && !DebugHandler.InstantBuildMode)) ? ((requirementsState == PlanScreen.RequirementsState.Complete || DebugHandler.InstantBuildMode) ? ImageToggleState.State.Inactive : ImageToggleState.State.Disabled) : ImageToggleState.State.Active); if ((UnityEngine.Object)def == (UnityEngine.Object)selectedBuilding && state == ImageToggleState.State.Disabled) { state = ImageToggleState.State.DisabledActive; } else if (state == ImageToggleState.State.Disabled) { state = ImageToggleState.State.Disabled; } toggle.GetComponent <ImageToggleState>().SetState(state); Material material; Color color; if (requirementsState == PlanScreen.RequirementsState.Complete || DebugHandler.InstantBuildMode) { material = defaultUIMaterial; color = Color.white; } else { material = desaturatedUIMaterial; Color color2; if (flag) { color2 = new Color(1f, 1f, 1f, 0.6f); } else { Color color4 = image.color = new Color(1f, 1f, 1f, 0.15f); color2 = color4; } color = color2; } if ((UnityEngine.Object)image.material != (UnityEngine.Object)material) { image.material = material; image.color = color; } Image fgImage = toggle.gameObject.GetComponent <KToggle>().fgImage; fgImage.gameObject.SetActive(false); if (!flag) { fgImage.sprite = Overlay_NeedTech; fgImage.gameObject.SetActive(true); string newString = string.Format(UI.PRODUCTINFO_REQUIRESRESEARCHDESC, techItem.parentTech.Name); component.AddMultiStringTooltip("\n", buildingToolTipSettings.ResearchRequirement); component.AddMultiStringTooltip(newString, buildingToolTipSettings.ResearchRequirement); } else if (requirementsState != PlanScreen.RequirementsState.Complete) { fgImage.gameObject.SetActive(false); component.AddMultiStringTooltip("\n", buildingToolTipSettings.ResearchRequirement); string newString2 = UI.PRODUCTINFO_MISSINGRESOURCES_HOVER; component.AddMultiStringTooltip(newString2, buildingToolTipSettings.ResearchRequirement); foreach (Recipe.Ingredient ingredient in def.CraftRecipe.Ingredients) { string newString3 = string.Format("{0}{1}: {2}", "• ", ingredient.tag.ProperName(), GameUtil.GetFormattedMass(ingredient.amount, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); component.AddMultiStringTooltip(newString3, buildingToolTipSettings.ResearchRequirement); } component.AddMultiStringTooltip(string.Empty, buildingToolTipSettings.ResearchRequirement); } } } }
public void RefreshSelectors() { if (activeRecipe != null) { MaterialSelectors.ForEach(delegate(MaterialSelector selector) { selector.gameObject.SetActive(false); }); TechItem techItem = Db.Get().TechItems.TryGet(activeRecipe.GetBuildingDef().PrefabID); if (!DebugHandler.InstantBuildMode && !Game.Instance.SandboxModeActive && techItem != null && !techItem.IsComplete()) { ResearchRequired.SetActive(true); LocText[] componentsInChildren = ResearchRequired.GetComponentsInChildren <LocText>(); componentsInChildren[0].text = UI.PRODUCTINFO_RESEARCHREQUIRED; componentsInChildren[1].text = string.Format(UI.PRODUCTINFO_REQUIRESRESEARCHDESC, techItem.parentTech.Name); componentsInChildren[1].color = Constants.NEGATIVE_COLOR; priorityScreen.gameObject.SetActive(false); } else { ResearchRequired.SetActive(false); for (int i = 0; i < activeRecipe.Ingredients.Count; i++) { MaterialSelectors[i].gameObject.SetActive(true); MaterialSelectors[i].ConfigureScreen(activeRecipe.Ingredients[i], activeRecipe); } priorityScreen.gameObject.SetActive(true); priorityScreen.gameObject.transform.SetAsLastSibling(); } } }