public static float GetHullSafety(Hull hull, Character character) { if (hull == null) { return(0.0f); } float safety = 100.0f; float waterPercentage = (hull.WaterVolume / hull.Volume) * 100.0f; if (hull.LethalPressure > 0.0f && character.PressureProtection <= 0.0f) { safety -= 100.0f; } else if (character.OxygenAvailable <= 0.0f) { safety -= waterPercentage; } else { safety -= waterPercentage * 0.1f; } if (hull.OxygenPercentage < 30.0f) { safety -= (30.0f - hull.OxygenPercentage) * 5.0f; } if (safety <= 0.0f) { return(0.0f); } float fireAmount = 0.0f; var nearbyHulls = hull.GetConnectedHulls(3); foreach (Hull hull2 in nearbyHulls) { foreach (FireSource fireSource in hull2.FireSources) { //increase priority if almost within damage range of a fire if (character.Position.X > fireSource.Position.X - fireSource.DamageRange * 2 && character.Position.X < fireSource.Position.X + fireSource.Size.X + fireSource.DamageRange * 2 && character.Position.Y > hull2.Rect.Y - hull2.Rect.Height && character.Position.Y < hull2.Rect.Y) { fireAmount += Math.Max(fireSource.Size.X, 50.0f); } } } safety -= fireAmount; return(MathHelper.Clamp(safety, 0.0f, 100.0f)); }
private static float GetHullSafety(Hull hull, Character character) { if (hull == null) { return(0.0f); } float waterPercentage = (hull.Volume / hull.FullVolume) * 100.0f; float fireAmount = 0.0f; var nearbyHulls = hull.GetConnectedHulls(3); foreach (Hull hull2 in nearbyHulls) { foreach (FireSource fireSource in hull2.FireSources) { //increase priority if almost within damage range of a fire if (character.Position.X > fireSource.Position.X - fireSource.DamageRange * 2 && character.Position.X < fireSource.Position.X + fireSource.Size.X + fireSource.DamageRange * 2 && character.Position.Y > hull2.Rect.Y - hull2.Rect.Height && character.Position.Y < hull2.Rect.Y) { fireAmount += Math.Max(fireSource.Size.X, 50.0f); } } } float safety = 100.0f - fireAmount; if (waterPercentage > 30.0f && character.OxygenAvailable <= 0.0f) { safety -= waterPercentage; } if (hull.OxygenPercentage < 30.0f) { safety -= (30.0f - hull.OxygenPercentage) * 5.0f; } return(safety); }