private static float GetDistance(PlayerDistanceTracker tracker) { // If the object is null, ship hasn't exploded yet or radius is too small if (!RadiationUtils.isSurfaceRadiationActive()) { return(tracker.distanceToPlayer); } // How deep the player is float playerDepth = Math.Max(0, -Player.main.transform.position.y); float radiationDepth = RadiationUtils.getRadiationDepth(); // If they are deeper than the radiation, return if (playerDepth > radiationDepth) { return(tracker.distanceToPlayer); } // When radiation is fixed, avoid a "long tail-off" near the surface if (RadiationUtils.isRadiationFixed()) { if (radiationDepth <= 15) { return(tracker.distanceToPlayer); } } // A % of how close they are to getting out of radiation float playerRadiationStrength = playerDepth / radiationDepth; //ErrorMessage.AddMessage("Player: " + playerDepth + " RadDepth: " + radiationDepth + " RadStr: " + playerRadiationStrength + " Dist: " + Math.Min(tracker.distanceToPlayer, tracker.maxDistance * playerRadiationStrength)); return(Math.Min(tracker.distanceToPlayer, tracker.maxDistance * playerRadiationStrength)); }
public static bool GetProvidesOxygen(PipeSurfaceFloater __instance, ref bool __result) { if (Config.FILTER_ANYWHERE.Equals(DeathRun.config.filterPumpRules)) { return(true); } if (Config.FILTER_RADIATION.Equals(DeathRun.config.filterPumpRules)) { if (!RadiationUtils.isInShipsRadiation(__instance.floater.transform)) { // Not in ship's hotzone radius (fairly big -- where radiation would normally be in vanilla game) return(true); } } else { // Not physically inside the Aurora string LDBiome = RadiationUtils.getPlayerBiome(); if (!LDBiome.Contains("CrashedShip")) { return(true); } } // Don't let it provide oxygen __result = false; return(false); }
/** * Checks if player is currently prevented from picking up food items on the island. */ private static bool GetPreventPickup(Transform transform) { // If we're always allowed island food, no need to trouble ourselves if (Config.ALWAYS.Equals(DeathRun.config.islandFood)) { return(false); } // If player is underwater, or is in a base or escape pod. Return false if (transform.position.y <= -1 || Player.main.IsInsideWalkable()) { return(false); } // If we're never allowed island food, then we're just never allowed it! if (Config.NEVER.Equals(DeathRun.config.islandFood)) { return(true); } // If the radiation can't be checked, or the ship hasn't exploded if (LeakingRadiation.main == null || !CrashedShipExploder.main.IsExploded()) { // Then it's before the ship exploded return(Config.AFTER.Equals(DeathRun.config.islandFood)); } // If radiation is still active return(RadiationUtils.isSurfaceRadiationActive()); }
/** * @return true if Transform is currently in radiation */ private static bool isTransformInRadiation(Transform transform) { if (transform == null) { return(false); } return(RadiationUtils.isInAnyRadiation(transform)); }
private static void ConsumeEnergy(UnityEngine.Transform transform, ref float amount) { if (!RadiationUtils.GetInAnyRadiation(transform)) { return; } amount *= EntryPoint.config.radiativePowerConsumptionMultiplier; }
private static void AddEnergy(UnityEngine.Transform transform, ref float amount) { if (!RadiationUtils.GetInAnyRadiation(transform)) { return; } amount *= Qpatch.config.radiativePowerAddMultiplier; }
/// <summary> /// Prevent PipeSurfaceFloater from providing oxygen when in close range /// </summary> public static bool GetProvidesOxygen(PipeSurfaceFloater __instance, ref bool __result) { if (!RadiationUtils.GetInShipsRadiation(__instance.floater.transform)) { // Not in a radiative hotzone return(true); } // Don't let it provide oxygen __result = false; return(false); }
public static bool isSurfaceAirPoisoned() { if (Config.BREATHABLE.Equals(DeathRun.config.surfaceAir)) { return(false); } if (Config.POISONED.Equals(DeathRun.config.surfaceAir)) { Inventory main2 = Inventory.main; if (main2 != null && main2.equipment != null && main2.equipment.GetCount(DeathRun.filterChip.TechType) > 0) { return(false); } return(true); } return(RadiationUtils.isRadiationActive()); }
/// <summary> /// If the player is in the outside air and there is radiation active /// </summary> private static bool GetPreventPickup(UnityEngine.Transform transform) { // If player is underwater, or is in a base or escape pod. Return false if (transform.position.y <= -1 || Player.main.IsInsideWalkable()) { return(false); } else // If the radiation can't be checked, or the ship hasn't exploded if (LeakingRadiation.main == null || !CrashedShipExploder.main.IsExploded()) { // Then it's before the ship exploded return(EntryPoint.config.preventPreRadiativeFoodPickup); } else if (!EntryPoint.config.preventRadiativeFoodPickup) // If they can pickup after ship has exploded, return early { return(false); } // If radiation is still active return(RadiationUtils.GetSurfaceRadiationActive()); }
private static float GetDistance(PlayerDistanceTracker tracker) { // If the object is null, ship hasn't exploded yet or radius is too small if (!RadiationUtils.GetSurfaceRadiationActive()) { return(tracker.distanceToPlayer); } // How deep the player is float playerDepth = Math.Max(0, -Player.main.transform.position.y); float radiationDepth = RadiationUtils.GetRadiationDepth(); // If they are deeper than the radiation, return if (playerDepth > radiationDepth) { return(tracker.distanceToPlayer); } // A % of how close they are to getting out of radiation float playerRadiationStrength = playerDepth / radiationDepth; return(Math.Min(tracker.distanceToPlayer, tracker.maxDistance * playerRadiationStrength)); }
/** * True if player can't breathe the current air, because on the surface. */ private static bool isAirPoisoned(Player player) { if (!isSurfaceAirPoisoned()) { return(false); } if (player.IsInside() || player.precursorOutOfWater) { return(false); } float depth = Ocean.main.GetDepthOf(player.gameObject); if (depth > 5) { return(false); } // After repairing radiation leaks, when inside the Aurora. if (LeakingRadiation.main != null) { if (LeakingRadiation.main.GetNumLeaks() == 0) { if (Config.IRRADIATED.Equals(DeathRun.config.surfaceAir)) { return(false); } string LDBiome = RadiationUtils.getPlayerBiome(); if (LDBiome.Contains("CrashedShip_Interior")) { return(false); } } } return(true); }
private static bool Update(RadiationsScreenFXController __instance) { if ((Player.main == null) || (LeakingRadiation.main == null) || Config.FX_NORMAL.Equals(DeathRun.config.radiationFX)) { DeathRun.saveData.playerSave.backgroundRads = 0; return(true); } Vector3 reactorRoom = new Vector3(873.7f, 2.9f, -1.7f); float distance = (Player.main.transform.position - reactorRoom).magnitude; //LeakingRadiation.main.transform.position float backgroundRads; //ErrorMessage.AddMessage("LDBiome=" + LDBiome + " PlayerBiome=" + PlayerBiome); if (RadiationUtils.isInShipsRadiation(Player.main.transform)) { backgroundRads = MINIMUM_AMOUNT_SHIP; } else if (RadiationUtils.isInAnyRadiation(Player.main.transform)) { backgroundRads = MINIMUM_AMOUNT_NORMAL; } else { backgroundRads = 0; } DeathRun.saveData.playerSave.backgroundRads = backgroundRads; if (Player.main == null) { return(true); } string LDBiome = RadiationUtils.getPlayerBiome(); string PlayerBiome = Player.main.GetBiomeString(); // In the moments right after we fix the leaks, the visible radiation fades back a bit. float fixFactor = 1.0f; if (LeakingRadiation.main.GetNumLeaks() == 0) { if (DeathRun.saveData.playerSave.fixedRadiation == 0) { DeathRun.saveData.playerSave.fixedRadiation = DayNightCycle.main.timePassedAsFloat; } else if (DayNightCycle.main.timePassedAsFloat > DeathRun.saveData.playerSave.fixedRadiation + FIX_PERIOD) { fixFactor = 0.0f; } else { fixFactor = 1 - ((DayNightCycle.main.timePassedAsFloat - DeathRun.saveData.playerSave.fixedRadiation) / FIX_PERIOD); } } // If we're inside the ship (or near it), and radiation leaks aren't fixed yet, we show quite a bit more radiation effects if (fixFactor > 0) { if (Config.FX_CHERNOBYL.Equals(DeathRun.config.radiationFX)) { if (LDBiome.Contains("CrashedShip")) { if (LDBiome.Contains("Interior_Power") && !LDBiome.Contains("Corridor")) { if (Player.main.IsSwimming()) { backgroundRads = 2.0f; } else { backgroundRads = 1.6f; } } else if (LDBiome.Contains("PowerCorridor")) { if (distance <= 32) { backgroundRads = 1.4f; } else { backgroundRads = 1.2f; } } else if (LDBiome.Contains("Elevator") || LDBiome.Contains("Locker") || LDBiome.Contains("Seamoth")) { backgroundRads = 1.0f; } else if (LDBiome.Contains("Exo") || LDBiome.Contains("Living") || LDBiome.Contains("Cargo")) { backgroundRads = 0.8f; } else if (LDBiome.Contains("Entrance_03") || LDBiome.Contains("Entrance_01_01")) { backgroundRads = 0.7f; } else if (LDBiome.Contains("THallway_Lower") || LDBiome.Contains("Entrance_01")) { backgroundRads = 0.6f; } else if (LDBiome.Contains("THallway") || LDBiome.Contains("Entrance")) { backgroundRads = 0.5f; } else if (PlayerBiome.Contains("crashedShip") || PlayerBiome.Contains("generatorRoom")) { backgroundRads = 0.4f; } else if (PlayerBiome.Contains("CrashZone") || PlayerBiome.Contains("crashZone")) { backgroundRads = 0.3f; } } if (backgroundRads > 0.8f) { backgroundRads = backgroundRads * LeakingRadiation.main.GetNumLeaks() / 11; if (backgroundRads < 0.8f) { backgroundRads = 0.8f; } } } else { if (LDBiome.Contains("Interior_Power") && !LDBiome.Contains("Corridor")) { if (Player.main.IsSwimming()) { backgroundRads = 0.5f; } else { backgroundRads = 0.4f; } } else if (PlayerBiome.Contains("CrashZone") || PlayerBiome.Contains("crashZone") || PlayerBiome.Contains("crashedShip") || PlayerBiome.Contains("generatorRoom")) { backgroundRads = 0.3f; } } backgroundRads = backgroundRads * fixFactor; if (backgroundRads > DeathRun.saveData.playerSave.backgroundRads) { DeathRun.saveData.playerSave.backgroundRads = backgroundRads; } } //ErrorMessage.AddMessage("Dist=" + distance + " Rads=" + backgroundRads + " Leaks="+ LeakingRadiation.main.GetNumLeaks()); //CattleLogger.Message("start = " + LeakingRadiation.main.kStartRadius); //CattleLogger.Message("max = " + LeakingRadiation.main.kMaxRadius); float rads = Mathf.Max(Player.main.radiationAmount, backgroundRads); // If Player is naturally in at least our minimum display amount, just run normal method. if (Player.main.radiationAmount >= rads) { return(true); } if (rads >= __instance.prevRadiationAmount && rads > 0f) { __instance.animTime += Time.deltaTime / __instance.fadeDuration; } else { __instance.animTime -= Time.deltaTime / __instance.fadeDuration; } __instance.animTime = Mathf.Clamp01(__instance.animTime); __instance.fx.noiseFactor = rads * __instance.radiationMultiplier + __instance.minRadiation * __instance.animTime; if (__instance.fx.noiseFactor > 0f && !__instance.fx.enabled) { __instance.fx.enabled = true; } __instance.prevRadiationAmount = rads; return(false); }
public static void Postfix(ref uGUI_SunbeamCountdown __instance) { if (DayNightCycle.main == null) { return; } if (CrashedShipExploder.main == null) { return; } // These are the internal parameters for the Aurora story events (see AuroraWarnings for time thresholds) float timeToStartWarning = CrashedShipExploder.main.GetTimeToStartWarning(); float timeToStartCountdown = CrashedShipExploder.main.GetTimeToStartCountdown(); float timeNow = DayNightCycle.main.timePassedAsFloat; DeathRun.countdownMonitor.Update(timeNow); int deep; if (Config.EXPLOSION_DEATHRUN.Equals(DeathRun.config.explodeDepth)) { deep = 100; } else if (Config.EXPLOSION_HARD.Equals(DeathRun.config.explodeDepth)) { deep = 50; } else { deep = 0; } if (deep > 0) { // At time of second Aurora warning if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.5f))) { DeathRunUtils.CenterMessage("Explosion Shockwave Will Be", MESSAGE_TIME); DeathRunUtils.CenterMessage("Over " + deep + "m Deep!", MESSAGE_TIME, 1); } if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.5f) + MESSAGE_TIME)) { ErrorMessage.AddMessage("WARNING: Explosion will produce shockwave over " + deep + "m deep!"); } // At time of third Aurora warning if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.8f))) { DeathRunUtils.CenterMessage("Prepare To Evacuate At Least", MESSAGE_TIME); DeathRunUtils.CenterMessage("" + deep + "m Deep. Preferably Inside.", MESSAGE_TIME, 1); } if (DeathRun.countdownMonitor.JustWentAbove(Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.8f) + MESSAGE_TIME)) { ErrorMessage.AddMessage("Prepare to evacuate at least " + deep + "m deep, preferably inside!"); } // At time of final countdown if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown)) { DeathRunUtils.CenterMessage("Seek Safe Depth Immediately!", MESSAGE_TIME); DeathRunUtils.CenterMessage("Preferably Inside!", MESSAGE_TIME, 1); } if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + MESSAGE_TIME)) { ErrorMessage.AddMessage("Seek safe depth immediately! Preferably inside!"); } } deep = (int)RadiationUtils.getRadiationMaxDepth(); if (deep > 0) { if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f)) { DeathRunUtils.CenterMessage("Radiation Will Gradually Permeate", MESSAGE_TIME); DeathRunUtils.CenterMessage("Ocean As Deep As " + deep + "m.", MESSAGE_TIME, 1); } if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME)) { ErrorMessage.AddMessage("Radiation will gradually permeate the sea, as deep as " + deep + "m."); } if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME * 2)) { DeathRunUtils.CenterMessage("All devices will consume power more rapidly", MESSAGE_TIME); DeathRunUtils.CenterMessage("while exposed to RADIATION, and recharge slowly.", MESSAGE_TIME, 1); } if (DeathRun.countdownMonitor.JustWentAbove(timeToStartCountdown + 100f + MESSAGE_TIME * 3)) { ErrorMessage.AddMessage("All devices will consume power more rapidly while exposed to RADIATION and recharge slowly."); } } // If the Sunbeam rescue timer is showing, give that precedence over our countdown timer. if (isSunbeamShowing(__instance)) { showingShip = false; return; } // This is the time of the very first warning about the Aurora if (timeNow >= Mathf.Lerp(timeToStartWarning, timeToStartCountdown, 0.2f) && // Time of first Aurora warning (timeNow < timeToStartCountdown + 24f)) // Actual explosion time (24 sec after countdown) { float timeLeft = (timeToStartCountdown + 24f) - timeNow; if (timeLeft < 0) { timeLeft *= -1; } showShip(ref __instance); updateShip(ref __instance, timeLeft); } else { hideShip(ref __instance); } }
/// <summary> /// If the player is in a radiative zone outside a vehicle/base/escape pod /// </summary> private static bool IsRadiativeAir(Player player) { return(RadiationUtils.GetInAnyRadiation(player.transform) && player.transform.position.y >= -1 && !player.IsInside()); }
public static void Postfix() { // Check if we've repaired the pod if (!EscapePod.main.damageEffectsShowing && !DeathRun.saveData.podSave.podRepaired) { if (EscapePod.main.liveMixin.GetHealthFraction() > 0.99f) { DeathRun.saveData.podSave.podRepaired = true; DeathRun.saveData.podSave.podRepairTime = DayNightCycle.main.timePassedAsFloat; } } // This just fixes a situation that 1.7.1 screwed up for some people if (EscapePod.main.damageEffectsShowing && DeathRun.saveData.podSave.podRepaired) { DeathRun.saveData.podSave.podRepaired = false; DeathRun.saveData.podSave.podRepairTime = 0; } // If we've repaired the pod but it hasn't right itself yet, let it off the kinematic leash to turn itself upright if (EscapePod_FixedUpdate_Patch.isRighting()) { if (Vector3.Distance(EscapePod.main.transform.position, Player.main.transform.position) < 15) { if (DeathRun.saveData.podSave.podRightingTime <= 0) { DeathRun.saveData.podSave.podRightingTime = DayNightCycle.main.timePassedAsFloat; } EscapePod.main.rigidbodyComponent.isKinematic = false; WorldForces wf = EscapePod.main.GetComponent <WorldForces>(); wf.underwaterGravity = 0.0f; } } EscapePod_FixedUpdate_Patch.CheckSolarCellRate(); if (damaged != EscapePod.main.damageEffectsShowing) { if (!EscapePod.main.damageEffectsShowing) { // At repair, give a one-time "full recharge" RegeneratePowerSource[] cells = EscapePod.main.gameObject.GetAllComponentsInChildren <RegeneratePowerSource>(); if (cells != null) { foreach (RegeneratePowerSource cell in cells) { float chargeable = cell.powerSource.GetMaxPower() - cell.powerSource.GetPower(); cell.powerSource.ModifyPower(chargeable, out _); } } } } else { if ((lastBlink == 0) || (lastBlink > Time.time)) { lastBlink = Time.time; } else if (Time.time >= lastBlink + 0.5) { lastBlink = Time.time; blinkOn = !blinkOn; } bool radioFound = false; bool radioWorks = false; if (EscapePod.main.radioSpawner != null && EscapePod.main.radioSpawner.spawnedObj != null) { LiveMixin component = EscapePod.main.radioSpawner.spawnedObj.GetComponent <LiveMixin>(); if (component) { radioFound = true; if (component.IsFullHealth()) { radioWorks = true; } } } if (damaged) { string content = Language.main.Get("IntroEscapePod3Content"); string bonus; if (DeathRun.saveData.podSave.podAnchored || Config.BASIC_GAME.Equals(DeathRun.config.startLocation)) { if (!Config.BASIC_GAME.Equals(DeathRun.config.startLocation)) { content = content.Replace("Flotation Devices: DEPLOYED", "Flotation Devices: FAILED"); if (DeathRun.config.podStayUpright || DeathRun.saveData.podSave.podRepaired) { content = content.Replace("Hull Integrity: OK", "Inertial Stabilizers: DEPLOYED"); } else { content = content.Replace("Hull Integrity: OK", "Inertial Stabilizers: " + (blinkOn ? "FAILED" : "")); } } } else { content = content.Replace("Flotation Devices: DEPLOYED", "Flotation Devices: " + (blinkOn ? "FAILED" : "")); } if (radioWorks) { content = content.Replace("Radio: OFFLINE", "Radio: INCOMING ONLY"); } if (!Config.NORMAL.Equals(DeathRun.config.creatureAggression)) { content = content.Replace("Uncharted ocean planet 4546B", "Planet 4546B: HOSTILE FAUNA"); } if (BreathingPatcher.isSurfaceAirPoisoned()) { content = content.Replace("Oxygen/nitrogen atmosphere", "Atmosphere: requires filtration"); } bonus = ""; if (BreathingPatcher.isSurfaceAirPoisoned()) { bonus += "\n\n- Atmosphere: " + (blinkOn ? "NOT BREATHABLE" : "") + "\n- Recommend Air Pumps to Filter Oxygen"; } if (DeathRunUtils.isExplosionClockRunning()) { bonus += "\n\n" + (blinkOn ? "- QUANTUM EXPLOSION WARNING" : ""); } if (RadiationUtils.isRadiationActive()) { bonus += "\n\n" + (blinkOn ? "- EXTREME RADIATION HAZARD" : ""); } uGUI_EscapePod.main.SetHeader(Language.main.Get("IntroEscapePod3Header"), new Color32(243, 201, 63, byte.MaxValue), 2f); uGUI_EscapePod.main.SetContent(content + bonus, new Color32(233, 63, 27, byte.MaxValue)); } else { string content = Language.main.Get("IntroEscapePod4Content"); if (radioFound && !radioWorks) { content = content.Replace("Incoming radio communication: ONLINE", "Incoming radio communication: OFFLINE"); } if (!Config.NORMAL.Equals(DeathRun.config.creatureAggression)) { content = content.Replace("Uncharted ocean planet 4546B", (blinkOn ? "Planet 4546B: HOSTILE FAUNA" : "Planet 4546B: ")); } if (BreathingPatcher.isSurfaceAirPoisoned()) { content = content.Replace("Oxygen/nitrogen atmosphere", "Atmosphere: requires filtration"); } if (!Config.BASIC_GAME.Equals(DeathRun.config.startLocation)) { content = content.Replace("Flotation Devices: DEPLOYED", "Flotation Devices: FAILED"); if (DeathRun.config.podStayUpright || DeathRun.saveData.podSave.podRepaired) { content = content.Replace("Hull Integrity: OK", "Inertial Stabilizers: DEPLOYED"); } else { content = content.Replace("Hull Integrity: OK", "Inertial Stabilizers: FAILED"); } } if (BreathingPatcher.isSurfaceAirPoisoned()) { content = content.Replace("Oxygen/nitrogen atmosphere", "Atmosphere: requires filtration"); } string bonus = ""; if (DeathRunUtils.isExplosionClockRunning()) { bonus += "\n " + (blinkOn ? "- QUANTUM EXPLOSION WARNING" : ""); } if (RadiationUtils.isRadiationActive()) { if (Config.NORMAL.Equals(DeathRun.config.radiationDepth)) { bonus += "\n - Radiation Hazard: Aurora"; } else { bonus += "\n " + (blinkOn ? "- EXTREME RADIATION HAZARD" : ""); } } uGUI_EscapePod.main.SetHeader(Language.main.Get("IntroEscapePod4Header"), new Color32((byte)(blinkOn ? 243 : 223), (byte)(blinkOn ? 243 : 223), 63, byte.MaxValue)); //, 2f); uGUI_EscapePod.main.SetContent(content + bonus, new Color32((byte)(blinkOn ? 243 : 223), (byte)(blinkOn ? 243 : 223), 63, byte.MaxValue)); } } }