Beispiel #1
0
 /// <summary>
 /// Applied after OnPrefabInit runs.
 /// </summary>
 internal static void Postfix(SimpleInfoScreen __instance)
 {
     if (__instance != null)
     {
         __instance.gameObject.AddOrGet <SimpleInfoScreenWrapper>();
     }
 }
Beispiel #2
0
        static void Prefix(ref SimpleInfoScreen __instance, GameObject target)
        {
            if (target != null &&
                target.GetComponent <Klei.AI.Traits>() != null &&
                target.GetComponent <KPrefabID>() != null &&
                target.HasTag(GameTags.Creature))
            {
                InitTraitsPanel(__instance);

                TraitsPanel.gameObject.SetActive(true);
                TraitsPanel.HeaderLabel.text = "TRAITS";

                TraitsDrawer.BeginDrawing();
                foreach (Trait trait in target.GetComponent <Klei.AI.Traits>().TraitList)
                {
                    if (!Traits.AllTraits.IsSupportedTrait(trait.Id))
                    {
                        continue;
                    }

                    var color = trait.PositiveTrait ? Constants.POSITIVE_COLOR : Constants.NEGATIVE_COLOR;
                    TraitsDrawer.NewLabel($"<color=#{color.ToHexString()}>{trait.Name}</color>").Tooltip(trait.GetTooltip());
                }
                TraitsDrawer.EndDrawing();
            }
            else
            {
                TraitsPanel?.gameObject?.SetActive(false);
            }
        }
Beispiel #3
0
            public static void Prefix(SimpleInfoScreen __instance, GameObject target)
            {
                var dupe = target.GetComponent <MinionIdentity>();

                // ReSharper disable once InvertIf
                if (dupe)
                {
                    Debug.Log("Dupe selected!");
                    //dupe.SetName("Guess who edited your name");
                    //dupe.
                    //Db.Get().Attributes.GermResistance.Lookup(dupe).Attribute.BaseValue = 100f;
                    //dupe.GetComponent()
                    //((Health) dupe.GetComponent(typeof(Health))).hitPoints = 150;
                    //target.GetAmounts().SetValue("Stress", 5);
                    //if (target.GetAmounts().ModifierList.Find((e) => e.modifier.Id == "ImmuneSystem") == null)
                    if (!HasDupeValue(target, ImmuneSystemAmount))
                    {
                        Debug.Log("Value ImmuneSystem was not present in Duplicant.");
                        target.GetAmounts().ModifierList.Add(new AmountInstance(ImmuneSystemAmount, target));
                        target.GetAmounts().SetValue("ImmuneSystem", 100);
                    }

                    //var value = target.GetAmounts().GetValue("ImmuneSystem");
                    //target.GetAmounts().SetValue("ImmuneSystem", value - 2.5f);
                    //ImmuneSystemAmount.Lookup(target).value -= 2.5f;
                }

                //___vitalsContainer.add LineItemPrefab.AddComponent(typeof(InfoScreenLineItem));
            }
            public static void Postfix(ref SimpleInfoScreen __instance, GameObject target)
            {
                if (target == null)
                {
                    return;
                }

                var prefab = target.GetComponent <KPrefabID>();

                if (prefab == null)
                {
                    return;
                }

                if (!prefab.HasTag(RoomConstraints.ConstraintTags.IndustrialMachinery))
                {
                    return;
                }

                var field = Traverse.Create(__instance).Field("descriptionContainer");
                var descriptionContainer = field?.GetValue <DescriptionContainer>();

                if (descriptionContainer == null)
                {
                    return;
                }

                var text = "\n\n<color=\"red\"><b>This is an industrial machine.</b></color>";

                descriptionContainer.flavour.text += text;

                field.SetValue(descriptionContainer);
            }
Beispiel #5
0
 /// <summary>
 /// Applied before OnSelectTarget runs.
 /// </summary>
 internal static bool Prefix(SimpleInfoScreen __instance, GameObject target)
 {
     if (__instance.lastTarget != target)
     {
         instance?.OnSelectTarget(target);
     }
     return(true);
 }
Beispiel #6
0
 private static void InitTraitsPanel(SimpleInfoScreen instance)
 {
     if (TraitsPanel == null || LastParent != instance.gameObject)
     {
         TraitsPanel  = Util.KInstantiateUI <CollapsibleDetailContentPanel>(ScreenPrefabs.Instance.CollapsableContentPanel, instance.gameObject);
         TraitsDrawer = new DetailsPanelDrawer(instance.attributesLabelTemplate, TraitsPanel.Content.gameObject);
         LastParent   = instance.gameObject;
     }
 }
            /// <summary>
            /// Applied after OnPrefabInit runs.
            /// </summary>
            internal static void Postfix(SimpleInfoScreen __instance)
            {
                var obj = __instance.gameObject;

                if (obj != null)
                {
                    obj.AddOrGet <InfoScreenRefresher>();
                }
            }
