public static IEnumerable <Thing> GetBeesInDanger(Map map) { var bees = map.GetComponent <BeeDangerManager_MapComponent>().bees; foreach (var bee in bees) { var temp = bee.TryGetComp <CompTempRuinableAndDestroy>(); if (temp.Ruined) { // don't care about bees that can't be saved continue; } if (SteadyEnvironmentEffects.FinalDeteriorationRate(bee) > 0f) { yield return(bee); } else { var ambient = bee.AmbientTemperature; if (ambient < temp.Props.minSafeTemperature || ambient > temp.Props.maxSafeTemperature) { yield return(bee); } } } }
public static void Restore(Thing thing, Map map = null) { ThingDef def = thing.def; if (map == null) { map = thing.Map; } //HitPoints only affects apparel/weapons, //so why does MarketValue care about HP if it has no effect? if (!def.CanEverDeteriorate || def == ThingDefOf.BurnedTree || def.IsApparel || def.IsWeapon || def.IsCorpse) { return; } //ignore everything that doesn't use StatPart_Health , //if the thing isn't deteriorating, set back to full hp if ((map != null && thing.Position != null && thing.Position.GetSlotGroup(map)?.parent is Building_Storage) || SteadyEnvironmentEffects.FinalDeteriorationRate(thing) == 0.0f) { if (thing.HitPoints != thing.MaxHitPoints) { Log.Message($"5-sec Rule Restored {thing}"); } thing.HitPoints = thing.MaxHitPoints; } }
private static void TryDoDeteriorate(SteadyEnvironmentEffects __instance, Thing t, bool roofed, bool roomUsesOutdoorTemperature, bool protectedByEdifice, TerrainDef terrain) { if (t is Corpse corpse && corpse.InnerPawn.apparel != null) { List <Apparel> wornApparel = corpse.InnerPawn.apparel.WornApparel; for (int index = 0; index < wornApparel.Count; ++index) { TryDoDeteriorate(__instance, wornApparel[index], roofed, roomUsesOutdoorTemperature, protectedByEdifice, terrain); } } float num1 = SteadyEnvironmentEffects.FinalDeteriorationRate(t, roofed, roomUsesOutdoorTemperature, protectedByEdifice, terrain, null); if (num1 < 1.0 / 1000.0 || !Rand.Chance((float)((double)deteriorationRate(__instance) * num1 / 36.0))) { return; } IntVec3 position = t.Position; Map map = t.Map; int num2 = t.IsInAnyStorage() ? 1 : 0; t.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, 1f, 0.0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null)); if (num2 == 0 || !t.Destroyed || !t.def.messageOnDeteriorateInStorage) { return; } Messages.Message("MessageDeterioratedAway".Translate(t.Label), new TargetInfo(position, map, false), MessageTypeDefOf.NegativeEvent, true); }
public virtual string GetInspectStringLowPriority() { string result = null; tmpDeteriorationReasons.Clear(); SteadyEnvironmentEffects.FinalDeteriorationRate(this, tmpDeteriorationReasons); if (tmpDeteriorationReasons.Count != 0) { result = string.Format("{0}: {1}", "DeterioratingBecauseOf".Translate(), tmpDeteriorationReasons.ToCommaList().CapitalizeFirst()); } return(result); }
private void checkThingsDeteriorating() { thingsDeteriorating = false; foreach (Thing thing in map.listerHaulables.ThingsPotentiallyNeedingHauling()) { if (SteadyEnvironmentEffects.FinalDeteriorationRate(thing) != 0) { thingsDeteriorating = true; return; } } }
private bool TryDoDeteriorate(Thing t, TerrainDef terrain, int ticks) { float num = 1000 * SteadyEnvironmentEffects.FinalDeteriorationRate(t, false, false, false, terrain); if (!(num < 0.001f) && Rand.Chance(num / 36f)) { IntVec3 position = this.Position; Map map = this.Map; t.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, 1f)); if (t.Destroyed && t.def.messageOnDeteriorateInStorage) { return(true); } } return(false); }
public override bool FilterApplies(Thing thing) => SteadyEnvironmentEffects.FinalDeteriorationRate(thing) >= 0.001f;