private static bool Prefix(OxygenBreather __instance, ref SimHashes __result, ref int cell, ref CellOffset[] offsets) { //Debug.Log(" === AmphibiousMod_OxygenBreather_GetBreathableElementAtCell === "); Klei.AI.Traits traits = __instance.gameObject.GetComponent <Klei.AI.Traits>(); bool flag = traits.GetTraitIds().Contains("Amphibious"); //Debug.Log(" === AmphibiousMod_OxygenBreather_GetBreathableElementAtCell === " + flag); if (!flag) { return(true); } if (offsets == null) { offsets = __instance.breathableCells; } //this.GetMouthCellAtCell(cell, offsets); int mouthCellAtCell = (int)GetMouthCellAtCellM.Invoke(__instance, new object[] { cell, offsets }); if (!Grid.IsValidCell(mouthCellAtCell)) { __result = SimHashes.Vacuum; return(false); } Element element = Grid.Element[mouthCellAtCell]; __result = ((!element.IsGas || !element.HasTag(GameTags.Breathable)) && (!element.IsLiquid || !element.HasTag(GameTags.AnyWater)) || !(Grid.Mass[mouthCellAtCell] > __instance.noOxygenThreshold)) ? SimHashes.Vacuum : element.id; return(false); }
public Instance(IStateMachineTarget master) : base(master) { breath = Db.Get().Amounts.Breath.Lookup(master.gameObject); query = new SafetyQuery(Game.Instance.safetyConditions.RecoverBreathChecker, GetComponent <KMonoBehaviour>(), 2147483647); navigator = GetComponent <Navigator>(); breather = GetComponent <OxygenBreather>(); }
public void OnSetOxygenBreather(OxygenBreather oxygen_breather) { suffocationMonitor = new SuffocationMonitor.Instance(oxygen_breather); suffocationMonitor.StartSM(); safeCellMonitor = new SafeCellMonitor.Instance(oxygen_breather); safeCellMonitor.StartSM(); oxygenBreather = oxygen_breather; }
public static void Postfix(OxygenBreather __instance) { if (OxygenNotNeededConfigChecker.ForceLoad || CustomGameSettings.Instance.GetCurrentQualitySetting(OxygenNotNeededPatches.WorldRequiresOxygen).id == "Enabled") { KSelectable component = __instance.GetComponent <KSelectable>(); component.RemoveStatusItem(Db.Get().DuplicantStatusItems.BreathingO2); component.RemoveStatusItem(Db.Get().DuplicantStatusItems.EmittingCO2); } }
public Context(KMonoBehaviour cmp) { cell = Grid.PosToCell(cmp); navigator = cmp.GetComponent <Navigator>(); oxygenBreather = cmp.GetComponent <OxygenBreather>(); minionBrain = cmp.GetComponent <MinionBrain>(); temperatureTransferer = cmp.GetComponent <SimTemperatureTransfer>(); primaryElement = cmp.GetComponent <PrimaryElement>(); }
public bool ConsumeGas(OxygenBreather oxygen_breather, float gas_consumed) { SimHashes getBreathableElement = oxygen_breather.GetBreathableElement; if (getBreathableElement == SimHashes.Vacuum) { return(false); } HandleVector <Game.ComplexCallbackInfo <Sim.MassConsumedCallback> > .Handle handle = Game.Instance.massConsumedCallbackManager.Add(OnSimConsumeCallback, this, "GasBreatherFromWorldProvider"); SimMessages.ConsumeMass(oxygen_breather.mouthCell, getBreathableElement, gas_consumed, 3, handle.index); return(true); }
public Instance(IStateMachineTarget master) : base(master) { sicknesses = master.GetComponent <MinionModifiers>().sicknesses; primaryElement = master.GetComponent <PrimaryElement>(); traits = master.GetComponent <Traits>(); lastDiseaseSources = new Dictionary <HashedString, DiseaseSourceInfo>(); lastExposureTime = new Dictionary <HashedString, float>(); inhaleExposureTick = new Dictionary <HashedString, InhaleTickInfo>(); GameClock.Instance.Subscribe(-722330267, OnNightTime); OxygenBreather component = GetComponent <OxygenBreather>(); component.onSimConsume = (Action <Sim.MassConsumedCallback>)Delegate.Combine(component.onSimConsume, new Action <Sim.MassConsumedCallback>(OnAirConsumed)); }
public static void Postfix(ref SuffocationMonitor.Instance __instance, ref OxygenBreather oxygen_breather) { var minionIdentity = oxygen_breather.gameObject.GetComponent <MinionIdentity>(); if (minionIdentity.GetComponent <Traits>().HasTrait("DiversLung")) { __instance.holdingbreath.SetValue(__instance.holdingbreath.Value * 3f / 4f); } if (minionIdentity.GetComponent <Traits>().HasTrait("MouthBreather")) { __instance.holdingbreath.SetValue(__instance.holdingbreath.Value * 2); } if (minionIdentity.GetComponent <Traits>().HasTrait("DeeperDiversLungs")) { __instance.holdingbreath.SetValue(__instance.holdingbreath.Value / 2); } }
public override void Update() { if ((Object)breather == (Object)null) { breather = GetComponent <OxygenBreather>(); } bool flag = isBreathable; isBreathable = breather.IsBreathableElement; if (isBreathable != flag) { if (isBreathable) { Trigger(99949694, null); } else { Trigger(-1189351068, null); } } }
private void CreateStatusItems() { Func <string, object, string> resolveStringCallback = delegate(string str, object data) { Workable workable3 = (Workable)data; if ((UnityEngine.Object)workable3 != (UnityEngine.Object)null) { str = str.Replace("{Target}", workable3.GetComponent <KSelectable>().GetName()); } return(str); }; Func <string, object, string> resolveStringCallback2 = delegate(string str, object data) { Workable workable2 = (Workable)data; if ((UnityEngine.Object)workable2 != (UnityEngine.Object)null) { str = str.Replace("{Target}", workable2.GetComponent <KSelectable>().GetName()); ComplexFabricatorWorkable complexFabricatorWorkable = workable2 as ComplexFabricatorWorkable; if ((UnityEngine.Object)complexFabricatorWorkable != (UnityEngine.Object)null) { ComplexRecipe currentWorkingOrder = complexFabricatorWorkable.CurrentWorkingOrder; if (currentWorkingOrder != null) { str = str.Replace("{Item}", currentWorkingOrder.FirstResult.ProperName()); } } } return(str); }; BedUnreachable = CreateStatusItem("BedUnreachable", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); BedUnreachable.AddNotification(null, null, null, 0f); DailyRationLimitReached = CreateStatusItem("DailyRationLimitReached", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); DailyRationLimitReached.AddNotification(null, null, null, 0f); HoldingBreath = CreateStatusItem("HoldingBreath", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Hungry = CreateStatusItem("Hungry", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Unhappy = CreateStatusItem("Unhappy", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Unhappy.AddNotification(null, null, null, 0f); NervousBreakdown = CreateStatusItem("NervousBreakdown", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); NervousBreakdown.AddNotification(null, null, null, 0f); NoRationsAvailable = CreateStatusItem("NoRationsAvailable", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); PendingPacification = CreateStatusItem("PendingPacification", "DUPLICANTS", "status_item_pending_pacification", StatusItem.IconType.Custom, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); QuarantineAreaUnassigned = CreateStatusItem("QuarantineAreaUnassigned", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); QuarantineAreaUnassigned.AddNotification(null, null, null, 0f); QuarantineAreaUnreachable = CreateStatusItem("QuarantineAreaUnreachable", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); QuarantineAreaUnreachable.AddNotification(null, null, null, 0f); Quarantined = CreateStatusItem("Quarantined", "DUPLICANTS", "status_item_quarantined", StatusItem.IconType.Custom, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); RationsUnreachable = CreateStatusItem("RationsUnreachable", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); RationsUnreachable.AddNotification(null, null, null, 0f); RationsNotPermitted = CreateStatusItem("RationsNotPermitted", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); RationsNotPermitted.AddNotification(null, null, null, 0f); Rotten = CreateStatusItem("Rotten", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Starving = CreateStatusItem("Starving", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); Starving.AddNotification(null, null, null, 0f); Suffocating = CreateStatusItem("Suffocating", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.DuplicantThreatening, false, OverlayModes.None.ID, true, 2); Suffocating.AddNotification(null, null, null, 0f); Tired = CreateStatusItem("Tired", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Idle = CreateStatusItem("Idle", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Idle.AddNotification(null, null, null, 0f); Pacified = CreateStatusItem("Pacified", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Dead = CreateStatusItem("Dead", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Dead.resolveStringCallback = delegate(string str, object data) { Death death = (Death)data; return(str.Replace("{Death}", death.Name)); }; MoveToSuitNotRequired = CreateStatusItem("MoveToSuitNotRequired", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); DroppingUnusedInventory = CreateStatusItem("DroppingUnusedInventory", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); MovingToSafeArea = CreateStatusItem("MovingToSafeArea", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); ToiletUnreachable = CreateStatusItem("ToiletUnreachable", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); ToiletUnreachable.AddNotification(null, null, null, 0f); NoUsableToilets = CreateStatusItem("NoUsableToilets", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); NoUsableToilets.AddNotification(null, null, null, 0f); NoToilets = CreateStatusItem("NoToilets", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); NoToilets.AddNotification(null, null, null, 0f); BreathingO2 = CreateStatusItem("BreathingO2", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 130); BreathingO2.resolveStringCallback = delegate(string str, object data) { OxygenBreather oxygenBreather2 = (OxygenBreather)data; float averageRate = Game.Instance.accumulators.GetAverageRate(oxygenBreather2.O2Accumulator); return(str.Replace("{ConsumptionRate}", GameUtil.GetFormattedMass(0f - averageRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"))); }; EmittingCO2 = CreateStatusItem("EmittingCO2", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 130); EmittingCO2.resolveStringCallback = delegate(string str, object data) { OxygenBreather oxygenBreather = (OxygenBreather)data; return(str.Replace("{EmittingRate}", GameUtil.GetFormattedMass(oxygenBreather.CO2EmitRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"))); }; Vomiting = CreateStatusItem("Vomiting", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Coughing = CreateStatusItem("Coughing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); LowOxygen = CreateStatusItem("LowOxygen", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); LowOxygen.AddNotification(null, null, null, 0f); RedAlert = CreateStatusItem("RedAlert", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Sleeping = CreateStatusItem("Sleeping", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Sleeping.resolveTooltipCallback = delegate(string str, object data) { if (data is SleepChore.StatesInstance) { SleepChore.StatesInstance statesInstance2 = (SleepChore.StatesInstance)data; string stateChangeNoiseSource = statesInstance2.stateChangeNoiseSource; if (!string.IsNullOrEmpty(stateChangeNoiseSource)) { string text5 = DUPLICANTS.STATUSITEMS.SLEEPING.TOOLTIP; text5 = text5.Replace("{Disturber}", stateChangeNoiseSource); str += text5; } } return(str); }; SleepingInterruptedByNoise = CreateStatusItem("SleepingInterruptedByNoise", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); SleepingInterruptedByLight = CreateStatusItem("SleepingInterruptedByLight", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Eating = CreateStatusItem("Eating", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Eating.resolveStringCallback = resolveStringCallback; Digging = CreateStatusItem("Digging", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Cleaning = CreateStatusItem("Cleaning", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Cleaning.resolveStringCallback = resolveStringCallback; PickingUp = CreateStatusItem("PickingUp", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); PickingUp.resolveStringCallback = resolveStringCallback; Mopping = CreateStatusItem("Mopping", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Cooking = CreateStatusItem("Cooking", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Cooking.resolveStringCallback = resolveStringCallback2; Mushing = CreateStatusItem("Mushing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Mushing.resolveStringCallback = resolveStringCallback2; Researching = CreateStatusItem("Researching", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Researching.resolveStringCallback = delegate(string str, object data) { TechInstance activeResearch = Research.Instance.GetActiveResearch(); if (activeResearch != null) { return(str.Replace("{Tech}", activeResearch.tech.Name)); } return(str); }; Tinkering = CreateStatusItem("Tinkering", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Tinkering.resolveStringCallback = delegate(string str, object data) { Tinkerable tinkerable = (Tinkerable)data; if ((UnityEngine.Object)tinkerable != (UnityEngine.Object)null) { return(string.Format(str, tinkerable.tinkerMaterialTag.ProperName())); } return(str); }; Storing = CreateStatusItem("Storing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Storing.resolveStringCallback = delegate(string str, object data) { Workable workable = (Workable)data; if ((UnityEngine.Object)workable != (UnityEngine.Object)null && (UnityEngine.Object)workable.worker != (UnityEngine.Object)null) { KSelectable component = workable.GetComponent <KSelectable>(); if ((bool)component) { str = str.Replace("{Target}", component.GetName()); } Pickupable pickupable = workable.worker.workCompleteData as Pickupable; if ((UnityEngine.Object)workable.worker != (UnityEngine.Object)null && (bool)pickupable) { KSelectable component2 = pickupable.GetComponent <KSelectable>(); if ((bool)component2) { str = str.Replace("{Item}", component2.GetName()); } } } return(str); }; Building = CreateStatusItem("Building", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Building.resolveStringCallback = resolveStringCallback; Equipping = CreateStatusItem("Equipping", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Equipping.resolveStringCallback = resolveStringCallback; WarmingUp = CreateStatusItem("WarmingUp", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); WarmingUp.resolveStringCallback = resolveStringCallback; GeneratingPower = CreateStatusItem("GeneratingPower", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); GeneratingPower.resolveStringCallback = resolveStringCallback; Harvesting = CreateStatusItem("Harvesting", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Harvesting.resolveStringCallback = resolveStringCallback; Uprooting = CreateStatusItem("Uprooting", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Uprooting.resolveStringCallback = resolveStringCallback; Emptying = CreateStatusItem("Emptying", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Emptying.resolveStringCallback = resolveStringCallback; Toggling = CreateStatusItem("Toggling", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Toggling.resolveStringCallback = resolveStringCallback; Deconstructing = CreateStatusItem("Deconstructing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Deconstructing.resolveStringCallback = resolveStringCallback; Disinfecting = CreateStatusItem("Disinfecting", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Disinfecting.resolveStringCallback = resolveStringCallback; Upgrading = CreateStatusItem("Upgrading", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Upgrading.resolveStringCallback = resolveStringCallback; Fabricating = CreateStatusItem("Fabricating", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Fabricating.resolveStringCallback = resolveStringCallback2; Processing = CreateStatusItem("Processing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Processing.resolveStringCallback = resolveStringCallback2; Clearing = CreateStatusItem("Clearing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Clearing.resolveStringCallback = resolveStringCallback; GeneratingPower = CreateStatusItem("GeneratingPower", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); GeneratingPower.resolveStringCallback = resolveStringCallback; Cold = CreateStatusItem("Cold", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Cold.resolveTooltipCallback = delegate(string str, object data) { str = str.Replace("{StressModification}", GameUtil.GetFormattedPercent(Db.Get().effects.Get("ColdAir").SelfModifiers[0].Value, GameUtil.TimeSlice.PerCycle)); float dtu_s2 = ((ExternalTemperatureMonitor.Instance)data).temperatureTransferer.average_kilowatts_exchanged.GetWeightedAverage * 1000f; str = str.Replace("{currentTransferWattage}", GameUtil.GetFormattedHeatEnergyRate(dtu_s2, GameUtil.HeatEnergyFormatterUnit.Automatic)); AttributeInstance attributeInstance3 = ((ExternalTemperatureMonitor.Instance)data).attributes.Get("ThermalConductivityBarrier"); string text3 = "<b>" + attributeInstance3.GetFormattedValue() + "</b>"; for (int j = 0; j != attributeInstance3.Modifiers.Count; j++) { AttributeModifier attributeModifier2 = attributeInstance3.Modifiers[j]; text3 += "\n"; string text4 = text3; text3 = text4 + " • " + attributeModifier2.GetDescription() + " <b>" + attributeModifier2.GetFormattedString(attributeInstance3.gameObject) + "</b>"; } str = str.Replace("{conductivityBarrier}", text3); return(str); }; Hot = CreateStatusItem("Hot", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); Hot.resolveTooltipCallback = delegate(string str, object data) { str = str.Replace("{StressModification}", GameUtil.GetFormattedPercent(Db.Get().effects.Get("WarmAir").SelfModifiers[0].Value, GameUtil.TimeSlice.PerCycle)); float dtu_s = ((ExternalTemperatureMonitor.Instance)data).temperatureTransferer.average_kilowatts_exchanged.GetWeightedAverage * 1000f; str = str.Replace("{currentTransferWattage}", GameUtil.GetFormattedHeatEnergyRate(dtu_s, GameUtil.HeatEnergyFormatterUnit.Automatic)); AttributeInstance attributeInstance2 = ((ExternalTemperatureMonitor.Instance)data).attributes.Get("ThermalConductivityBarrier"); string text = "<b>" + attributeInstance2.GetFormattedValue() + "</b>"; for (int i = 0; i != attributeInstance2.Modifiers.Count; i++) { AttributeModifier attributeModifier = attributeInstance2.Modifiers[i]; text += "\n"; string text2 = text; text = text2 + " • " + attributeModifier.GetDescription() + " <b>" + attributeModifier.GetFormattedString(attributeInstance2.gameObject) + "</b>"; } str = str.Replace("{conductivityBarrier}", text); return(str); }; BodyRegulatingHeating = CreateStatusItem("BodyRegulatingHeating", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); BodyRegulatingHeating.resolveStringCallback = delegate(string str, object data) { WarmBlooded.StatesInstance statesInstance = (WarmBlooded.StatesInstance)data; return(str.Replace("{TempDelta}", GameUtil.GetFormattedTemperature(statesInstance.TemperatureDelta, GameUtil.TimeSlice.PerSecond, GameUtil.TemperatureInterpretation.Relative, true, false))); }; BodyRegulatingCooling = CreateStatusItem("BodyRegulatingCooling", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); BodyRegulatingCooling.resolveStringCallback = BodyRegulatingHeating.resolveStringCallback; EntombedChore = CreateStatusItem("EntombedChore", "DUPLICANTS", "status_item_entombed", StatusItem.IconType.Custom, NotificationType.DuplicantThreatening, false, OverlayModes.None.ID, true, 2); EntombedChore.AddNotification(null, null, null, 0f); EarlyMorning = CreateStatusItem("EarlyMorning", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); NightTime = CreateStatusItem("NightTime", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); PoorDecor = CreateStatusItem("PoorDecor", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); PoorQualityOfLife = CreateStatusItem("PoorQualityOfLife", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); PoorFoodQuality = CreateStatusItem("PoorFoodQuality", DUPLICANTS.STATUSITEMS.POOR_FOOD_QUALITY.NAME, DUPLICANTS.STATUSITEMS.POOR_FOOD_QUALITY.TOOLTIP, string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, 2); GoodFoodQuality = CreateStatusItem("GoodFoodQuality", DUPLICANTS.STATUSITEMS.GOOD_FOOD_QUALITY.NAME, DUPLICANTS.STATUSITEMS.GOOD_FOOD_QUALITY.TOOLTIP, string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, 2); Arting = CreateStatusItem("Arting", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Arting.resolveStringCallback = resolveStringCallback; SevereWounds = CreateStatusItem("SevereWounds", "DUPLICANTS", "status_item_broken", StatusItem.IconType.Custom, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); SevereWounds.AddNotification(null, null, null, 0f); Incapacitated = CreateStatusItem("Incapacitated", "DUPLICANTS", "status_item_broken", StatusItem.IconType.Custom, NotificationType.DuplicantThreatening, false, OverlayModes.None.ID, true, 2); Incapacitated.AddNotification(null, null, null, 0f); Incapacitated.resolveStringCallback = delegate(string str, object data) { IncapacitationMonitor.Instance instance = (IncapacitationMonitor.Instance)data; float bleedLifeTime = instance.GetBleedLifeTime(instance); str = str.Replace("{CauseOfIncapacitation}", instance.GetCauseOfIncapacitation().Name); return(str.Replace("{TimeUntilDeath}", GameUtil.GetFormattedTime(bleedLifeTime))); }; Relocating = CreateStatusItem("Relocating", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Relocating.resolveStringCallback = resolveStringCallback; Fighting = CreateStatusItem("Fighting", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); Fighting.AddNotification(null, null, null, 0f); Fleeing = CreateStatusItem("Fleeing", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); Fleeing.AddNotification(null, null, null, 0f); Stressed = CreateStatusItem("Stressed", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Stressed.AddNotification(null, null, null, 0f); LashingOut = CreateStatusItem("LashingOut", "DUPLICANTS", string.Empty, StatusItem.IconType.Exclamation, NotificationType.Bad, false, OverlayModes.None.ID, true, 2); LashingOut.AddNotification(null, null, null, 0f); LowImmunity = CreateStatusItem("LowImmunity", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 2); LowImmunity.AddNotification(null, null, null, 0f); Studying = CreateStatusItem("Studying", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, true, 2); Socializing = CreateStatusItem("Socializing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Good, false, OverlayModes.None.ID, true, 2); Dancing = CreateStatusItem("Dancing", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Good, false, OverlayModes.None.ID, true, 2); Gaming = CreateStatusItem("Gaming", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Good, false, OverlayModes.None.ID, true, 2); Mingling = CreateStatusItem("Mingling", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Good, false, OverlayModes.None.ID, true, 2); ContactWithGerms = CreateStatusItem("ContactWithGerms", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, true, OverlayModes.Disease.ID, true, 2); ContactWithGerms.resolveStringCallback = delegate(string str, object data) { GermExposureMonitor.ExposureStatusData exposureStatusData4 = (GermExposureMonitor.ExposureStatusData)data; string name2 = Db.Get().Sicknesses.Get(exposureStatusData4.exposure_type.sickness_id).Name; str = str.Replace("{Sickness}", name2); return(str); }; ContactWithGerms.statusItemClickCallback = delegate(object data) { GermExposureMonitor.ExposureStatusData exposureStatusData3 = (GermExposureMonitor.ExposureStatusData)data; Vector3 lastExposurePosition2 = exposureStatusData3.owner.GetLastExposurePosition(exposureStatusData3.exposure_type.germ_id); CameraController.Instance.CameraGoTo(lastExposurePosition2, 2f, true); if (OverlayScreen.Instance.mode == OverlayModes.None.ID) { OverlayScreen.Instance.ToggleOverlay(OverlayModes.Disease.ID, true); } }; ExposedToGerms = CreateStatusItem("ExposedToGerms", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, true, OverlayModes.Disease.ID, true, 2); ExposedToGerms.resolveStringCallback = delegate(string str, object data) { GermExposureMonitor.ExposureStatusData exposureStatusData2 = (GermExposureMonitor.ExposureStatusData)data; string name = Db.Get().Sicknesses.Get(exposureStatusData2.exposure_type.sickness_id).Name; AttributeInstance attributeInstance = Db.Get().Attributes.GermResistance.Lookup(exposureStatusData2.owner.gameObject); string lastDiseaseSource = exposureStatusData2.owner.GetLastDiseaseSource(exposureStatusData2.exposure_type.germ_id); GermExposureMonitor.Instance sMI = exposureStatusData2.owner.GetSMI <GermExposureMonitor.Instance>(); float num = (float)exposureStatusData2.exposure_type.base_resistance + GERM_EXPOSURE.EXPOSURE_TIER_RESISTANCE_BONUSES[0]; float totalValue = attributeInstance.GetTotalValue(); float resistanceToExposureType = sMI.GetResistanceToExposureType(exposureStatusData2.exposure_type, -1f); float contractionChance = GermExposureMonitor.GetContractionChance(resistanceToExposureType); float exposureTier = sMI.GetExposureTier(exposureStatusData2.exposure_type.germ_id); float num2 = GERM_EXPOSURE.EXPOSURE_TIER_RESISTANCE_BONUSES[(int)exposureTier - 1] - GERM_EXPOSURE.EXPOSURE_TIER_RESISTANCE_BONUSES[0]; str = str.Replace("{Severity}", DUPLICANTS.STATUSITEMS.EXPOSEDTOGERMS.EXPOSURE_TIERS[(int)exposureTier - 1]); str = str.Replace("{Sickness}", name); str = str.Replace("{Source}", lastDiseaseSource); str = str.Replace("{Base}", GameUtil.GetFormattedSimple(num, GameUtil.TimeSlice.None, null)); str = str.Replace("{Dupe}", GameUtil.GetFormattedSimple(totalValue, GameUtil.TimeSlice.None, null)); str = str.Replace("{Total}", GameUtil.GetFormattedSimple(resistanceToExposureType, GameUtil.TimeSlice.None, null)); str = str.Replace("{ExposureLevelBonus}", GameUtil.GetFormattedSimple(num2, GameUtil.TimeSlice.None, null)); str = str.Replace("{Chance}", GameUtil.GetFormattedPercent(contractionChance * 100f, GameUtil.TimeSlice.None)); return(str); }; ExposedToGerms.statusItemClickCallback = delegate(object data) { GermExposureMonitor.ExposureStatusData exposureStatusData = (GermExposureMonitor.ExposureStatusData)data; Vector3 lastExposurePosition = exposureStatusData.owner.GetLastExposurePosition(exposureStatusData.exposure_type.germ_id); CameraController.Instance.CameraGoTo(lastExposurePosition, 2f, true); if (OverlayScreen.Instance.mode == OverlayModes.None.ID) { OverlayScreen.Instance.ToggleOverlay(OverlayModes.Disease.ID, true); } }; LightWorkEfficiencyBonus = CreateStatusItem("LightWorkEfficiencyBonus", "DUPLICANTS", string.Empty, StatusItem.IconType.Info, NotificationType.Good, false, OverlayModes.None.ID, true, 2); }
private static bool Prefix(GasBreatherFromWorldProvider __instance, ref bool __result, ref OxygenBreather oxygen_breather, ref float gas_consumed) { //Debug.Log(" === AmphibiousMod_GasBreatherFromWorldProvider_ConsumeGas === "); Klei.AI.Traits traits = oxygen_breather.gameObject.GetComponent <Klei.AI.Traits>(); bool flag = traits.GetTraitIds().Contains("Amphibious"); if (!flag) { return(true); } SimHashes getBreathableElement = oxygen_breather.GetBreathableElement; if (getBreathableElement == SimHashes.Vacuum) { __result = false; return(false); } //HandleVector<Game.ComplexCallbackInfo<Sim.MassConsumedCallback>>.Handle handle = Game.Instance.massConsumedCallbackManager.Add(OnSimConsumeCallback, __instance, "GasBreatherFromWorldProvider"); //SimMessages.ConsumeMass(oxygen_breather.mouthCell, getBreathableElement, gas_consumed/5f, 3, handle.index); SimMessages.ConsumeMass(oxygen_breather.mouthCell, getBreathableElement, gas_consumed / 5f, 1); __result = true; return(false); }
private static void StubSetGasProvider(OxygenBreather breather, OxygenBreather.IGasProvider gas_provider) { }
private static bool Prefix(OxygenBreather __instance, ref float dt) { dt = 0; return(true); }
public BreathableCellQuery Reset(Brain brain) { breather = brain.GetComponent <OxygenBreather>(); return(this); }
public static void Prefix(OxygenBreather __instance, float dt) { //Debug.Log("Patch o2toco2 " + dt.ToString()); __instance.O2toCO2conversion = 1; __instance.minCO2ToEmit = 0.6f; }
public void OnClearOxygenBreather(OxygenBreather oxygen_breather) { suffocationMonitor.StopSM("Removed gas provider"); safeCellMonitor.StopSM("Removed gas provider"); }
private static void Postfix(OxygenBreather __instance, float dt) { ChemicalBurnMonitor chemicalBurnMonitor = __instance.gameObject.AddOrGet <ChemicalBurnMonitor>(); chemicalBurnMonitor.CheckForCorrosiveChemicals(dt); }
public GameObject CreatePrefab() { string name = DUPLICANTS.MODIFIERS.BASEDUPLICANT.NAME; GameObject gameObject = EntityTemplates.CreateEntity(ID, name, true); gameObject.AddOrGet <StateMachineController>(); MinionModifiers modifiers = gameObject.AddOrGet <MinionModifiers>(); AddMinionAmounts(modifiers); AddMinionTraits(name, modifiers); gameObject.AddOrGet <MinionBrain>(); gameObject.AddOrGet <KPrefabID>().AddTag(GameTags.DupeBrain, false); gameObject.AddOrGet <Worker>(); gameObject.AddOrGet <ChoreConsumer>(); Storage storage = gameObject.AddOrGet <Storage>(); storage.fxPrefix = Storage.FXPrefix.PickedUp; storage.dropOnLoad = true; storage.SetDefaultStoredItemModifiers(new List <Storage.StoredItemModifier> { Storage.StoredItemModifier.Preserve, Storage.StoredItemModifier.Seal }); gameObject.AddOrGet <Health>(); OxygenBreather oxygenBreather = gameObject.AddOrGet <OxygenBreather>(); oxygenBreather.O2toCO2conversion = 0.02f; oxygenBreather.lowOxygenThreshold = 0.52f; oxygenBreather.noOxygenThreshold = 0.05f; oxygenBreather.mouthOffset = new Vector2f(0.25f, 0.7f); oxygenBreather.minCO2ToEmit = 0.02f; oxygenBreather.breathableCells = new CellOffset[6] { new CellOffset(0, 0), new CellOffset(0, 1), new CellOffset(1, 1), new CellOffset(-1, 1), new CellOffset(1, 0), new CellOffset(-1, 0) }; gameObject.AddOrGet <WarmBlooded>(); gameObject.AddOrGet <MinionIdentity>(); GridVisibility gridVisibility = gameObject.AddOrGet <GridVisibility>(); gridVisibility.radius = 30f; gridVisibility.innerRadius = 20f; gameObject.AddOrGet <MiningSounds>(); gameObject.AddOrGet <SaveLoadRoot>(); gameObject.AddOrGet <AntiCluster>(); Navigator navigator = gameObject.AddOrGet <Navigator>(); navigator.NavGridName = "MinionNavGrid"; navigator.CurrentNavType = NavType.Floor; KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.isMovable = true; kBatchedAnimController.sceneLayer = Grid.SceneLayer.Move; kBatchedAnimController.AnimFiles = new KAnimFile[8] { Assets.GetAnim("body_comp_default_kanim"), Assets.GetAnim("anim_construction_default_kanim"), Assets.GetAnim("anim_idles_default_kanim"), Assets.GetAnim("anim_loco_firepole_kanim"), Assets.GetAnim("anim_loco_new_kanim"), Assets.GetAnim("anim_loco_tube_kanim"), Assets.GetAnim("anim_construction_firepole_kanim"), Assets.GetAnim("anim_construction_jetsuit_kanim") }; KBoxCollider2D kBoxCollider2D = gameObject.AddOrGet <KBoxCollider2D>(); kBoxCollider2D.offset = new Vector2(0f, 0.8f); kBoxCollider2D.size = new Vector2(1f, 1.5f); SnapOn snapOn = gameObject.AddOrGet <SnapOn>(); snapOn.snapPoints = new List <SnapOn.SnapPoint>(new SnapOn.SnapPoint[17] { new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"dig", buildFile = Assets.GetAnim("excavator_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"build", buildFile = Assets.GetAnim("constructor_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"fetchliquid", buildFile = Assets.GetAnim("water_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"paint", buildFile = Assets.GetAnim("painting_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"harvest", buildFile = Assets.GetAnim("plant_harvester_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"capture", buildFile = Assets.GetAnim("net_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"attack", buildFile = Assets.GetAnim("attack_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"pickup", buildFile = Assets.GetAnim("pickupdrop_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"store", buildFile = Assets.GetAnim("pickupdrop_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"disinfect", buildFile = Assets.GetAnim("plant_spray_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"tend", buildFile = Assets.GetAnim("plant_harvester_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "carry", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_chest" }, new SnapOn.SnapPoint { pointName = "build", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "remote", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "snapTo_neck", automatic = false, context = (HashedString)string.Empty, buildFile = Assets.GetAnim("helm_oxygen_kanim"), overrideSymbol = (HashedString)"snapTo_neck" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"powertinker", buildFile = Assets.GetAnim("electrician_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"specialistdig", buildFile = Assets.GetAnim("excavator_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" } }); gameObject.AddOrGet <Effects>(); gameObject.AddOrGet <Traits>(); gameObject.AddOrGet <AttributeLevels>(); gameObject.AddOrGet <AttributeConverters>(); PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>(); primaryElement.InternalTemperature = 310.15f; primaryElement.MassPerUnit = 30f; primaryElement.ElementID = SimHashes.Creature; gameObject.AddOrGet <ChoreProvider>(); gameObject.AddOrGetDef <DebugGoToMonitor.Def>(); gameObject.AddOrGetDef <SpeechMonitor.Def>(); gameObject.AddOrGetDef <BlinkMonitor.Def>(); gameObject.AddOrGetDef <ConversationMonitor.Def>(); gameObject.AddOrGet <Sensors>(); gameObject.AddOrGet <Chattable>(); gameObject.AddOrGet <FaceGraph>(); gameObject.AddOrGet <Accessorizer>(); gameObject.AddOrGet <Schedulable>(); LoopingSounds loopingSounds = gameObject.AddOrGet <LoopingSounds>(); loopingSounds.updatePosition = true; gameObject.AddOrGet <AnimEventHandler>(); FactionAlignment factionAlignment = gameObject.AddOrGet <FactionAlignment>(); factionAlignment.Alignment = FactionManager.FactionID.Duplicant; gameObject.AddOrGet <Weapon>(); gameObject.AddOrGet <RangedAttackable>(); gameObject.AddOrGet <CharacterOverlay>(); OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>(); occupyArea.objectLayers = new ObjectLayer[1]; occupyArea.ApplyToCells = false; occupyArea.OccupiedCellsOffsets = new CellOffset[2] { new CellOffset(0, 0), new CellOffset(0, 1) }; gameObject.AddOrGet <Pickupable>(); CreatureSimTemperatureTransfer creatureSimTemperatureTransfer = gameObject.AddOrGet <CreatureSimTemperatureTransfer>(); creatureSimTemperatureTransfer.SurfaceArea = 10f; creatureSimTemperatureTransfer.Thickness = 0.01f; gameObject.AddOrGet <SicknessTrigger>(); gameObject.AddOrGet <ClothingWearer>(); gameObject.AddOrGet <SuitEquipper>(); DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>(); decorProvider.baseRadius = 3f; decorProvider.isMovable = true; gameObject.AddOrGet <ConsumableConsumer>(); gameObject.AddOrGet <NoiseListener>(); gameObject.AddOrGet <MinionResume>(); DuplicantNoiseLevels.SetupNoiseLevels(); SetupLaserEffects(gameObject); SymbolOverrideController symbolOverrideController = SymbolOverrideControllerUtil.AddToPrefab(gameObject); symbolOverrideController.applySymbolOverridesEveryFrame = true; ConfigureSymbols(gameObject); return(gameObject); }
// changing oxygen breather to accumulate oxygen public static void Postfix(OxygenBreather __instance, ref float dt) { if (!__instance.gameObject.HasTag(GameTags.Dead)) { float num = Traverse.Create(__instance).Field("airConsumptionRate").Method("GetTotalValue").GetValue <float>() * dt; bool flag = Traverse.Create(__instance).Field("gasProvider").Method("ConsumeGas", __instance, num).GetValue <bool>(); if (flag) { // add oxygen to storage __instance.GetComponents <Storage>()[1].AddGasChunk(SimHashes.Oxygen, num, Traverse.Create(__instance).Field("temperature").Field("value").GetValue <float>(), byte.MaxValue, 0, false, true); if (Traverse.Create(__instance).Field("gasProvider").Method("ShouldEmitCO2").GetValue <bool>()) { float num2 = num * __instance.O2toCO2conversion; Game.Instance.accumulators.Accumulate(Traverse.Create(__instance).Field("co2Accumulator").GetValue <HandleVector <int> .Handle>(), num2); __instance.accumulatedCO2 += num2; if (__instance.accumulatedCO2 >= __instance.minCO2ToEmit) { GameObject o2Chunk = __instance.GetComponents <Storage>()[1].FindFirst(SimHashes.Oxygen.CreateTag()); PrimaryElement primaryElementO2 = o2Chunk.GetComponent <PrimaryElement>(); primaryElementO2.Mass -= o2_fraction_of_co2 * __instance.minCO2ToEmit; __instance.accumulatedCO2 -= __instance.minCO2ToEmit; Vector3 position = __instance.transform.GetPosition(); position.x += ((!Traverse.Create(__instance).Field("facing").GetValue <Facing>().GetFacing()) ? __instance.mouthOffset.x : (-__instance.mouthOffset.x)); position.y += __instance.mouthOffset.y; position.z -= 0.5f; CO2Manager.instance.SpawnBreath(position, __instance.minCO2ToEmit, Traverse.Create(__instance).Field("temperature").Field("value").GetValue <float>()); } } else if (Traverse.Create(__instance).Field("gasProvider").Method("ShouldStoreCO2").GetValue <bool>()) { Equippable equippable = __instance.GetComponent <SuitEquipper>().IsWearingAirtightSuit(); if (equippable != null) { float num3 = num * __instance.O2toCO2conversion; Game.Instance.accumulators.Accumulate(Traverse.Create(__instance).Field("co2Accumulator").GetValue <HandleVector <int> .Handle>(), num3); __instance.accumulatedCO2 += num3; if (__instance.accumulatedCO2 >= __instance.minCO2ToEmit) { GameObject o2Chunk = __instance.GetComponents <Storage>()[1].FindFirst(SimHashes.Oxygen.CreateTag()); PrimaryElement primaryElementO2 = o2Chunk.GetComponent <PrimaryElement>(); primaryElementO2.KeepZeroMassObject = true; // makes sure the mass doesn't go negative primaryElementO2.Mass -= o2_fraction_of_co2 * __instance.minCO2ToEmit; // subtract o2 in co2 from oxygen storage __instance.accumulatedCO2 -= __instance.minCO2ToEmit; equippable.GetComponent <Storage>().AddGasChunk(SimHashes.CarbonDioxide, __instance.minCO2ToEmit, Traverse.Create(__instance).Field("temperature").Field("value").GetValue <float>(), byte.MaxValue, 0, false, true); } } } } if (flag != Traverse.Create(__instance).Field("hasAir").GetValue <bool>()) { Traverse.Create(__instance).Field("hasAirTimer").Method("Start").GetValue(); if (Traverse.Create(__instance).Field("hasAirTimer").Method("TryStop", 2f).GetValue <bool>()) { Traverse.Create(__instance).Field("hasAir").SetValue(flag); } } else { Traverse.Create(__instance).Field("hasAirTimer").Method("Stop").GetValue(); } } }