public void Sim1000ms(float dt) { foreach (KeyValuePair <HandleVector <int> .Handle, Rottable.Instance> rotUpdater in rotUpdaters) { HandleVector <int> .Handle key = rotUpdater.Key; Rottable.Instance value = rotUpdater.Value; Fetchable data = fetchables.GetData(key); data.freshness = QuantizeRotValue(value.RotValue); fetchables.SetData(key, data); } }
protected override void OnPrefabInit() { base.OnPrefabInit(); Pickupable pickupable = GetComponent <Pickupable>(); if ((UnityEngine.Object)pickupable == (UnityEngine.Object)null) { Debug.LogError(base.name + " does not have a pickupable component!"); } Pickupable pickupable2 = pickupable; pickupable2.OnTake = (Func <float, Pickupable>)Delegate.Combine(pickupable2.OnTake, (Func <float, Pickupable>)((float amount) => Split(pickupable, amount, null))); Rottable.Instance rottable = base.gameObject.GetSMI <Rottable.Instance>(); pickupable.absorbable = true; pickupable.CanAbsorb = ((Pickupable other) => CanFirstAbsorbSecond(pickupable, rottable, other, maxStackSize)); Subscribe(-2064133523, OnAbsorbDelegate); }
public HandleVector <int> .Handle AddPickupable(Pickupable pickupable) { byte foodQuality = 5; Edible component = pickupable.GetComponent <Edible>(); if ((Object)component != (Object)null) { foodQuality = (byte)component.GetQuality(); } byte masterPriority = 0; Prioritizable prioritizable = null; if ((Object)pickupable.storage != (Object)null) { prioritizable = pickupable.storage.prioritizable; if ((Object)prioritizable != (Object)null) { PrioritySetting masterPriority2 = prioritizable.GetMasterPriority(); masterPriority = (byte)masterPriority2.priority_value; } } Rottable.Instance sMI = pickupable.GetSMI <Rottable.Instance>(); byte freshness = 0; if (!sMI.IsNullOrStopped()) { freshness = QuantizeRotValue(sMI.RotValue); } KPrefabID component2 = pickupable.GetComponent <KPrefabID>(); TagBits rhs = new TagBits(ref disallowedTagMask); component2.AndTagBits(ref rhs); HandleVector <int> .Handle handle = fetchables.Allocate(new Fetchable { pickupable = pickupable, foodQuality = foodQuality, freshness = freshness, masterPriority = masterPriority, tagBitsHash = rhs.GetHashCode() }); if (!sMI.IsNullOrStopped()) { rotUpdaters[handle] = sMI; } return(handle); }
private static bool CanFirstAbsorbSecond(Pickupable pickupable, Rottable.Instance rottable, Pickupable other, float maxStackSize) { if ((UnityEngine.Object)other == (UnityEngine.Object)null) { return(false); } KPrefabID component = pickupable.GetComponent <KPrefabID>(); KPrefabID component2 = other.GetComponent <KPrefabID>(); if ((UnityEngine.Object)component == (UnityEngine.Object)null) { return(false); } if ((UnityEngine.Object)component2 == (UnityEngine.Object)null) { return(false); } if (component.PrefabTag != component2.PrefabTag) { return(false); } if (pickupable.TotalAmount + other.TotalAmount > maxStackSize) { return(false); } if (rottable != null) { Rottable.Instance sMI = other.GetSMI <Rottable.Instance>(); if (sMI == null) { return(false); } if (!rottable.IsRotLevelStackable(sMI)) { return(false); } } return(true); }
private void RefreshStorage() { if ((UnityEngine.Object)selectedTarget == (UnityEngine.Object)null) { storagePanel.gameObject.SetActive(false); } else { Storage[] componentsInChildren = selectedTarget.GetComponentsInChildren <Storage>(); if (componentsInChildren == null) { storagePanel.gameObject.SetActive(false); } else { componentsInChildren = Array.FindAll(componentsInChildren, (Storage n) => n.showInUI); if (componentsInChildren.Length == 0) { storagePanel.gameObject.SetActive(false); } else { storagePanel.gameObject.SetActive(true); string text = (!((UnityEngine.Object)selectedTarget.GetComponent <MinionIdentity>() != (UnityEngine.Object)null)) ? UI.DETAILTABS.DETAILS.GROUPNAME_CONTENTS : UI.DETAILTABS.DETAILS.GROUPNAME_MINION_CONTENTS; storagePanel.GetComponent <CollapsibleDetailContentPanel>().HeaderLabel.text = text; foreach (KeyValuePair <string, GameObject> storageLabel in storageLabels) { storageLabel.Value.SetActive(false); } int num = 0; Storage[] array = componentsInChildren; GameObject select_item; Storage selected_storage; GameObject select_target; foreach (Storage storage in array) { foreach (GameObject item in storage.items) { if (!((UnityEngine.Object)item == (UnityEngine.Object)null)) { GameObject gameObject = AddOrGetStorageLabel(storageLabels, storagePanel, "storage_" + num.ToString()); num++; if (storage.allowUIItemRemoval) { Transform transform = gameObject.transform.Find("removeAttributeButton"); if ((UnityEngine.Object)transform != (UnityEngine.Object)null) { KButton component = transform.GetComponent <KButton>(); component.enabled = true; component.gameObject.SetActive(true); select_item = item; selected_storage = storage; component.onClick += delegate { selected_storage.Drop(select_item, true); }; } } PrimaryElement component2 = item.GetComponent <PrimaryElement>(); Rottable.Instance sMI = item.GetSMI <Rottable.Instance>(); gameObject.GetComponentInChildren <ToolTip>().ClearMultiStringTooltip(); string unitFormattedName = GameUtil.GetUnitFormattedName(item, false); unitFormattedName = string.Format(UI.DETAILTABS.DETAILS.CONTENTS_MASS, unitFormattedName, GameUtil.GetFormattedMass(component2.Mass, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); unitFormattedName = string.Format(UI.DETAILTABS.DETAILS.CONTENTS_TEMPERATURE, unitFormattedName, GameUtil.GetFormattedTemperature(component2.Temperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); if (sMI != null) { string text2 = sMI.StateString(); if (!string.IsNullOrEmpty(text2)) { unitFormattedName += string.Format(UI.DETAILTABS.DETAILS.CONTENTS_ROTTABLE, text2); } gameObject.GetComponentInChildren <ToolTip>().AddMultiStringTooltip(sMI.GetToolTip(), PluginAssets.Instance.defaultTextStyleSetting); } if (component2.DiseaseIdx != 255) { unitFormattedName += string.Format(UI.DETAILTABS.DETAILS.CONTENTS_DISEASED, GameUtil.GetFormattedDisease(component2.DiseaseIdx, component2.DiseaseCount, false)); string formattedDisease = GameUtil.GetFormattedDisease(component2.DiseaseIdx, component2.DiseaseCount, true); gameObject.GetComponentInChildren <ToolTip>().AddMultiStringTooltip(formattedDisease, PluginAssets.Instance.defaultTextStyleSetting); } gameObject.GetComponentInChildren <LocText>().text = unitFormattedName; KButton component3 = gameObject.GetComponent <KButton>(); select_target = item; component3.onClick += delegate { SelectTool.Instance.Select(select_target.GetComponent <KSelectable>(), false); }; } } } if (num == 0) { GameObject gameObject2 = AddOrGetStorageLabel(storageLabels, storagePanel, "empty"); gameObject2.GetComponentInChildren <LocText>().text = UI.DETAILTABS.DETAILS.STORAGE_EMPTY; } } } } }
private void CreateStatusItems() { Hot = new StatusItem("Hot", "CREATURES", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Hot.resolveStringCallback = delegate(string str, object data) { TemperatureVulnerable temperatureVulnerable4 = (TemperatureVulnerable)data; return(string.Format(str, GameUtil.GetFormattedTemperature(temperatureVulnerable4.internalTemperatureWarning_Low, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false), GameUtil.GetFormattedTemperature(temperatureVulnerable4.internalTemperatureWarning_High, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))); }; Hot_Crop = new StatusItem("Hot_Crop", "CREATURES", "status_item_plant_temperature", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Hot_Crop.resolveStringCallback = delegate(string str, object data) { TemperatureVulnerable temperatureVulnerable3 = (TemperatureVulnerable)data; str = str.Replace("{low_temperature}", GameUtil.GetFormattedTemperature(temperatureVulnerable3.internalTemperatureWarning_Low, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{high_temperature}", GameUtil.GetFormattedTemperature(temperatureVulnerable3.internalTemperatureWarning_High, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Scalding = new StatusItem("Scalding", "CREATURES", string.Empty, StatusItem.IconType.Exclamation, NotificationType.DuplicantThreatening, true, OverlayModes.None.ID, true, 129022); Scalding.resolveTooltipCallback = delegate(string str, object data) { float averageExternalTemperature = ((ExternalTemperatureMonitor.Instance)data).AverageExternalTemperature; float scaldingThreshold = ((ExternalTemperatureMonitor.Instance)data).GetScaldingThreshold(); str = str.Replace("{ExternalTemperature}", GameUtil.GetFormattedTemperature(averageExternalTemperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{TargetTemperature}", GameUtil.GetFormattedTemperature(scaldingThreshold, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Scalding.AddNotification(null, null, null, 0f); Cold = new StatusItem("Cold", "CREATURES", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Cold.resolveStringCallback = delegate(string str, object data) { TemperatureVulnerable temperatureVulnerable2 = (TemperatureVulnerable)data; return(string.Format(str, GameUtil.GetFormattedTemperature(temperatureVulnerable2.internalTemperatureWarning_Low, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false), GameUtil.GetFormattedTemperature(temperatureVulnerable2.internalTemperatureWarning_High, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))); }; Cold_Crop = new StatusItem("Cold_Crop", "CREATURES", "status_item_plant_temperature", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Cold_Crop.resolveStringCallback = delegate(string str, object data) { TemperatureVulnerable temperatureVulnerable = (TemperatureVulnerable)data; str = str.Replace("low_temperature", GameUtil.GetFormattedTemperature(temperatureVulnerable.internalTemperatureWarning_Low, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("high_temperature", GameUtil.GetFormattedTemperature(temperatureVulnerable.internalTemperatureWarning_High, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Crop_Too_Dark = new StatusItem("Crop_Too_Dark", "CREATURES", "status_item_plant_light", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Crop_Too_Dark.resolveStringCallback = ((string str, object data) => str); Crop_Too_Bright = new StatusItem("Crop_Too_Bright", "CREATURES", "status_item_plant_light", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Crop_Too_Bright.resolveStringCallback = ((string str, object data) => str); Hyperthermia = new StatusItem("Hyperthermia", "CREATURES", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 129022); Hyperthermia.resolveTooltipCallback = delegate(string str, object data) { float value2 = ((TemperatureMonitor.Instance)data).temperature.value; float hyperthermiaThreshold = ((TemperatureMonitor.Instance)data).HyperthermiaThreshold; str = str.Replace("{InternalTemperature}", GameUtil.GetFormattedTemperature(value2, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{TargetTemperature}", GameUtil.GetFormattedTemperature(hyperthermiaThreshold, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Hypothermia = new StatusItem("Hypothermia", "CREATURES", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 129022); Hypothermia.resolveTooltipCallback = delegate(string str, object data) { float value = ((TemperatureMonitor.Instance)data).temperature.value; float hypothermiaThreshold = ((TemperatureMonitor.Instance)data).HypothermiaThreshold; str = str.Replace("{InternalTemperature}", GameUtil.GetFormattedTemperature(value, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{TargetTemperature}", GameUtil.GetFormattedTemperature(hypothermiaThreshold, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Suffocating = new StatusItem("Suffocating", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Hatching = new StatusItem("Hatching", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Incubating = new StatusItem("Incubating", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Drowning = new StatusItem("Drowning", "CREATURES", "status_item_flooded", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Drowning.resolveStringCallback = ((string str, object data) => str); Saturated = new StatusItem("Saturated", "CREATURES", "status_item_flooded", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Saturated.resolveStringCallback = ((string str, object data) => str); DryingOut = new StatusItem("DryingOut", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 1026); DryingOut.resolveStringCallback = ((string str, object data) => str); ReadyForHarvest = new StatusItem("ReadyForHarvest", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 1026); Growing = new StatusItem("Growing", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 1026); Growing.resolveStringCallback = delegate(string str, object data) { Crop component = ((Growing)data).GetComponent <Crop>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { float seconds = ((Growing)data).TimeUntilNextHarvest(); str = str.Replace("{TimeUntilNextHarvest}", GameUtil.GetFormattedCycles(seconds, "F1")); } float val = 100f * ((Growing)data).PercentGrown(); str = str.Replace("{PercentGrow}", Math.Floor((double)Math.Max(val, 0f)).ToString("F0")); return(str); }; CropSleeping = new StatusItem("Crop_Sleeping", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 1026); CropSleeping.resolveStringCallback = delegate(string str, object data) { CropSleepingMonitor.Instance instance8 = (CropSleepingMonitor.Instance)data; return(str.Replace("{REASON}", (!instance8.def.prefersDarkness) ? CREATURES.STATUSITEMS.CROP_SLEEPING.REASON_TOO_DARK : CREATURES.STATUSITEMS.CROP_SLEEPING.REASON_TOO_BRIGHT)); }; CropSleeping.resolveTooltipCallback = delegate(string str, object data) { CropSleepingMonitor.Instance instance7 = (CropSleepingMonitor.Instance)data; string newValue4 = string.Format(CREATURES.STATUSITEMS.CROP_SLEEPING.REQUIREMENT_LUMINANCE, instance7.def.lightIntensityThreshold); return(str.Replace("{REQUIREMENTS}", newValue4)); }; EnvironmentTooWarm = new StatusItem("EnvironmentTooWarm", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); EnvironmentTooWarm.resolveStringCallback = delegate(string str, object data) { float temp3 = Grid.Temperature[Grid.PosToCell(((TemperatureVulnerable)data).gameObject)]; float temp4 = ((TemperatureVulnerable)data).internalTemperatureLethal_High - 1f; str = str.Replace("{ExternalTemperature}", GameUtil.GetFormattedTemperature(temp3, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{TargetTemperature}", GameUtil.GetFormattedTemperature(temp4, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; EnvironmentTooCold = new StatusItem("EnvironmentTooCold", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); EnvironmentTooCold.resolveStringCallback = delegate(string str, object data) { float temp = Grid.Temperature[Grid.PosToCell(((TemperatureVulnerable)data).gameObject)]; float temp2 = ((TemperatureVulnerable)data).internalTemperatureLethal_Low + 1f; str = str.Replace("{ExternalTemperature}", GameUtil.GetFormattedTemperature(temp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); str = str.Replace("{TargetTemperature}", GameUtil.GetFormattedTemperature(temp2, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)); return(str); }; Entombed = new StatusItem("Entombed", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Entombed.resolveStringCallback = ((string str, object go) => str); Entombed.resolveTooltipCallback = delegate(string str, object go) { GameObject go2 = go as GameObject; return(string.Format(str, GameUtil.GetIdentityDescriptor(go2))); }; Wilting = new StatusItem("Wilting", "CREATURES", "status_item_need_plant", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 1026); Wilting.resolveStringCallback = delegate(string str, object data) { if (data is Growing && data != null) { str = str.Replace("{TimeUntilNextHarvest}", GameUtil.GetFormattedCycles(Mathf.Min(((Growing)data).growthTime, ((Growing)data).TimeUntilNextHarvest()), "F1")); } str = str.Replace("{Reasons}", (data as KMonoBehaviour).GetComponent <WiltCondition>().WiltCausesString()); return(str); }; WiltingDomestic = new StatusItem("WiltingDomestic", "CREATURES", "status_item_need_plant", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 1026); WiltingDomestic.resolveStringCallback = delegate(string str, object data) { if (data is Growing && data != null) { str = str.Replace("{TimeUntilNextHarvest}", GameUtil.GetFormattedCycles(Mathf.Min(((Growing)data).growthTime, ((Growing)data).TimeUntilNextHarvest()), "F1")); } str = str.Replace("{Reasons}", (data as KMonoBehaviour).GetComponent <WiltCondition>().WiltCausesString()); return(str); }; WiltingNonGrowing = new StatusItem("WiltingNonGrowing", "CREATURES", "status_item_need_plant", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 1026); WiltingNonGrowing.resolveStringCallback = delegate(string str, object data) { str = CREATURES.STATUSITEMS.WILTING_NON_GROWING_PLANT.NAME; str = str.Replace("{Reasons}", (data as WiltCondition).WiltCausesString()); return(str); }; WiltingNonGrowingDomestic = new StatusItem("WiltingNonGrowing", "CREATURES", "status_item_need_plant", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 1026); WiltingNonGrowingDomestic.resolveStringCallback = delegate(string str, object data) { str = CREATURES.STATUSITEMS.WILTING_NON_GROWING_PLANT.NAME; str = str.Replace("{Reasons}", (data as WiltCondition).WiltCausesString()); return(str); }; WrongAtmosphere = new StatusItem("WrongAtmosphere", "CREATURES", "status_item_plant_atmosphere", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); WrongAtmosphere.resolveStringCallback = delegate(string str, object data) { string text = string.Empty; foreach (Element safe_atmosphere in (data as PressureVulnerable).safe_atmospheres) { text = text + "\n • " + safe_atmosphere.name; } str = str.Replace("{elements}", text); return(str); }; AtmosphericPressureTooLow = new StatusItem("AtmosphericPressureTooLow", "CREATURES", "status_item_plant_atmosphere", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); AtmosphericPressureTooLow.resolveStringCallback = delegate(string str, object data) { PressureVulnerable pressureVulnerable2 = (PressureVulnerable)data; str = str.Replace("{low_mass}", GameUtil.GetFormattedMass(pressureVulnerable2.pressureWarning_Low, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); str = str.Replace("{high_mass}", GameUtil.GetFormattedMass(pressureVulnerable2.pressureWarning_High, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; AtmosphericPressureTooHigh = new StatusItem("AtmosphericPressureTooHigh", "CREATURES", "status_item_plant_atmosphere", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); AtmosphericPressureTooHigh.resolveStringCallback = delegate(string str, object data) { PressureVulnerable pressureVulnerable = (PressureVulnerable)data; str = str.Replace("{low_mass}", GameUtil.GetFormattedMass(pressureVulnerable.pressureWarning_Low, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); str = str.Replace("{high_mass}", GameUtil.GetFormattedMass(pressureVulnerable.pressureWarning_High, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; HealthStatus = new StatusItem("HealthStatus", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); HealthStatus.resolveStringCallback = delegate(string str, object data) { string newValue3 = string.Empty; switch ((Health.HealthState)data) { case Health.HealthState.Perfect: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.PERFECT.NAME; break; case Health.HealthState.Scuffed: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.SCUFFED.NAME; break; case Health.HealthState.Injured: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.INJURED.NAME; break; case Health.HealthState.Critical: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.CRITICAL.NAME; break; case Health.HealthState.Incapacitated: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.INCAPACITATED.NAME; break; case Health.HealthState.Dead: newValue3 = MISC.STATUSITEMS.HEALTHSTATUS.DEAD.NAME; break; } str = str.Replace("{healthState}", newValue3); return(str); }; HealthStatus.resolveTooltipCallback = delegate(string str, object data) { string newValue2 = string.Empty; switch ((Health.HealthState)data) { case Health.HealthState.Perfect: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.PERFECT.TOOLTIP; break; case Health.HealthState.Scuffed: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.SCUFFED.TOOLTIP; break; case Health.HealthState.Injured: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.INJURED.TOOLTIP; break; case Health.HealthState.Critical: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.CRITICAL.TOOLTIP; break; case Health.HealthState.Incapacitated: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.INCAPACITATED.TOOLTIP; break; case Health.HealthState.Dead: newValue2 = MISC.STATUSITEMS.HEALTHSTATUS.DEAD.TOOLTIP; break; } str = str.Replace("{healthState}", newValue2); return(str); }; Barren = new StatusItem("Barren", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); NeedsFertilizer = new StatusItem("NeedsFertilizer", "CREATURES", "status_item_plant_solid", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Func <string, object, string> resolveStringCallback = (string str, object data) => str; NeedsFertilizer.resolveStringCallback = resolveStringCallback; NeedsIrrigation = new StatusItem("NeedsIrrigation", "CREATURES", "status_item_plant_liquid", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, false, 129022); Func <string, object, string> resolveStringCallback2 = (string str, object data) => str; NeedsIrrigation.resolveStringCallback = resolveStringCallback2; WrongFertilizer = new StatusItem("WrongFertilizer", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Func <string, object, string> resolveStringCallback3 = (string str, object data) => str; WrongFertilizer.resolveStringCallback = resolveStringCallback3; WrongFertilizerMajor = new StatusItem("WrongFertilizerMajor", "CREATURES", "status_item_fabricator_empty", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); WrongFertilizerMajor.resolveStringCallback = resolveStringCallback3; WrongIrrigation = new StatusItem("WrongIrrigation", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Func <string, object, string> resolveStringCallback4 = (string str, object data) => str; WrongIrrigation.resolveStringCallback = resolveStringCallback4; WrongIrrigationMajor = new StatusItem("WrongIrrigationMajor", "CREATURES", "status_item_fabricator_empty", StatusItem.IconType.Custom, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); WrongIrrigationMajor.resolveStringCallback = resolveStringCallback4; CantAcceptFertilizer = new StatusItem("CantAcceptFertilizer", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Rotting = new StatusItem("Rotting", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Rotting.resolveStringCallback = ((string str, object data) => str.Replace("{RotTemperature}", GameUtil.GetFormattedTemperature(277.15f, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))); Fresh = new StatusItem("Fresh", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Fresh.resolveStringCallback = delegate(string str, object data) { Rottable.Instance instance6 = (Rottable.Instance)data; return(str.Replace("{RotPercentage}", "(" + Util.FormatWholeNumber(instance6.RotConstitutionPercentage * 100f) + "%)")); }; Fresh.resolveTooltipCallback = delegate(string str, object data) { Rottable.Instance instance5 = (Rottable.Instance)data; return(str.Replace("{RotTooltip}", instance5.GetToolTip())); }; Stale = new StatusItem("Stale", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Stale.resolveStringCallback = delegate(string str, object data) { Rottable.Instance instance4 = (Rottable.Instance)data; return(str.Replace("{RotPercentage}", "(" + Util.FormatWholeNumber(instance4.RotConstitutionPercentage * 100f) + "%)")); }; Stale.resolveTooltipCallback = delegate(string str, object data) { Rottable.Instance instance3 = (Rottable.Instance)data; return(str.Replace("{RotTooltip}", instance3.GetToolTip())); }; Spoiled = new StatusItem("Spoiled", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Refrigerated = new StatusItem("Refrigerated", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Unrefrigerated = new StatusItem("Unrefrigerated", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Unrefrigerated.resolveStringCallback = ((string str, object data) => str.Replace("{RotTemperature}", GameUtil.GetFormattedTemperature(277.15f, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))); SterilizingAtmosphere = new StatusItem("SterilizingAtmosphere", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); ContaminatedAtmosphere = new StatusItem("ContaminatedAtmosphere", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Old = new StatusItem("Old", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022); Old.resolveTooltipCallback = delegate(string str, object data) { AgeMonitor.Instance instance2 = (AgeMonitor.Instance)data; return(str.Replace("{TimeUntilDeath}", GameUtil.GetFormattedCycles(instance2.CyclesUntilDeath * 600f, "F1"))); }; ExchangingElementConsume = new StatusItem("ExchangingElementConsume", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); ExchangingElementConsume.resolveStringCallback = delegate(string str, object data) { EntityElementExchanger.StatesInstance statesInstance4 = (EntityElementExchanger.StatesInstance)data; str = str.Replace("{ConsumeElement}", ElementLoader.FindElementByHash(statesInstance4.master.consumedElement).tag.ProperName()); str = str.Replace("{ConsumeRate}", GameUtil.GetFormattedMass(statesInstance4.master.consumeRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; ExchangingElementConsume.resolveTooltipCallback = delegate(string str, object data) { EntityElementExchanger.StatesInstance statesInstance3 = (EntityElementExchanger.StatesInstance)data; str = str.Replace("{ConsumeElement}", ElementLoader.FindElementByHash(statesInstance3.master.consumedElement).tag.ProperName()); str = str.Replace("{ConsumeRate}", GameUtil.GetFormattedMass(statesInstance3.master.consumeRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; ExchangingElementOutput = new StatusItem("ExchangingElementOutput", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); ExchangingElementOutput.resolveStringCallback = delegate(string str, object data) { EntityElementExchanger.StatesInstance statesInstance2 = (EntityElementExchanger.StatesInstance)data; str = str.Replace("{OutputElement}", ElementLoader.FindElementByHash(statesInstance2.master.emittedElement).tag.ProperName()); str = str.Replace("{OutputRate}", GameUtil.GetFormattedMass(statesInstance2.master.consumeRate * statesInstance2.master.exchangeRatio, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; ExchangingElementOutput.resolveTooltipCallback = delegate(string str, object data) { EntityElementExchanger.StatesInstance statesInstance = (EntityElementExchanger.StatesInstance)data; str = str.Replace("{OutputElement}", ElementLoader.FindElementByHash(statesInstance.master.emittedElement).tag.ProperName()); str = str.Replace("{OutputRate}", GameUtil.GetFormattedMass(statesInstance.master.consumeRate * statesInstance.master.exchangeRatio, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")); return(str); }; Hungry = new StatusItem("Hungry", "CREATURES", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 129022); Hungry.resolveTooltipCallback = delegate(string str, object data) { CreatureCalorieMonitor.Instance instance = (CreatureCalorieMonitor.Instance)data; CreatureCalorieMonitor.Def def = instance.master.gameObject.GetDef <CreatureCalorieMonitor.Def>(); Diet diet = def.diet; if (diet.consumedTags.Count > 0) { string[] array = (from t in diet.consumedTags select t.Key.ProperName()).ToArray(); if (array.Length > 3) { string[] array2 = new string[4] { array[0], array[1], array[2], "..." }; array = array2; } string newValue = string.Join(", ", array); return(str + "\n" + UI.BUILDINGEFFECTS.DIET_CONSUMED.text.Replace("{Foodlist}", newValue)); } return(str); }; }
private TemplateContainer GetSelectionAsAsset() { List <Cell> list = new List <Cell>(); List <Prefab> list2 = new List <Prefab>(); List <Prefab> list3 = new List <Prefab>(); List <Prefab> _primaryElementOres = new List <Prefab>(); List <Prefab> _otherEntities = new List <Prefab>(); HashSet <GameObject> _excludeEntities = new HashSet <GameObject>(); float num = 0f; float num2 = 0f; foreach (int selectedCell in SelectedCells) { float num3 = num; Vector2I vector2I = Grid.CellToXY(selectedCell); num = num3 + (float)vector2I.x; float num4 = num2; Vector2I vector2I2 = Grid.CellToXY(selectedCell); num2 = num4 + (float)vector2I2.y; } float x = num / (float)SelectedCells.Count; float y = num2 /= (float)SelectedCells.Count; int cell = Grid.PosToCell(new Vector3(x, y, 0f)); Grid.CellToXY(cell, out int x2, out int y2); for (int i = 0; i < SelectedCells.Count; i++) { int i2 = SelectedCells[i]; Grid.CellToXY(SelectedCells[i], out int x3, out int y3); Element element = ElementLoader.elements[Grid.ElementIdx[i2]]; string diseaseName = (Grid.DiseaseIdx[i2] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[i2]].Id; list.Add(new Cell(x3 - x2, y3 - y2, element.id, Grid.Temperature[i2], Grid.Mass[i2], diseaseName, Grid.DiseaseCount[i2], Grid.PreventFogOfWarReveal[SelectedCells[i]])); } for (int j = 0; j < Components.BuildingCompletes.Count; j++) { BuildingComplete buildingComplete = Components.BuildingCompletes[j]; if (!_excludeEntities.Contains(buildingComplete.gameObject)) { Grid.CellToXY(Grid.PosToCell(buildingComplete), out int x4, out int y4); if (SaveAllBuildings || SelectedCells.Contains(Grid.PosToCell(buildingComplete))) { int[] placementCells = buildingComplete.PlacementCells; string diseaseName2; foreach (int num5 in placementCells) { Grid.CellToXY(num5, out int x5, out int y5); diseaseName2 = ((Grid.DiseaseIdx[num5] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[num5]].Id); list.Add(new Cell(x5 - x2, y5 - y2, Grid.Element[num5].id, Grid.Temperature[num5], Grid.Mass[num5], diseaseName2, Grid.DiseaseCount[num5], false)); } Orientation rotation = Orientation.Neutral; Rotatable component = buildingComplete.gameObject.GetComponent <Rotatable>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { rotation = component.GetOrientation(); } SimHashes element2 = SimHashes.Void; float value = 280f; diseaseName2 = null; int disease_count = 0; PrimaryElement component2 = buildingComplete.GetComponent <PrimaryElement>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { element2 = component2.ElementID; value = component2.Temperature; diseaseName2 = ((component2.DiseaseIdx == 255) ? null : Db.Get().Diseases[component2.DiseaseIdx].Id); disease_count = component2.DiseaseCount; } List <Prefab.template_amount_value> list4 = new List <Prefab.template_amount_value>(); List <Prefab.template_amount_value> list5 = new List <Prefab.template_amount_value>(); foreach (AmountInstance amount in buildingComplete.gameObject.GetAmounts()) { list4.Add(new Prefab.template_amount_value(amount.amount.Id, amount.value)); } float num6 = 0f; Battery component3 = buildingComplete.GetComponent <Battery>(); if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { num6 = component3.JoulesAvailable; list5.Add(new Prefab.template_amount_value("joulesAvailable", num6)); } float num7 = 0f; Unsealable component4 = buildingComplete.GetComponent <Unsealable>(); if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { num7 = (float)(component4.facingRight ? 1 : 0); list5.Add(new Prefab.template_amount_value("sealedDoorDirection", num7)); } float num8 = 0f; LogicSwitch component5 = buildingComplete.GetComponent <LogicSwitch>(); if ((UnityEngine.Object)component5 != (UnityEngine.Object)null) { num8 = (float)(component5.IsSwitchedOn ? 1 : 0); list5.Add(new Prefab.template_amount_value("switchSetting", num8)); } x4 -= x2; y4 -= y2; value = Mathf.Clamp(value, 1f, 99999f); Prefab prefab = new Prefab(buildingComplete.PrefabID().Name, Prefab.Type.Building, x4, y4, element2, value, 0f, diseaseName2, disease_count, rotation, list4.ToArray(), list5.ToArray(), 0); Storage component6 = buildingComplete.gameObject.GetComponent <Storage>(); if ((UnityEngine.Object)component6 != (UnityEngine.Object)null) { foreach (GameObject item2 in component6.items) { float units = 0f; SimHashes element3 = SimHashes.Vacuum; float temp = 280f; string disease = null; int disease_count2 = 0; bool isOre = false; PrimaryElement component7 = item2.GetComponent <PrimaryElement>(); if ((UnityEngine.Object)component7 != (UnityEngine.Object)null) { units = component7.Units; element3 = component7.ElementID; temp = component7.Temperature; disease = ((component7.DiseaseIdx == 255) ? null : Db.Get().Diseases[component7.DiseaseIdx].Id); disease_count2 = component7.DiseaseCount; } float rotAmount = 0f; Rottable.Instance sMI = item2.gameObject.GetSMI <Rottable.Instance>(); if (sMI != null) { rotAmount = sMI.RotValue; } ElementChunk component8 = item2.GetComponent <ElementChunk>(); if ((UnityEngine.Object)component8 != (UnityEngine.Object)null) { isOre = true; } StorageItem storageItem = new StorageItem(item2.PrefabID().Name, units, temp, element3, disease, disease_count2, isOre); if (sMI != null) { storageItem.rottable.rotAmount = rotAmount; } prefab.AssignStorage(storageItem); _excludeEntities.Add(item2); } } list2.Add(prefab); _excludeEntities.Add(buildingComplete.gameObject); } } } for (int l = 0; l < list2.Count; l++) { Prefab prefab2 = list2[l]; int x6 = prefab2.location_x + x2; int y6 = prefab2.location_y + y2; int cell2 = Grid.XYToCell(x6, y6); switch (prefab2.id) { default: prefab2.connections = 0; break; case "Wire": case "InsulatedWire": case "HighWattageWire": prefab2.connections = (int)Game.Instance.electricalConduitSystem.GetConnections(cell2, true); break; case "GasConduit": case "InsulatedGasConduit": prefab2.connections = (int)Game.Instance.gasConduitSystem.GetConnections(cell2, true); break; case "LiquidConduit": case "InsulatedLiquidConduit": prefab2.connections = (int)Game.Instance.liquidConduitSystem.GetConnections(cell2, true); break; case "LogicWire": prefab2.connections = (int)Game.Instance.logicCircuitSystem.GetConnections(cell2, true); break; } } for (int m = 0; m < Components.Pickupables.Count; m++) { if (Components.Pickupables[m].gameObject.activeSelf) { Pickupable pickupable = Components.Pickupables[m]; if (!_excludeEntities.Contains(pickupable.gameObject)) { int num9 = Grid.PosToCell(pickupable); if ((SaveAllPickups || SelectedCells.Contains(num9)) && !(bool)Components.Pickupables[m].gameObject.GetComponent <MinionBrain>()) { Grid.CellToXY(num9, out int x7, out int y7); x7 -= x2; y7 -= y2; SimHashes element4 = SimHashes.Void; float temperature = 280f; float units2 = 1f; string disease2 = null; int disease_count3 = 0; float rotAmount2 = 0f; Rottable.Instance sMI2 = pickupable.gameObject.GetSMI <Rottable.Instance>(); if (sMI2 != null) { rotAmount2 = sMI2.RotValue; } PrimaryElement component9 = pickupable.gameObject.GetComponent <PrimaryElement>(); if ((UnityEngine.Object)component9 != (UnityEngine.Object)null) { element4 = component9.ElementID; units2 = component9.Units; temperature = component9.Temperature; disease2 = ((component9.DiseaseIdx == 255) ? null : Db.Get().Diseases[component9.DiseaseIdx].Id); disease_count3 = component9.DiseaseCount; } ElementChunk component10 = pickupable.gameObject.GetComponent <ElementChunk>(); if ((UnityEngine.Object)component10 != (UnityEngine.Object)null) { Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Ore, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0); _primaryElementOres.Add(item); } else { Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Pickupable, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0); item.rottable = new TemplateClasses.Rottable(); item.rottable.rotAmount = rotAmount2; list3.Add(item); } _excludeEntities.Add(pickupable.gameObject); } } } } GetEntities(Components.Crops.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities(Components.Health.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities(Components.Harvestables.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities(Components.Edibles.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities <Geyser>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities <OccupyArea>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); GetEntities <FogOfWarMask>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities); TemplateContainer templateContainer = new TemplateContainer(); templateContainer.Init(list, list2, list3, _primaryElementOres, _otherEntities); return(templateContainer); }