public static Building_MeatHook FindHookFor(Pawn p, Pawn traveler, bool ignoreOtherReservations = false) { IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs where typeof(Building_MeatHook).IsAssignableFrom(def.thingClass) select def; foreach (ThingDef singleDef in enumerable) { Building_MeatHook building_MeatHook = (Building_MeatHook)GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForDef(singleDef), PathEndMode.InteractionCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, delegate(Thing x) { bool result; if (!((Building_MeatHook)x).Accepts()) { Pawn traveler2 = traveler; LocalTargetInfo target = x; bool ignoreOtherReservations2 = ignoreOtherReservations; result = traveler2.CanReserve(target, 1, -1, null, ignoreOtherReservations2); } else { result = false; } return(result); }, null, 0, -1, false, RegionType.Set_Passable, false); if (building_MeatHook != null && !building_MeatHook.forbiddable.Forbidden) { return(building_MeatHook); } } return(null); }
// TaleUtility.Notify_PawnDied(this, dinfo); public static void Pre_Notify_PawnDied(ref Pawn victim, ref DamageInfo?dinfo) { if (victim.Spawned && victim.Map != null) { List <Thing> thingList = victim.Position.GetThingList(victim.Map); for (int i = 0; i < thingList.Count; i++) { Pawn pawn = thingList[i] as Pawn; Building_MeatHook Building_MeatHook = thingList[i] as Building_MeatHook; if (Building_MeatHook != null) { if (Building_MeatHook.hangedman == victim) { Building_MeatHook.hangedman = null; Building_MeatHook.killcount++; break; } } } } }
public static bool Prefix_AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo localTargetInfo3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { LocalTargetInfo localTargetInfo4 = localTargetInfo3; Pawn victim = (Pawn)localTargetInfo4.Thing; if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_MeatHook.FindHookFor(victim, pawn, true) != null) { string text4 = "CarryToDBDHook".Translate(localTargetInfo4.Thing.LabelCap, localTargetInfo4.Thing); JobDef jDef = Hook_JobDefOf.FPDBDTakeToMeatHook; Action action3 = delegate() { Building_MeatHook building_MeatHook = Building_MeatHook.FindHookFor(victim, pawn, false); if (building_MeatHook == null) { building_MeatHook = Building_MeatHook.FindHookFor(victim, pawn, true); } if (building_MeatHook == null) { Messages.Message("CannotCarryToDBDHook".Translate() + ": " + "NoDBDHook".Translate(), victim, MessageTypeDefOf.RejectInput, false); return; } Job job = new Job(jDef, victim, building_MeatHook); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }; string label = text4; Action action2 = action3; Pawn revalidateClickTarget = victim; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2, MenuOptionPriority.Default, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy")); } } } return(true); }