public static FloatMenuOption AddCaptureOption(Pawn pawn, Pawn victim) { var floatOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Capture".Translate (victim.LabelCap, victim), delegate() { var ZTracker = ZUtils.ZTracker; var oldMap = pawn.Map; var oldPosition1 = pawn.Position; var oldPosition2 = victim.Position; bool select = Find.Selector.SelectedObjects.Contains(pawn); Building building_Bed = null; foreach (var otherMap in ZUtils.GetAllMapsInClosestOrderForTwoThings(pawn, oldMap, oldPosition1, victim, oldMap, oldPosition2)) { building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, true); } if (building_Bed != null) { break; } } ZUtils.TeleportThing(pawn, oldMap, oldPosition1); ZUtils.TeleportThing(victim, oldMap, oldPosition2); if (select) { Find.Selector.Select(pawn); } if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageTypeDefOf.RejectInput, false); return; } Job job = JobMaker.MakeJob(JobDefOf.Capture, victim, building_Bed); job.count = 1; ZTracker.BuildJobListFor(pawn, pawn.Map, job); ZLogger.Message(pawn + " taking first job 3"); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); if (victim.Faction != null && victim.Faction != Faction.OfPlayer && !victim.Faction.def.hidden && !victim.Faction.HostileTo(Faction.OfPlayer) && !victim.IsPrisonerOfColony) { Messages.Message("MessageCapturingWillAngerFaction".Translate(victim.Named("PAWN")) .AdjustedFor(victim, "PAWN", true), victim, MessageTypeDefOf.CautionInput, false); } }, MenuOptionPriority.RescueOrCapture, null, victim, 0f, null, null), pawn, victim, "ReservedBy"); return(floatOption); }
public static FloatMenuOption AddRescueOption(Pawn pawn, Pawn victim) { var floatOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Rescue".Translate (victim.LabelCap, victim), delegate() { var ZTracker = ZUtils.ZTracker; var oldMap = pawn.Map; var oldPosition1 = pawn.Position; var oldPosition2 = victim.Position; bool select = false; if (Find.Selector.SelectedObjects.Contains(pawn)) { select = true; } Building building_Bed = null; foreach (var otherMap in ZUtils.GetAllMapsInClosestOrderForTwoThings(pawn, oldMap, oldPosition1, victim, oldMap, oldPosition2)) { ZLogger.Message("Searching rest job for " + pawn + " in " + ZTracker.GetMapInfo(otherMap) + " for " + ZTracker.GetMapInfo(oldMap)); building_Bed = RestUtility.FindBedFor(victim, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(victim, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed != null) { break; } } if (select) { Find.Selector.Select(pawn); } ZUtils.TeleportThing(pawn, oldMap, oldPosition1); ZUtils.TeleportThing(victim, oldMap, oldPosition2); if (building_Bed == null) { string t3 = (!victim.RaceProps.Animal) ? ((string)"NoNonPrisonerBed".Translate()) : ((string)"NoAnimalBed".Translate()); Messages.Message("CannotRescue".Translate() + ": " + t3, victim, MessageTypeDefOf.RejectInput, historical: false); } else { Job job = JobMaker.MakeJob(JobDefOf.Rescue, victim, building_Bed); job.count = 1; ZTracker.BuildJobListFor(pawn, pawn.Map, job); Log.Message(pawn + " taking first job 2"); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); } }, MenuOptionPriority.RescueOrCapture, null, victim, 0f, null, null), pawn, victim, "ReservedBy"); return(floatOption); }
public static FloatMenuOption AddArrestOption(Pawn pawn, Pawn victim) { if (!pawn.CanReach(victim, PathEndMode.OnCell, Danger.Deadly)) { return(new FloatMenuOption( "CannotArrest".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else { Pawn pTarg2 = victim; Action action = delegate { var ZTracker = ZUtils.ZTracker; var oldMap = pawn.Map; var oldPosition1 = pawn.Position; var oldPosition2 = victim.Position; bool select = false; if (Find.Selector.SelectedObjects.Contains(pawn)) { select = true; } Building building_Bed3 = null; foreach (var otherMap in ZUtils.GetAllMapsInClosestOrderForTwoThings(pawn, oldMap, oldPosition1, victim, oldMap, oldPosition2)) { building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false); if (building_Bed3 == null) { building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed3 != null) { break; } } ZUtils.TeleportThing(pawn, oldMap, oldPosition1); ZUtils.TeleportThing(victim, oldMap, oldPosition2); if (select) { Find.Selector.Select(pawn); } if (building_Bed3 == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg2, MessageTypeDefOf.RejectInput, historical: false); } else { Job job = JobMaker.MakeJob(JobDefOf.Arrest, pTarg2, building_Bed3); job.count = 1; ZTracker.BuildJobListFor(pawn, pawn.Map, job); ZLogger.Message(pawn + " taking first job 3"); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, false); if (pTarg2.Faction != null && ((pTarg2.Faction != Faction.OfPlayer && !pTarg2.Faction.def.hidden) || pTarg2.IsQuestLodger())) { TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies); } } }; return(FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( "TryToArrest".Translate(victim.LabelCap, victim, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()), action, MenuOptionPriority.High, null, victim), pawn, pTarg2)); } }