public static ushort PathFindCostFor(this RimWorld.Building_Trap trap, Verse.Pawn p) { if (trap.KnowsOfTrap(p)) { if (!trap.Armed) { return(100); } else { return(800); } } else { return(0); } }
internal static bool _StateCheck(this Verse.Pawn_HealthTracker __instance, Verse.DamageInfo?dinfo, Verse.Hediff hediff) { MethodInfo _shouldBeDead = typeof(Verse.Pawn_HealthTracker).GetMethod("ShouldBeDead", BF); FieldInfo _pawn = typeof(Verse.Pawn_HealthTracker).GetField("pawn", BF); MethodInfo _shouldBeDowned = typeof(Verse.Pawn_HealthTracker).GetMethod("ShouldBeDowned", BF); MethodInfo _makeDowned = typeof(Verse.Pawn_HealthTracker).GetMethod("MakeDowned", BF); MethodInfo _makeUndowned = typeof(Verse.Pawn_HealthTracker).GetMethod("MakeUndowned", BF); bool shouldBeDead = (bool)_shouldBeDead.Invoke(__instance, new object[] {}); bool shouldBeDowned = (bool)_shouldBeDowned.Invoke(__instance, new object[] {}); bool isNotLethalDam = ((dinfo != null) ? (dinfo.ToString().Contains('=') ? dinfo.ToString().Split('=')[1].Split(',')[0].StartsWith("LTL_") : false) : false); bool isNotLethalDis = ((hediff != null) ? hediff.ToString().StartsWith("(LTL_") : false); Verse.Pawn pawn = (Verse.Pawn)_pawn.GetValue(__instance); if (!__instance.Dead) { if (shouldBeDead) { if (!pawn.Destroyed) { bool flag = PawnUtility.ShouldSendNotificationAbout(pawn); Caravan caravan = pawn.GetCaravan(); pawn.Kill(dinfo); if (flag) { __instance.NotifyPlayerOfKilled(dinfo, hediff, caravan); } } return(false); } if (!__instance.Downed) { if (shouldBeDowned) { float num = (isNotLethalDam || isNotLethalDis) ? ((float)LTL.likelihood_nonlethal / (float)100) : ((!pawn.RaceProps.Animal) ? ((float)LTL.likelihood_lethalHuman / (float)100) : ((float)LTL.likelihood_lethalAnimal / (float)10)); if (!__instance.forceIncap && (pawn.Faction == null || !pawn.Faction.IsPlayer) && !pawn.IsPrisonerOfColony && pawn.RaceProps.IsFlesh && Verse.Rand.Value < num) { pawn.Kill(dinfo); return(false); } __instance.forceIncap = false; _makeDowned.Invoke(__instance, new object[] { dinfo, hediff }); return(false); } else if (!__instance.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { if (pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null && pawn.jobs != null && pawn.CurJob != null) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } if (pawn.equipment != null && pawn.equipment.Primary != null) { if (pawn.InContainerEnclosed) { pawn.equipment.TryTransferEquipmentToContainer(pawn.equipment.Primary, pawn.holdingOwner); } else if (pawn.SpawnedOrAnyParentSpawned) { Verse.ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); } else { pawn.equipment.DestroyEquipment(pawn.equipment.Primary); } } } } else if (!shouldBeDowned) { _makeUndowned.Invoke(__instance, new object[] {}); return(false); } } return(false); }