Beispiel #8
0
            private static void Postfix(SimpleInfoScreen __instance,
                                        GameObject ___storagePanel, GameObject ___selectedTarget,
                                        ref Dictionary <string, GameObject> ___storageLabels)
            {
                if (___selectedTarget.GetComponent <TeleStorage>() == null)
                {
                    return;
                }
                ConduitType type = ___selectedTarget.GetComponent <TeleStorage>().Type;

                ___storagePanel.gameObject.SetActive(true);
                ___storagePanel.GetComponent <CollapsibleDetailContentPanel>().HeaderLabel.text = (!(___selectedTarget.GetComponent <MinionIdentity>() != null) ? STRINGS.UI.DETAILTABS.DETAILS.GROUPNAME_CONTENTS : STRINGS.UI.DETAILTABS.DETAILS.GROUPNAME_MINION_CONTENTS);
                if (___storageLabels == null)
                {
                    ___storageLabels = new Dictionary <string, GameObject>();
                }
                foreach (KeyValuePair <string, GameObject> storageLabel in ___storageLabels)
                {
                    storageLabel.Value.SetActive(false);
                }
                int num = 0;

                foreach (SimHashes element in TeleStorageData.Instance.storedElementsMap.Keys)
                {
                    StoredItem item = TeleStorageData.Instance.storedElementsMap[element];
                    if (item.mass > 0.0f)
                    {
                        Element elementObj = ElementLoader.FindElementByHash(element);
                        if (elementObj.IsLiquid && !type.Equals(ConduitType.Liquid))
                        {
                            continue;
                        }
                        if (elementObj.IsGas && !type.Equals(ConduitType.Gas))
                        {
                            continue;
                        }
                        GameObject storageLabel = Traverse.Create(__instance).Method("AddOrGetStorageLabel", new Type[] { typeof(Dictionary <string, GameObject>), typeof(GameObject), typeof(string) }).GetValue <GameObject>(new object[] { ___storageLabels, ___storagePanel, "storage_" + num.ToString() });
                        ++num;
                        storageLabel.GetComponentInChildren <ToolTip>().ClearMultiStringTooltip();
                        string formattedName = elementObj.name;
                        string str1          = string.Format(STRINGS.UI.DETAILTABS.DETAILS.CONTENTS_MASS, formattedName, GameUtil.GetFormattedMass(item.mass, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"));
                        string str2          = string.Format(STRINGS.UI.DETAILTABS.DETAILS.CONTENTS_TEMPERATURE, str1, GameUtil.GetFormattedTemperature(item.temperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false));
                        if (item.diseaseIdx != byte.MaxValue)
                        {
                            str2 += string.Format(STRINGS.UI.DETAILTABS.DETAILS.CONTENTS_DISEASED, GameUtil.GetFormattedDisease(item.diseaseIdx, item.diseaseCount, false));
                            string formattedDisease = GameUtil.GetFormattedDisease(item.diseaseIdx, item.diseaseCount, true);
                            storageLabel.GetComponentInChildren <ToolTip>().AddMultiStringTooltip(formattedDisease, PluginAssets.Instance.defaultTextStyleSetting);
                        }
                        storageLabel.GetComponentInChildren <LocText>().text = str2;
                    }
                }
                if (num == 0)
                {
                    Traverse.Create(__instance).Method("AddOrGetStorageLabel", new Type[] { typeof(Dictionary <string, GameObject>), typeof(GameObject), typeof(string) }).GetValue <GameObject>(___storageLabels, ___storagePanel, "empty").GetComponentInChildren <LocText>().text = STRINGS.UI.DETAILTABS.DETAILS.STORAGE_EMPTY;
                }
                Traverse.Create(___storagePanel.GetComponent <CollapsibleDetailContentPanel>().scalerMask).Method("Update").GetValue();
            }
Beispiel #9
0
            /// <summary>
            /// Applied before RefreshStorage runs.
            /// </summary>
            internal static bool Prefix(SimpleInfoScreen __instance)
            {
                var inst = instance;

                if (inst != null && __instance.selectedTarget != null)
                {
                    inst.RefreshStorage(false);
                }
                return(false);
            }
 public static void Postfix(SimpleInfoScreen __instance, GameObject ___selectedTarget)
 {
     if (___selectedTarget != null)
     {
         // TODO: At some point adjust for dupe carrying capacity
         var storages = ___selectedTarget.GetComponentsInChildren <Storage>();
         var panel    = __instance.StoragePanel.GetComponent <CollapsibleDetailContentPanel>();
         if (panel != null && storages.Length > 0)
         {
             var storedMass = storages.Sum(storage => storage.MassStored());
             var totalMass  = storages.Sum(storage => storage.Capacity());
             panel.HeaderLabel.text
                 += ": " + string.Format(UI.STARMAP.STORAGESTATS.STORAGECAPACITY, storedMass, totalMass) +
                    UI.UNITSUFFIXES.MASS.KILOGRAM;
         }
     }
 }
Beispiel #11
0
 static void Prefix(ref SimpleInfoScreen __instance, GameObject target)
 {
     if (target != null && (target.GetComponent <Klei.AI.Traits>() != null || target.GetComponent <AIGeneticTraits>() != null) && (target.HasTag(GameTags.Creature) || target.HasTag(GameTags.Egg)))
     {
         InitTraitsPanel(__instance);
         TraitsPanel.gameObject.SetActive(true);
         TraitsPanel.HeaderLabel.text = "GENETIC TRAITS";
         TraitsDrawer.BeginDrawing();
         List <Trait> traits = null;
         if (target.HasTag(GameTags.Egg) && target.GetComponent <AIGeneticTraits>() != null)
         {
             traits = target.GetComponent <AIGeneticTraits>().TraitList;
         }
         else
         {
             traits = target.GetComponent <Klei.AI.Traits>().TraitList;
         }
         foreach (Trait trait in traits)
         {
             if (!GeneticTraits.GeneticTraits.IsSupportedTrait(trait.Id))
             {
                 continue;
             }
             var color = trait.PositiveTrait ? Constants.POSITIVE_COLOR : Constants.NEGATIVE_COLOR;
             TraitsDrawer.NewLabel($"<color=#{color.ToHexString()}>{trait.Name}</color>").Tooltip(trait.GetTooltip());
             var traitComponent = GeneticTraits.GeneticTraits.getTrait(trait.Id);
             if (traitComponent.CustomDescription)
             {
                 var textholders = target.GetComponents <StringHolderComponent>();
                 if (textholders != null)
                 {
                     var text = textholders.Where(x => x.id == trait.Id).First();
                     if (text.text != null)
                     {
                         TraitsDrawer.NewLabel(text.text);
                     }
                 }
             }
         }
         TraitsDrawer.EndDrawing();
     }
     else
     {
         TraitsPanel?.gameObject?.SetActive(false);
     }
 }
Beispiel #12
0
        /// <summary>
        /// Creates a new blank label.
        /// </summary>
        /// <param name="sis">The info screen for the label prefab.</param>
        /// <param name="parent">The parent object for the label.</param>
        /// <param name="id">The unique ID of this label.</param>
        internal CachedStorageLabel(SimpleInfoScreen sis, GameObject parent, string id)
        {
            var label     = Util.KInstantiate(sis.attributesLabelButtonTemplate, parent, id);
            var transform = label.transform;

            transform.localScale = Vector3.one;
            labelObj             = label;
            freeze = label.AddOrGet <LayoutElement>();
            frozen = FREEZE_THAWED;
            label.TryGetComponent(out selectButton);
            label.TryGetComponent(out thaw);
            Lines = 0;
            selectButton.onClick += Select;
            tooltip = label.GetComponentInChildren <ToolTip>();
            text    = label.GetComponentInChildren <LocText>();
            if (id == EMPTY_ITEM)
            {
                text.SetText(STRINGS.UI.DETAILTABS.DETAILS.STORAGE_EMPTY);
            }
            // Set up the manual drop button, but default disable
            transform = transform.Find("removeAttributeButton");
            if (transform != null)
            {
                var remove = transform.FindComponent <KButton>();
                remove.enabled = false;
                remove.gameObject.SetActive(false);
                remove.onClick += Drop;
                removeButton    = remove;
            }
            else
            {
                removeButton = null;
            }
            active         = false;
            this.id        = id;
            item           = null;
            storage        = null;
            freeze.enabled = false;
        }
Beispiel #13
0
 /// <summary>
 /// Applied after OnDeselectTarget runs.
 /// </summary>
 internal static void Postfix(SimpleInfoScreen __instance, GameObject target)
 {
     __instance.gameObject.GetComponentSafe <InfoScreenRefresher>()?.
     OnDeselectTarget(target);
 }
Beispiel #14
0
 /// <summary>
 /// Applied after OnPrefabInit runs.
 /// </summary>
 internal static void Postfix(SimpleInfoScreen __instance)
 {
     __instance.gameObject.AddOrGet <InfoScreenRefresher>();
 }
Beispiel #15
0
 /// <summary>
 /// Applied before RefreshWorld runs.
 /// </summary>
 internal static bool Prefix(SimpleInfoScreen __instance)
 {
     instance?.RefreshWorld();
     return(false);
 }