private string OnPriorityButtonTooltip(PriorityButton b) { b.tooltip.ClearMultiStringTooltip(); if ((UnityEngine.Object)identity != (UnityEngine.Object)null) { Attributes attributes = identity.GetAttributes(); if (attributes != null) { if (!consumer.IsPermittedByTraits(b.choreGroup)) { string newString = string.Format(UI.TOOLTIPS.JOBSSCREEN_CANNOTPERFORMTASK, consumer.GetComponent <MinionIdentity>().GetProperName()); b.tooltip.AddMultiStringTooltip(newString, TooltipTextStyle_AbilityNegativeModifier); return(string.Empty); } b.tooltip.AddMultiStringTooltip(UI.TOOLTIPS.JOBSSCREEN_RELEVANT_ATTRIBUTES, TooltipTextStyle_Ability); Klei.AI.Attribute attribute = b.choreGroup.attribute; AttributeInstance attributeInstance = attributes.Get(attribute); float totalValue = attributeInstance.GetTotalValue(); TextStyleSetting styleSetting = TooltipTextStyle_Ability; if (totalValue > 0f) { styleSetting = TooltipTextStyle_AbilityPositiveModifier; } else if (totalValue < 0f) { styleSetting = TooltipTextStyle_AbilityNegativeModifier; } b.tooltip.AddMultiStringTooltip(attribute.Name + " " + attributeInstance.GetTotalValue(), styleSetting); } } return(string.Empty); }
public StatesInstance(RecoverBreathChore master, GameObject recoverer) : base(master) { base.sm.recoverer.Set(recoverer, base.smi); Klei.AI.Attribute deltaAttribute = Db.Get().Amounts.Breath.deltaAttribute; float value = 3f; recoveringbreath = new AttributeModifier(deltaAttribute.Id, value, DUPLICANTS.MODIFIERS.RECOVERINGBREATH.NAME, false, false, true); }
private void SetupDependentAttribute(Klei.AI.Attribute targetAttribute, AttributeConverter attributeConverter) { Klei.AI.Attribute attribute = attributeConverter.attribute; AttributeInstance attributeInstance = attribute.Lookup(this); AttributeModifier target_modifier = new AttributeModifier(targetAttribute.Id, attributeConverter.Lookup(this).Evaluate(), attribute.Name, false, false, false); this.GetAttributes().Add(target_modifier); AttributeInstance attributeInstance2 = attributeInstance; attributeInstance2.OnDirty = (System.Action)Delegate.Combine(attributeInstance2.OnDirty, (System.Action) delegate { target_modifier.SetValue(attributeConverter.Lookup(this).Evaluate()); }); }
private void AddAttributeLine(Klei.AI.Attribute attribute, Func <AttributeInstance, string> tooltip_func = null) { GameObject gameObject = Util.KInstantiateUI(LineItemPrefab, base.gameObject, false); gameObject.GetComponentInChildren <Image>().sprite = Assets.GetSprite(attribute.uiSprite); gameObject.GetComponent <ToolTip>().refreshWhileHovering = true; gameObject.SetActive(true); AttributeLine item = default(AttributeLine); item.attribute = attribute; item.go = gameObject; item.locText = gameObject.GetComponentInChildren <LocText>(); item.toolTip = gameObject.GetComponentInChildren <ToolTip>(); gameObject.GetComponentInChildren <ValueTrendImageToggle>().gameObject.SetActive(false); item.toolTipFunc = ((tooltip_func == null) ? new Func <AttributeInstance, string>(attribute.GetTooltip) : tooltip_func); attributesLines.Add(item); }
public static void Postfix(Database.Attributes __instance) { Klei.AI.Attribute attribute = new Klei.AI.Attribute(HeartAttackMonitor.ATTRIBUTE_ID, false, Klei.AI.Attribute.Display.Details, false, 0f, null, null); attribute.SetFormatter(new ToPercentAttributeFormatter(1, GameUtil.TimeSlice.None)); __instance.Add(attribute); }
public static Tuple <Sprite, Color> GetUISprite(object item, string animName = "ui", bool centered = false) { if (item is Substance) { return(GetUISprite(ElementLoader.FindElementByHash((item as Substance).elementID), animName, centered)); } if (item is Element) { if ((item as Element).IsSolid) { return(new Tuple <Sprite, Color>(GetUISpriteFromMultiObjectAnim((item as Element).substance.anim, animName, centered, string.Empty), Color.white)); } if ((item as Element).IsLiquid) { return(new Tuple <Sprite, Color>(Assets.GetSprite("element_liquid"), (item as Element).substance.uiColour)); } if ((item as Element).IsGas) { return(new Tuple <Sprite, Color>(Assets.GetSprite("element_gas"), (item as Element).substance.uiColour)); } return(new Tuple <Sprite, Color>(null, Color.clear)); } if (item is GameObject) { GameObject gameObject = item as GameObject; if (ElementLoader.GetElement(gameObject.PrefabID()) != null) { return(GetUISprite(ElementLoader.GetElement(gameObject.PrefabID()), animName, centered)); } CreatureBrain component = gameObject.GetComponent <CreatureBrain>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { animName = component.symbolPrefix + "ui"; } SpaceArtifact component2 = gameObject.GetComponent <SpaceArtifact>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { animName = component2.GetUIAnim(); } if (gameObject.HasTag(GameTags.Egg)) { IncubationMonitor.Def def = gameObject.GetDef <IncubationMonitor.Def>(); if (def != null) { GameObject prefab = Assets.GetPrefab(def.spawnedCreature); if ((bool)prefab) { component = prefab.GetComponent <CreatureBrain>(); if ((bool)component && !string.IsNullOrEmpty(component.symbolPrefix)) { animName = component.symbolPrefix + animName; } } } } KBatchedAnimController component3 = gameObject.GetComponent <KBatchedAnimController>(); if ((bool)component3) { Sprite uISpriteFromMultiObjectAnim = GetUISpriteFromMultiObjectAnim(component3.AnimFiles[0], animName, centered, string.Empty); return(new Tuple <Sprite, Color>(uISpriteFromMultiObjectAnim, (!((UnityEngine.Object)uISpriteFromMultiObjectAnim != (UnityEngine.Object)null)) ? Color.clear : Color.white)); } if ((UnityEngine.Object)gameObject.GetComponent <Building>() != (UnityEngine.Object)null) { Sprite uISprite = gameObject.GetComponent <Building>().Def.GetUISprite(animName, centered); return(new Tuple <Sprite, Color>(uISprite, (!((UnityEngine.Object)uISprite != (UnityEngine.Object)null)) ? Color.clear : Color.white)); } Debug.LogWarningFormat("Can't get sprite for type {0} (no KBatchedAnimController)", item.ToString()); return(null); } if (item is string) { if (Db.Get().Amounts.Exists(item as string)) { Amount amount = Db.Get().Amounts.Get(item as string); return(new Tuple <Sprite, Color>(Assets.GetSprite(amount.uiSprite), Color.white)); } if (Db.Get().Attributes.Exists(item as string)) { Klei.AI.Attribute attribute = Db.Get().Attributes.Get(item as string); return(new Tuple <Sprite, Color>(Assets.GetSprite(attribute.uiSprite), Color.white)); } return(GetUISprite((item as string).ToTag(), animName, centered)); } if (item is Tag) { if (ElementLoader.GetElement((Tag)item) != null) { return(GetUISprite(ElementLoader.GetElement((Tag)item), animName, centered)); } if ((UnityEngine.Object)Assets.GetPrefab((Tag)item) != (UnityEngine.Object)null) { return(GetUISprite(Assets.GetPrefab((Tag)item), animName, centered)); } if ((UnityEngine.Object)Assets.GetSprite(((Tag)item).Name) != (UnityEngine.Object)null) { return(new Tuple <Sprite, Color>(Assets.GetSprite(((Tag)item).Name), Color.white)); } } DebugUtil.DevAssertArgs(false, "Can't get sprite for type ", item.ToString()); return(null); }
protected override void OnPrefabInit() { base.OnPrefabInit(); germResistAttr = Db.Get().Attributes.GermResistance; }
private void SetDescription(BuildingDef def) { if (!((UnityEngine.Object)def == (UnityEngine.Object)null) && !((UnityEngine.Object)productFlavourText == (UnityEngine.Object)null)) { string text = def.Desc; Dictionary <Klei.AI.Attribute, float> dictionary = new Dictionary <Klei.AI.Attribute, float>(); Dictionary <Klei.AI.Attribute, float> dictionary2 = new Dictionary <Klei.AI.Attribute, float>(); foreach (Klei.AI.Attribute attribute in def.attributes) { if (!dictionary.ContainsKey(attribute)) { dictionary[attribute] = 0f; } } foreach (AttributeModifier attributeModifier in def.attributeModifiers) { float value = 0f; Klei.AI.Attribute key = Db.Get().BuildingAttributes.Get(attributeModifier.AttributeId); dictionary.TryGetValue(key, out value); value = (dictionary[key] = value + attributeModifier.Value); } if (materialSelectionPanel.CurrentSelectedElement != (Tag)null) { Element element = ElementLoader.GetElement(materialSelectionPanel.CurrentSelectedElement); if (element != null) { foreach (AttributeModifier attributeModifier2 in element.attributeModifiers) { float value2 = 0f; Klei.AI.Attribute key2 = Db.Get().BuildingAttributes.Get(attributeModifier2.AttributeId); dictionary2.TryGetValue(key2, out value2); value2 = (dictionary2[key2] = value2 + attributeModifier2.Value); } } else { GameObject gameObject = Assets.TryGetPrefab(materialSelectionPanel.CurrentSelectedElement); PrefabAttributeModifiers component = gameObject.GetComponent <PrefabAttributeModifiers>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { foreach (AttributeModifier descriptor in component.descriptors) { float value3 = 0f; Klei.AI.Attribute key3 = Db.Get().BuildingAttributes.Get(descriptor.AttributeId); dictionary2.TryGetValue(key3, out value3); value3 = (dictionary2[key3] = value3 + descriptor.Value); } } } } if (dictionary.Count > 0) { text += "\n\n"; foreach (KeyValuePair <Klei.AI.Attribute, float> item in dictionary) { float value4 = 0f; dictionary.TryGetValue(item.Key, out value4); float value5 = 0f; string text2 = string.Empty; if (dictionary2.TryGetValue(item.Key, out value5)) { value5 = Mathf.Abs(value4 * value5); text2 = "(+" + value5 + ")"; } string text3 = text; text = text3 + "\n" + item.Key.Name + ": " + (value4 + value5) + text2; } } productFlavourText.text = text; } }
private void SetInfoText() { traitEntries.ForEach(delegate(GameObject tl) { UnityEngine.Object.Destroy(tl.gameObject); }); traitEntries.Clear(); characterNameTitle.SetTitle(stats.Name); for (int i = 1; i < stats.Traits.Count; i++) { Trait trait = stats.Traits[i]; LocText locText = (!trait.PositiveTrait) ? badTrait : goodTrait; LocText locText2 = Util.KInstantiateUI <LocText>(locText.gameObject, locText.transform.parent.gameObject, false); locText2.gameObject.SetActive(true); locText2.text = stats.Traits[i].Name; locText2.color = ((!trait.PositiveTrait) ? Constants.NEGATIVE_COLOR : Constants.POSITIVE_COLOR); locText2.GetComponent <ToolTip>().SetSimpleTooltip(trait.description); for (int num = 0; num < trait.SelfModifiers.Count; num++) { GameObject gameObject = Util.KInstantiateUI(attributeLabelTrait.gameObject, locText.transform.parent.gameObject, false); gameObject.SetActive(true); LocText componentInChildren = gameObject.GetComponentInChildren <LocText>(); string format = (!(trait.SelfModifiers[num].Value > 0f)) ? UI.CHARACTERCONTAINER_ATTRIBUTEMODIFIER_DECREASED : UI.CHARACTERCONTAINER_ATTRIBUTEMODIFIER_INCREASED; componentInChildren.text = string.Format(format, Strings.Get("STRINGS.DUPLICANTS.ATTRIBUTES." + trait.SelfModifiers[num].AttributeId.ToUpper() + ".NAME")); if (!(trait.SelfModifiers[num].AttributeId == "GermResistance")) { goto IL_01bd; } goto IL_01bd; IL_01bd: Klei.AI.Attribute attribute = Db.Get().Attributes.Get(trait.SelfModifiers[num].AttributeId); string text = attribute.Description; string text2 = text; text = text2 + "\n\n" + Strings.Get("STRINGS.DUPLICANTS.ATTRIBUTES." + trait.SelfModifiers[num].AttributeId.ToUpper() + ".NAME") + ": " + trait.SelfModifiers[num].GetFormattedString(null); List <AttributeConverter> convertersForAttribute = Db.Get().AttributeConverters.GetConvertersForAttribute(attribute); for (int j = 0; j < convertersForAttribute.Count; j++) { string text3 = convertersForAttribute[j].DescriptionFromAttribute(convertersForAttribute[j].multiplier * trait.SelfModifiers[num].Value, null); if (text3 != string.Empty) { text = text + "\n • " + text3; } } componentInChildren.GetComponent <ToolTip>().SetSimpleTooltip(text); traitEntries.Add(gameObject); } if (trait.disabledChoreGroups != null) { GameObject gameObject2 = Util.KInstantiateUI(attributeLabelTrait.gameObject, locText.transform.parent.gameObject, false); gameObject2.SetActive(true); LocText componentInChildren2 = gameObject2.GetComponentInChildren <LocText>(); componentInChildren2.text = trait.GetDisabledChoresString(false); string text4 = string.Empty; string text5 = string.Empty; for (int k = 0; k < trait.disabledChoreGroups.Length; k++) { if (k > 0) { text4 += ", "; text5 += "\n"; } text4 += trait.disabledChoreGroups[k].Name; text5 += trait.disabledChoreGroups[k].description; } componentInChildren2.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(DUPLICANTS.TRAITS.CANNOT_DO_TASK_TOOLTIP, text4, text5)); traitEntries.Add(gameObject2); } if (trait.ignoredEffects != null && trait.ignoredEffects.Length > 0) { GameObject gameObject3 = Util.KInstantiateUI(attributeLabelTrait.gameObject, locText.transform.parent.gameObject, false); gameObject3.SetActive(true); LocText componentInChildren3 = gameObject3.GetComponentInChildren <LocText>(); componentInChildren3.text = trait.GetIgnoredEffectsString(false); string text6 = string.Empty; string text7 = string.Empty; for (int l = 0; l < trait.ignoredEffects.Length; l++) { if (l > 0) { text6 += ", "; text7 += "\n"; } text6 += Strings.Get("STRINGS.DUPLICANTS.MODIFIERS." + trait.ignoredEffects[l].ToUpper() + ".NAME"); text7 += Strings.Get("STRINGS.DUPLICANTS.MODIFIERS." + trait.ignoredEffects[l].ToUpper() + ".CAUSE"); } componentInChildren3.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(DUPLICANTS.TRAITS.IGNORED_EFFECTS_TOOLTIP, text6, text7)); traitEntries.Add(gameObject3); } if (Strings.TryGet("STRINGS.DUPLICANTS.TRAITS." + trait.Id.ToUpper() + ".SHORT_DESC", out StringEntry result)) { GameObject gameObject4 = Util.KInstantiateUI(attributeLabelTrait.gameObject, locText.transform.parent.gameObject, false); gameObject4.SetActive(true); LocText componentInChildren4 = gameObject4.GetComponentInChildren <LocText>(); componentInChildren4.text = result.String; componentInChildren4.GetComponent <ToolTip>().SetSimpleTooltip(Strings.Get("STRINGS.DUPLICANTS.TRAITS." + trait.Id.ToUpper() + ".SHORT_DESC_TOOLTIP")); traitEntries.Add(gameObject4); } traitEntries.Add(locText2.gameObject); } aptitudeEntries.ForEach(delegate(GameObject al) { UnityEngine.Object.Destroy(al.gameObject); }); aptitudeEntries.Clear(); expectationLabels.ForEach(delegate(LocText el) { UnityEngine.Object.Destroy(el.gameObject); }); expectationLabels.Clear(); foreach (KeyValuePair <SkillGroup, float> skillAptitude in stats.skillAptitudes) { if (skillAptitude.Value != 0f) { SkillGroup skillGroup = Db.Get().SkillGroups.Get(skillAptitude.Key.IdHash); if (skillGroup == null) { Debug.LogWarningFormat("Role group not found for aptitude: {0}", skillAptitude.Key); } else { GameObject gameObject5 = Util.KInstantiateUI(aptitudeEntry.gameObject, aptitudeEntry.transform.parent.gameObject, false); LocText locText3 = Util.KInstantiateUI <LocText>(aptitudeLabel.gameObject, gameObject5, false); locText3.gameObject.SetActive(true); locText3.text = skillGroup.Name; string empty = string.Empty; if (skillGroup.choreGroupID != string.Empty) { ChoreGroup choreGroup = Db.Get().ChoreGroups.Get(skillGroup.choreGroupID); empty = string.Format(DUPLICANTS.ROLES.GROUPS.APTITUDE_DESCRIPTION_CHOREGROUP, skillGroup.Name, DUPLICANTSTATS.APTITUDE_BONUS, choreGroup.description); } else { empty = string.Format(DUPLICANTS.ROLES.GROUPS.APTITUDE_DESCRIPTION, skillGroup.Name, DUPLICANTSTATS.APTITUDE_BONUS); } locText3.GetComponent <ToolTip>().SetSimpleTooltip(empty); float num2 = (float)DUPLICANTSTATS.APTITUDE_ATTRIBUTE_BONUSES[stats.skillAptitudes.Count - 1]; LocText locText4 = Util.KInstantiateUI <LocText>(attributeLabelAptitude.gameObject, gameObject5, false); locText4.gameObject.SetActive(true); locText4.text = "+" + num2 + " " + skillAptitude.Key.relevantAttributes[0].Name; string text8 = skillAptitude.Key.relevantAttributes[0].Description; string text2 = text8; text8 = text2 + "\n\n" + skillAptitude.Key.relevantAttributes[0].Name + ": +" + DUPLICANTSTATS.APTITUDE_ATTRIBUTE_BONUSES[stats.skillAptitudes.Count - 1]; List <AttributeConverter> convertersForAttribute2 = Db.Get().AttributeConverters.GetConvertersForAttribute(skillAptitude.Key.relevantAttributes[0]); for (int m = 0; m < convertersForAttribute2.Count; m++) { text8 = text8 + "\n • " + convertersForAttribute2[m].DescriptionFromAttribute(convertersForAttribute2[m].multiplier * num2, null); } locText4.GetComponent <ToolTip>().SetSimpleTooltip(text8); gameObject5.gameObject.SetActive(true); aptitudeEntries.Add(gameObject5); } } } if (stats.stressTrait != null) { LocText locText5 = Util.KInstantiateUI <LocText>(expectationRight.gameObject, expectationRight.transform.parent.gameObject, false); locText5.gameObject.SetActive(true); locText5.text = string.Format(UI.CHARACTERCONTAINER_STRESSTRAIT, stats.stressTrait.Name); locText5.GetComponent <ToolTip>().SetSimpleTooltip(stats.stressTrait.GetTooltip()); expectationLabels.Add(locText5); } if (stats.congenitaltrait != null) { LocText locText6 = Util.KInstantiateUI <LocText>(expectationRight.gameObject, expectationRight.transform.parent.gameObject, false); locText6.gameObject.SetActive(true); locText6.text = string.Format(UI.CHARACTERCONTAINER_CONGENITALTRAIT, stats.congenitaltrait.Name); locText6.GetComponent <ToolTip>().SetSimpleTooltip(stats.congenitaltrait.GetTooltip()); expectationLabels.Add(locText6); } description.text = stats.personality.description; }