public static void Postfix() { TechType tankSlot = Inventory.main.equipment.GetTechTypeInSlot("Tank"); if (GameModeUtils.RequiresOxygen() && Player.main.IsSwimming() && tankSlot == ScubaManifold.techType) { int photosynthesisTanks = Inventory.main.container.GetCount(O2TanksCore.PhotosynthesisSmallID) + Inventory.main.container.GetCount(O2TanksCore.PhotosynthesisTankID); int chemosynthesisTanks = Inventory.main.container.GetCount(O2TanksCore.ChemosynthesisTankID); if (photosynthesisTanks > 0) { float playerDepth = Ocean.main.GetDepthOf(Player.main.gameObject); float currentLight = DayNightCycle.main.GetLocalLightScalar(); float photosynthesisDepthCalc = (currentLight > 0.9f ? 0.9f : currentLight) * Time.deltaTime * (Config.multipleTanks ? photosynthesisTanks : 1) * (200f - playerDepth > 0f ? ((200 - playerDepth) / 200f) : 0); Player.main.oxygenMgr.AddOxygen(photosynthesisDepthCalc); } if (chemosynthesisTanks > 0) { float waterTemp = WaterTemperatureSimulation.main.GetTemperature(Player.main.transform.position); float chemosynthesisTempCalc = (waterTemp > 30f ? waterTemp : 0) * Time.deltaTime * 0.01f * (Config.multipleTanks ? chemosynthesisTanks : 1); Player.main.oxygenMgr.AddOxygen(chemosynthesisTempCalc); } } }
public static bool Prefix(ref NitrogenLevel __instance, Player player) { Inventory main = Inventory.main; TechType bodySlot = Inventory.main.equipment.GetTechTypeInSlot("Body"); TechType headSlot = Inventory.main.equipment.GetTechTypeInSlot("Head"); if (GameModeUtils.RequiresOxygen()) { float depthOf = Ocean.main.GetDepthOf(player.gameObject); if (__instance.nitrogenEnabled) { float modifier = 1f; if (depthOf > 0f) { if (bodySlot == ReinforcedSuitsCore.ReinforcedSuit3ID) { modifier = 0.55f; } else if ((bodySlot == ReinforcedSuitsCore.ReinforcedSuit2ID || bodySlot == ReinforcedSuitsCore.ReinforcedStillSuit) && depthOf <= 1300f) { modifier = 0.75f; } else if (bodySlot == TechType.ReinforcedDiveSuit && depthOf <= 800f) { modifier = 0.85f; } else if ((bodySlot == TechType.RadiationSuit || bodySlot == TechType.Stillsuit) && depthOf <= 500f) { modifier = 0.95f; } if (headSlot == TechType.Rebreather) { modifier -= 0.05f; } } float num = __instance.depthCurve.Evaluate(depthOf / 2048f); __instance.safeNitrogenDepth = UWE.Utils.Slerp(__instance.safeNitrogenDepth, depthOf, num * __instance.kBreathScalar * modifier); } if (crushEnabled && Player.main.GetDepthClass() == Ocean.DepthClass.Crush) { if (UnityEngine.Random.value < 0.5f) { float crushDepth = PlayerGetDepthClassPatcher.divingCrushDepth; if (depthOf > crushDepth) { DamagePlayer(depthOf - crushDepth); } } } } return(false); }
public static bool Prefix(ref NitrogenLevel __instance) { if (__instance.nitrogenEnabled && GameModeUtils.RequiresOxygen() && Time.timeScale > 0f) { float depthOf = Ocean.main.GetDepthOf(Player.main.gameObject); if (depthOf < __instance.safeNitrogenDepth - 10f && UnityEngine.Random.value < 0.0125f) { LiveMixin component = Player.main.gameObject.GetComponent <LiveMixin>(); float damage = 1f + damageScaler * (__instance.safeNitrogenDepth - depthOf) / 10f; if (component.health - damage > 0f) { component.TakeDamage(damage, default, DamageType.Normal, null);
public static bool Prefix(ref NitrogenLevel __instance, Player player) { if (GameModeUtils.RequiresOxygen() && !PrisonManager.IsInsideAquarium(player.gameObject.transform.position)) { float depthOf = Ocean.main.GetDepthOf(player.gameObject); // Player's personal crush depth if (crushEnabled) { if (Player.main.GetDepthClass() == Ocean.DepthClass.Crush) { if (!crushed) { ErrorMessage.AddMessage("Personal crush depth exceeded. Return to safe depth!"); crushed = true; } if (UnityEngine.Random.value < 0.5f) { float crushDepth = DeathRun.saveData.playerSave.crushDepth; if (depthOf > crushDepth) { float crush = depthOf - crushDepth; if (crush < 50) { DamagePlayer(4); } else if (crush < 100) { DamagePlayer(8); } else if (crush < 200) { DamagePlayer(16); } else { DamagePlayer(32); // "Okay, Sparky..." } } } } else { crushed = false; } } } return(false); }
private void Update() { TechType tankSlot = Inventory.main.equipment.GetTechTypeInSlot("Tank"); if (Player.main.IsSwimming() && GameModeUtils.RequiresOxygen()) { float playerDepth = Ocean.main.GetDepthOf(Player.main.gameObject); if ((tankSlot == O2TanksCore.PhotosynthesisSmallID || tankSlot == O2TanksCore.PhotosynthesisTankID) && playerDepth < 200f) { if (cachedDayNight == null) // Safety check { cachedDayNight = DayNightCycle.main; return; } float lightScalar = cachedDayNight.GetLocalLightScalar(); if (lightScalar > 0.9f) { lightScalar = 0.9f; } float percentage = (200f - playerDepth) / 200f; cachedOxygenManager.AddOxygen(Time.deltaTime * lightScalar * percentage); } if (tankSlot == O2TanksCore.ChemosynthesisTankID) { if (cachedTemp == null) // Safety check { cachedTemp = WaterTemperatureSimulation.main; return; } else { float waterTemp = cachedTemp.GetTemperature(Player.main.transform.position); if (waterTemp > 30f) { float oxygenAdded = waterTemp * Time.deltaTime * .01f; cachedOxygenManager.AddOxygen(oxygenAdded); } } } } }
public static void Postfix() { if (modCheck) { TechTypeHandler.TryGetModdedTechType("ScubaManifold", out scubaManifold); TechTypeHandler.TryGetModdedTechType("photosynthesissmalltank", out photosynthesisSmall); TechTypeHandler.TryGetModdedTechType("photosynthesistank", out photosynthesisTank); TechTypeHandler.TryGetModdedTechType("chemosynthesistank", out chemosynthesisTank); modCheck = false; } if (scubaManifold != TechType.None && photosynthesisSmall != TechType.None && photosynthesisTank != TechType.None && chemosynthesisTank != TechType.None) { var tankSlot = Inventory.main.equipment.GetTechTypeInSlot("Tank"); if (GameModeUtils.RequiresOxygen() && Player.main.IsSwimming() && tankSlot == scubaManifold) { var photosynthesisTanks = Inventory.main.container.GetCount(photosynthesisSmall) + Inventory.main.container.GetCount(photosynthesisTank); var chemosynthesisTanks = Inventory.main.container.GetCount(chemosynthesisTank); if (photosynthesisTanks > 0) { var playerDepth = #if SN1 Ocean.main.GetDepthOf(Player.main.gameObject); #else Ocean.GetDepthOf(Player.main.gameObject); #endif var currentLight = DayNightCycle.main.GetLocalLightScalar(); var photosynthesisDepthCalc = (currentLight > 0.9f ? 0.9f : currentLight) * Time.deltaTime * (Main.Config.multipleTanks ? photosynthesisTanks : 1) * (200f - playerDepth > 0f ? ((200 - playerDepth) / 200f) : 0); Player.main.oxygenMgr.AddOxygen(photosynthesisDepthCalc); } if (chemosynthesisTanks > 0) { var waterTemp = WaterTemperatureSimulation.main.GetTemperature(Player.main.transform.position); var chemosynthesisTempCalc = (waterTemp > 30f ? waterTemp : 0) * Time.deltaTime * 0.01f * (Main.Config.multipleTanks ? chemosynthesisTanks : 1); Player.main.oxygenMgr.AddOxygen(chemosynthesisTempCalc); } } } }