public static bool isFrostbite(ExternalTemperatureMonitor.Instance data) { // a bit of a kludge, because for some reason Average External Temperature // does not update for Frostbite even though it does for Scalding. var exttemp = data.GetCurrentExternalTemperature; return(exttemp < GetFrostbiteThreshold(data) && exttemp > 0.01f && GetCurrentExternalPressure(data) >= GermExposureTuning.MIN_PRESSURE); }
// Gets the minimum external pressure of the cells occupied by the creature public static float GetCurrentExternalPressure(ExternalTemperatureMonitor.Instance instance) { int cell = Grid.PosToCell(instance.gameObject); var area = instance.occupyArea; float pressure = Grid.Pressure[cell]; if (area != null) { foreach (CellOffset offset in area.OccupiedCellsOffsets) { int newCell = Grid.OffsetCell(cell, offset); if (Grid.IsValidCell(newCell)) { float newPressure = Grid.Pressure[newCell]; if (newPressure < pressure) { pressure = newPressure; } } } } return(pressure); }
public static bool Prefix(ExternalTemperatureMonitor.Instance __instance, float dt, float ___lastScaldTime) { float now = Time.time; var hp = __instance.health; // Avoid damage for pressures < threshold bool pressure = GetCurrentExternalPressure(__instance) > GermExposureTuning. MIN_PRESSURE; if (hp != null && now - ___lastScaldTime > 5.0f && pressure) { float temp = __instance.AverageExternalTemperature, mult = GermExposureTuning.DAMAGE_PER_K; // For every 5 C outside the limits, damage 1HP more float damage = System.Math.Max(0.0f, mult * (temp - __instance. GetScaldingThreshold())) + System.Math.Max(0.0f, mult * ( GetFrostbiteThreshold(__instance) - temp)); if (damage > 0.0f) { hp.Damage(damage * dt); } } return(pressure); }
public static float GetFrostbiteThreshold(ExternalTemperatureMonitor.Instance data) { return(data.attributes.GetValue("FrostbiteThreshold") + GermExposureTuning. BASE_FROSTBITE_THRESHOLD); }