private void UpdateRecharge() { if (solarCount > 0) { DayNightCycle daynight = DayNightCycle.main; if (daynight == null) { return; } float num = Mathf.Clamp01((Constants.kMaxSolarChargeDepth + parentVehicle.transform.position.y) / Constants.kMaxSolarChargeDepth); float localLightScalar = daynight.GetLocalLightScalar(); float amount = Constants.kSeamothSolarChargePerSecond * localLightScalar * num * (float)solarCount; parentVehicle.relay.ModifyPower(amount, out float modified); } if (thermalCount > 0) { WaterTemperatureSimulation waterSim = WaterTemperatureSimulation.main; if (waterSim != null) { float temperature = waterSim.GetTemperature(parentVehicle.transform.position); float num = thermalReactorCharge.Evaluate(temperature) * thermalCount; parentVehicle.relay.ModifyPower(num * Time.deltaTime, out float modified); } } }
private void Awake() { cachedOxygenManager = Player.main.oxygenMgr; cachedDayNight = DayNightCycle.main; cachedTemp = WaterTemperatureSimulation.main; SeraLogger.Message(Main.modName, "SpecialtyTanks is Awake() and running!"); }
/// <summary> /// Gets the amount of available energy provided by the current ambient heat. /// </summary> /// <param name="cyclops">The cyclops.</param> /// <returns>The currently available thermal energy.</returns> private static float GetThermalChargeAmount(ref SubRoot cyclops) { // This code mostly replicates what the UpdateThermalReactorCharge() method does from the SubRoot class WaterTemperatureSimulation main = WaterTemperatureSimulation.main; float temperature = (!(main != null)) ? 0f : main.GetTemperature(cyclops.transform.position); float thermalCharge = cyclops.thermalReactorCharge.Evaluate(temperature) * ThermalChargingFactor; float thermalChargeOverTime = thermalCharge * Time.deltaTime; UWE.Utils.Assert(thermalChargeOverTime >= 0f, "ThermalReactorModule must produce positive amounts", cyclops); return(thermalChargeOverTime); }
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); } } } } }