private static FloatMenuOption GetEquipOffHandOption(Pawn pawn, ThingWithComps equipment) { string labelShort = equipment.LabelShort; FloatMenuOption menuItem; if (equipment.def.IsWeapon && pawn.story.DisabledWorkTagsBackstoryAndTraits.HasFlag(WorkTags.Violent)) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " (" + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort, pawn) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, false, TraverseMode.ByPawn)) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (equipment.IsBurning()) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " (" + "BurningLower".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (pawn.HasMissingArmOrHand()) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " ( " + "DW_MissArmOrHand".Translate() + " )", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (pawn.equipment != null && pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsTwoHand()) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " ( " + "DW_WieldingTwoHanded".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (equipment.def.IsTwoHand()) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " ( " + "DW_NoTwoHandedInOffHand".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!equipment.def.CanBeOffHand()) { menuItem = new FloatMenuOption("CannotEquip".Translate(labelShort) + " " + "DW_AsOffHand".Translate() + " ( " + "DW_CannotBeOffHand".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text5 = "DW_EquipOffHand".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text5 = text5 + " " + "EquipWarningBrawler".Translate(); } menuItem = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text5, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(DW_DefOff.DW_EquipOffhand, equipment), JobTag.Misc); FleckMaker.Static(equipment.DrawPos, equipment.Map, FleckDefOf.FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); } return(menuItem); }
private void TryProducePortion(float yieldPct) { ThingDef thingDef; int num; IntVec3 intVec; bool nextResource = this.GetNextResource(out thingDef, out num, out intVec); if (thingDef == null) { return; } int num2 = Mathf.Min(num, thingDef.deepCountPerPortion); if (nextResource) { this.parent.Map.deepResourceGrid.SetAt(intVec, thingDef, num - num2); } int stackCount = Mathf.Max(1, GenMath.RoundRandom((float)num2 * yieldPct)); Thing thing = ThingMaker.MakeThing(thingDef, null); thing.stackCount = stackCount; GenPlace.TryPlaceThing(thing, this.parent.InteractionCell, this.parent.Map, ThingPlaceMode.Near, null, null); if (nextResource && !this.ValuableResourcesPresent()) { if (DeepDrillUtility.GetBaseResource(this.parent.Map) == null) { Messages.Message("DeepDrillExhaustedNoFallback".Translate(), this.parent, MessageTypeDefOf.TaskCompletion, true); } else { Messages.Message("DeepDrillExhausted".Translate(Find.ActiveLanguageWorker.Pluralize(DeepDrillUtility.GetBaseResource(this.parent.Map).label, -1)), this.parent, MessageTypeDefOf.TaskCompletion, true); for (int i = 0; i < 9; i++) { IntVec3 c = intVec + GenRadial.RadialPattern[i]; if (c.InBounds(this.parent.Map)) { ThingWithComps firstThingWithComp = c.GetFirstThingWithComp(this.parent.Map); if (firstThingWithComp != null && !firstThingWithComp.GetComp <CompDeepDrill>().ValuableResourcesPresent()) { firstThingWithComp.SetForbidden(true, true); } } } } } }
private void TryProducePortion(float yieldPct) { ThingDef resDef; int countPresent; IntVec3 cell; bool nextResource = GetNextResource(out resDef, out countPresent, out cell); if (resDef == null) { return; } int num = Mathf.Min(countPresent, resDef.deepCountPerPortion); if (nextResource) { parent.Map.deepResourceGrid.SetAt(cell, resDef, countPresent - num); } int stackCount = Mathf.Max(1, GenMath.RoundRandom((float)num * yieldPct)); Thing thing = ThingMaker.MakeThing(resDef); thing.stackCount = stackCount; GenPlace.TryPlaceThing(thing, parent.InteractionCell, parent.Map, ThingPlaceMode.Near); if (!nextResource || ValuableResourcesPresent()) { return; } if (DeepDrillUtility.GetBaseResource(parent.Map, parent.Position) == null) { Messages.Message("DeepDrillExhaustedNoFallback".Translate(), parent, MessageTypeDefOf.TaskCompletion); return; } Messages.Message("DeepDrillExhausted".Translate(Find.ActiveLanguageWorker.Pluralize(DeepDrillUtility.GetBaseResource(parent.Map, parent.Position).label)), parent, MessageTypeDefOf.TaskCompletion); for (int i = 0; i < 21; i++) { IntVec3 c = cell + GenRadial.RadialPattern[i]; if (c.InBounds(parent.Map)) { ThingWithComps firstThingWithComp = c.GetFirstThingWithComp <CompDeepDrill>(parent.Map); if (firstThingWithComp != null && !firstThingWithComp.GetComp <CompDeepDrill>().ValuableResourcesPresent()) { firstThingWithComp.SetForbidden(value: true); } } } }
public static void AppendSidearmsOptions(Pawn pawn, ThingWithComps equipment, ref List <FloatMenuOption> __result) { try { string labelShort = equipment.LabelShort; if (!pawn.CanReach(new LocalTargetInfo(equipment), PathEndMode.ClosestTouch, Danger.Deadly) || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !equipment.def.IsWeapon || equipment.IsBurning() || pawn.IsQuestLodger()) { return; } FloatMenuOption item3; if (!PeteTimesSix.SimpleSidearms.Utilities.StatCalculator.canCarrySidearmInstance(equipment, pawn, out var errStr)) { "CannotEquip".Translate(); item3 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + errStr + ")", null); __result.Add(item3); return; } string text2 = "Equip".Translate(labelShort); text2 = (((pawn.CombinedDisabledWorkTags & WorkTags.Violent) == 0 && !PeteTimesSix.SimpleSidearms.Extensions.isToolNotWeapon (PeteTimesSix.SimpleSidearms.Extensions.toThingDefStuffDefPair(equipment))) ? ((string)(text2 + "AsSidearm".Translate())) : ((string)(text2 + "AsTool".Translate()))); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, delegate { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(SimpleSidearms.rimworld.SidearmsDefOf.EquipSecondary, equipment), JobTag.Misc); PlayerKnowledgeDatabase.KnowledgeDemonstrated(SimpleSidearms.rimworld.SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction); }, MenuOptionPriority.High), pawn, equipment); __result.Add(item3); } catch (Exception e) { Log.Error("Exception during SimpleSidearms floatmenumaker intercept. Cancelling intercept. Exception: " + e.ToString()); } }
private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (SimpleSidearms.CEOverride) { return; } IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; string errStr; FloatMenuOption item3; if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { } else if (!equipment.def.IsWeapon) { } else if (!StatCalculator.canCarrySidearm(equipment.def, pawn, out errStr)) { "CannotEquip".Translate(); item3 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + errStr + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.Add(item3); } else { string text2 = "Equip".Translate(labelShort) + "AsSidearm".Translate(); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(SidearmsDefOf.EquipSecondary, equipment), JobTag.Misc); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); opts.Add(item3); } } } }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 position = IntVec3.FromVector3(clickPos); // Add options for equipment. if (pawn.equipment != null) { List <Thing> things = position.GetThingList(pawn.Map); foreach (Thing thing in things) { if (thing.TryGetComp <CompEquippable>() != null) { ThingWithComps equipment = (ThingWithComps)thing; if (equipment.def.IsWeapon && !pawn.WorkTagIsDisabled(WorkTags.Violent) && pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly) && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && !(pawn.IsQuestLodger() && (!equipment.def.IsWeapon || pawn.equipment.Primary != null)) && EquipmentUtility.CanEquip(equipment, pawn, out _)) { string text3 = UIText.AIEquip.Translate(thing.LabelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 += " " + UIText.EquipWarningBrawler.Translate(); } var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( text3, () => { TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn); CompBladelinkWeapon compBladelinkWeapon = equipment.TryGetComp <CompBladelinkWeapon>(); if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn) { if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n"; } equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate(); } if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate(); Find.WindowStack.Add( new Dialog_MessageBox( equipWeaponConfirmationDialogText, "Yes".Translate(), () => { Equip(); }, "No".Translate())); } else { Equip(); } }, MenuOptionPriority.High), pawn, equipment); opts.Add(option); } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(AwesomeInventory_JobDefOf.AwesomeInventory_MapEquip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } } } } // Add options for apparel. if (pawn.apparel != null) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(position); if (apparel != null) { if (pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly) && !apparel.IsBurning() && ApparelOptionUtility.CanWear(pawn, apparel)) { FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIForceWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = true; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = false; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); } } } }
// RimWorld.FloatMenuMakerMap public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); //Ground things with installed part components ThingWithComps groundThing = c.GetThingList(pawn.Map).FirstOrDefault(x => x.TryGetComp <CompInstalledPart>() != null) as ThingWithComps; if (groundThing != null && groundThing.GetComp <CompInstalledPart>() is CompInstalledPart groundPart) { if (pawn.equipment != null) { //Remove "Equip" option from right click. if (groundThing.GetComp <CompEquippable>() != null) { var optToRemove = opts.FirstOrDefault((x) => x.Label.Contains(groundThing.Label)); if (optToRemove != null) { opts.Remove(optToRemove); } } string text = "CompInstalledPart_Install".Translate(); opts.Add(new FloatMenuOption(text, delegate { CompProperties_InstalledPart props = groundPart.Props; if (props != null) { if (props.allowedToInstallOn != null && props.allowedToInstallOn.Count > 0) { SoundDefOf.TickTiny.PlayOneShotOnCamera(null); Find.Targeter.BeginTargeting(new TargetingParameters { canTargetPawns = true, canTargetBuildings = true, mapObjectTargetsMustBeAutoAttackable = false, validator = delegate(TargetInfo targ) { if (!targ.HasThing) { return(false); } return(props.allowedToInstallOn.Contains(targ.Thing.def)); } }, delegate(LocalTargetInfo target) { groundThing.SetForbidden(false); groundPart.GiveInstallJob(pawn, target.Thing); }, null, null, null); } else { Log.ErrorOnce("CompInstalledPart :: allowedToInstallOn list needs to be defined in XML.", 3242); } } }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } //Install to a thing Pawn targetPawn = c.GetThingList(pawn.Map).FirstOrDefault(x => x is Pawn) as Pawn; if (targetPawn != null) { if (targetPawn != null && pawn != null && pawn != targetPawn) { //Handle installed weapons if (targetPawn.equipment != null) { if (targetPawn.equipment.Primary != null) { CompInstalledPart installedEq = targetPawn.equipment.Primary.GetComp <CompInstalledPart>(); if (installedEq != null) { string text = "CompInstalledPart_Uninstall".Translate(targetPawn.equipment.Primary.LabelShort); opts.Add(new FloatMenuOption(text, delegate { SoundDefOf.TickTiny.PlayOneShotOnCamera(null); installedEq.GiveUninstallJob(pawn, targetPawn); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } } } //Handle installed apparel if (targetPawn.apparel != null) { if (targetPawn.apparel.WornApparel != null && targetPawn.apparel.WornApparelCount > 0) { List <Apparel> installedApparel = targetPawn.apparel.WornApparel.FindAll((x) => x.GetComp <CompInstalledPart>() != null); if (installedApparel != null && installedApparel.Count > 0) { foreach (Apparel ap in installedApparel) { string text = "CompInstalledPart_Uninstall".Translate(ap.LabelShort); opts.Add(new FloatMenuOption(text, delegate { SoundDefOf.TickTiny.PlayOneShotOnCamera(null); ap.GetComp <CompInstalledPart>().GiveUninstallJob(pawn, targetPawn); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } } } } }
private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c2 = IntVec3.FromVector3(clickPos); foreach (Thing current in c2.GetThingList(pawn.Map)) { Thing t = current; bool flag = t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow; if (flag) { bool flag2 = t.def.ingestible.ingestCommandString.NullOrEmpty(); string text; if (flag2) { text = "ConsumeThing".Translate(new object[] { t.LabelShort }); } else { text = string.Format(t.def.ingestible.ingestCommandString, t.LabelShort); } bool flag3 = t.def.IsPleasureDrug && pawn.story != null && pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire) < 0; FloatMenuOption item; if (flag3) { item = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag4 = !pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn); if (flag4) { item = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag5 = !pawn.CanReserve(t, 1); if (flag5) { item = new FloatMenuOption(text + " (" + "ReservedBy".Translate(new object[] { pawn.Map.reservationManager.FirstReserverOf(t, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { item = new FloatMenuOption(text, delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.count = FoodUtility.WillIngestStackCountOf(pawn, t.def); pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.Default, null, null, 0f, null, null); } } } opts.Add(item); } } bool flag6 = pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation); if (flag6) { foreach (LocalTargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current2.Thing; bool flag7 = !victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1); if (flag7) { bool flag8 = (victim.Faction == Faction.OfPlayer && victim.MentalStateDef == null) || (victim.Faction != Faction.OfPlayer && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer))); if (flag8) { Pawn victim4 = victim; opts.Add(new FloatMenuOption("Rescue".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); bool flag34 = building_Bed == null; if (flag34) { bool animal = victim.RaceProps.Animal; string str2; if (animal) { str2 = "NoAnimalBed".Translate(); } else { str2 = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageSound.RejectInput); } else { Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); } }, MenuOptionPriority.Default, null, victim4, 0f, null, null)); } bool flag9 = victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfPlayer); if (flag9) { Pawn victim2 = victim; opts.Add(new FloatMenuOption("Capture".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); bool flag34 = building_Bed == null; if (flag34) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); } else { Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); } }, MenuOptionPriority.Default, null, victim2, 0f, null, null)); } } } foreach (LocalTargetInfo current3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { LocalTargetInfo localTargetInfo = current3; Pawn victim = (Pawn)localTargetInfo.Thing; bool flag10 = victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null; if (flag10) { string label = "CarryToCryptosleepCasket".Translate(new object[] { localTargetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); bool flag34 = building_CryptosleepCasket == null; if (flag34) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); } else { Job job = new Job(jDef, victim, building_CryptosleepCasket); job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); } }; Pawn victim3 = victim; opts.Add(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, victim3, 0f, null, null)); } } } foreach (LocalTargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { LocalTargetInfo stripTarg = current4; bool flag11 = !pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn); FloatMenuOption item2; if (flag11) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag12 = !pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1); if (flag12) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "ReservedBy".Translate(new object[] { pawn.Map.reservationManager.FirstReserverOf(stripTarg, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { item2 = new FloatMenuOption("Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), delegate { stripTarg.Thing.SetForbidden(false, false); Job job = new Job(JobDefOf.Strip, stripTarg); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.Default, null, null, 0f, null, null); } } opts.Add(item2); } bool flag13 = pawn.equipment != null; if (flag13) { ThingWithComps equipment = null; List <Thing> thingList = c2.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { bool flag14 = thingList[i].TryGetComp <CompEquippable>() != null; if (flag14) { equipment = (ThingWithComps)thingList[i]; break; } } bool flag15 = equipment != null; if (flag15) { string label2 = equipment.Label; bool flag16 = !pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn); FloatMenuOption item3; if (flag16) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag17 = !pawn.CanReserve(equipment, 1); if (flag17) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "ReservedBy".Translate(new object[] { pawn.Map.reservationManager.FirstReserverOf(equipment, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag18 = !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation); if (flag18) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text2 = "Equip".Translate(new object[] { label2 }); bool flag19 = equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler); if (flag19) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } item3 = new FloatMenuOption(text2, delegate { equipment.SetForbidden(false, true); Job job = new Job(JobDefOf.Equip, equipment); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); MoteMaker.MakeStaticMote(equipment.DrawPos, pawn.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.Default, null, null, 0f, null, null); } } } opts.Add(item3); } } bool flag20 = pawn.apparel != null; if (flag20) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(c2); bool flag21 = apparel != null; if (flag21) { bool flag22 = !pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn); FloatMenuOption item4; if (flag22) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag23 = !pawn.CanReserve(apparel, 1); if (flag23) { Pawn pawn2 = pawn.Map.reservationManager.FirstReserverOf(apparel, pawn.Faction, true); item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "ReservedBy".Translate(new object[] { pawn2.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag24 = !ApparelUtility.HasPartsToWear(pawn, apparel.def); if (flag24) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { bool flag25 = MenuMakerMapRestricted.RaceRestricted(pawn, apparel); if (flag25) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfWrongRace".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { item4 = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelShort }), delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.Default, null, null, 0f, null, null); } } } } opts.Add(item4); } } bool flag26 = pawn.equipment != null && pawn.equipment.Primary != null; if (flag26) { Thing thing = pawn.Map.thingGrid.ThingAt(c2, ThingDefOf.EquipmentRack); bool flag27 = thing != null; if (flag27) { bool flag28 = !pawn.CanReach(thing, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn); if (flag28) { opts.Add(new FloatMenuOption("CannotDeposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { using (IEnumerator <IntVec3> enumerator5 = GenAdj.CellsOccupiedBy(thing).GetEnumerator()) { while (enumerator5.MoveNext()) { IntVec3 c = enumerator5.Current; bool flag29 = c.GetStorable(pawn.Map) == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1); if (flag29) { Action action2 = delegate { ThingWithComps t; bool flag34 = pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true); if (flag34) { t.SetForbidden(false, true); Job job = new Job(JobDefOf.HaulToCell, t, c); job.haulMode = HaulMode.ToCellStorage; job.count = 1; job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); } }; opts.Add(new FloatMenuOption("Deposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }), action2, MenuOptionPriority.Default, null, null, 0f, null, null)); break; } } } } } bool flag30 = pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <LocalTargetInfo>(); if (flag30) { Action action3 = delegate { ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Wait, 20, false)); }; opts.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.Label }), action3, MenuOptionPriority.Default, null, null, 0f, null, null)); } } foreach (LocalTargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { LocalTargetInfo dest = current5; bool flag31 = !pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn); if (flag31) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { bool flag32 = !pawn.CanReserve(dest.Thing, 1); if (flag32) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action4 = delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string str = string.Empty; bool flag33 = pTarg.Faction != null; if (flag33) { str = " (" + pTarg.Faction.Name + ")"; } Thing thing2 = dest.Thing; opts.Add(new FloatMenuOption("TradeWith".Translate(new object[] { pTarg.LabelShort + ", " + pTarg.TraderKind.label }) + str, action4, MenuOptionPriority.Default, null, thing2, 0f, null, null)); } } } foreach (Thing current6 in pawn.Map.thingGrid.ThingsAt(c2)) { foreach (FloatMenuOption current7 in current6.GetFloatMenuOptions(pawn)) { opts.Add(current7); } } }
internal static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c2 = IntVec3.FromVector3(clickPos); int num = 0; if (pawn.story != null) { num = pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire); } foreach (Thing current in c2.GetThingList()) { Thing t = current; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { FloatMenuOption item; if (t.def.ingestible.isPleasureDrug && num < 0) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "Teetotaler".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(t, 1)) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(t, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }), delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.maxNumToCarry = FoodUtility.WillEatStackCountOf(pawn, t.def); pawn.drafter.TakeOrderedJob(job); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item); } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current2.Thing; if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && !victim.IsPrisonerOfColony) { if ((victim.Faction == Faction.OfPlayer && victim.MentalStateDef == null) || (victim.Faction != Faction.OfPlayer && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer)))) { Pawn victim2 = victim; opts.Add(new FloatMenuOption("Rescue".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed == null) { string str2; if (victim.RaceProps.Animal) { str2 = "NoAnimalBed".Translate(); } else { str2 = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, victim2, 0f, null)); } if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfPlayer)) { Pawn victim2 = victim; opts.Add(new FloatMenuOption("Capture".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, victim2, 0f, null)); } } } foreach (TargetInfo current3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { TargetInfo targetInfo = current3; Pawn victim = (Pawn)targetInfo.Thing; if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null) { string label = "CarryToCryptosleepCasket".Translate(new object[] { targetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(jDef, victim, building_CryptosleepCasket); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }; Pawn victim2 = victim; opts.Add(new FloatMenuOption(label, action, MenuOptionPriority.Medium, null, victim2, 0f, null)); } } } foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { TargetInfo stripTarg = current4; FloatMenuOption item2; if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { item2 = new FloatMenuOption("Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), delegate { stripTarg.Thing.SetForbidden(false, false); Job job = new Job(JobDefOf.Strip, stripTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item2); } CompInventory compInventory = pawn.TryGetComp <CompInventory>(); // Need compInventory here for equip and wear options if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c2.GetThingList(); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string label2 = equipment.Label; FloatMenuOption item3; if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(equipment, 1)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(equipment, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { string text = "Equip".Translate(new object[] { label2 }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text = text + " " + "EquipWarningBrawler".Translate(); } item3 = new FloatMenuOption(text, delegate { equipment.SetForbidden(false, true); Job job = new Job(JobDefOf.Equip, equipment); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item3); } } if (pawn.apparel != null) { Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(c2); if (apparel != null) { FloatMenuOption item4; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(apparel, 1)) { Pawn pawn2 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction, true); item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "ReservedBy".Translate(new object[] { pawn2.LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { // Added check for inventory capacity int count; if (compInventory != null && !compInventory.CanFitInInventory(apparel, out count, false, true)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { item4 = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelShort }), new Action(delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } } opts.Add(item4); } } // *** NEW: Pick up option *** if (compInventory != null) { List <Thing> thingList = c2.GetThingList(); if (!thingList.NullOrEmpty <Thing>()) { Thing item = thingList.FirstOrDefault(thing => thing.def.alwaysHaulable && !(thing is Corpse)); if (item != null) { FloatMenuOption pickUpOption; int count = 0; if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "NoPath".Translate() + ")", null); } else if (!pawn.CanReserve(item)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(item, pawn.Faction) }), null); } else if (!compInventory.CanFitInInventory(item, out count)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "CR_InventoryFull".Translate() + ")", null); } else { pickUpOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelShort, new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = 1 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); } opts.Add(pickUpOption); if (count > 1 && item.stackCount > 1) { int numToCarry = Math.Min(count, item.stackCount); FloatMenuOption pickUpStackOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelShort + " x" + numToCarry.ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); opts.Add(pickUpStackOption); FloatMenuOption pickUpHalfStackOption = new FloatMenuOption("CE_PickUpHalf" + " " + item.LabelShort + " x" + (numToCarry / 2).ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry / 2 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); opts.Add(pickUpHalfStackOption); } } } } if (pawn.equipment != null && pawn.equipment.Primary != null) { Thing thing = Find.ThingGrid.ThingAt(c2, ThingDefOf.EquipmentRack); if (thing != null) { if (!pawn.CanReach(thing, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotDeposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(thing)) { if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { Action action2 = delegate { ThingWithComps t; if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true)) { t.SetForbidden(false, true); Job job = new Job(JobDefOf.HaulToCell, t, c); job.haulMode = HaulMode.ToCellStorage; job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); } }; opts.Add(new FloatMenuOption("Deposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }), action2, MenuOptionPriority.Medium, null, null, 0f, null)); break; } } } } if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>()) { Action action3 = delegate { ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false)); }; opts.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.Label }), action3, MenuOptionPriority.Medium, null, null, 0f, null)); } } foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { TargetInfo dest = current5; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else if (!pawn.CanReserve(dest.Thing, 1)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action4 = delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } Thing thing2 = dest.Thing; opts.Add(new FloatMenuOption("TradeWith".Translate(new object[] { pTarg.LabelShort }) + str, action4, MenuOptionPriority.Medium, null, thing2, 0f, null)); } } foreach (Thing current6 in Find.ThingGrid.ThingsAt(c2)) { foreach (FloatMenuOption current7 in current6.GetFloatMenuOptions(pawn)) { opts.Add(current7); } } }
public static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { try { IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; string errStr; FloatMenuOption item3; /*if ((!equipment.toThingStuffPair().isToolNotWeapon()) && ((pawn.CombinedDisabledWorkTags & WorkTags.Violent) != 0)) * { * }*/ //if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) if (!pawn.CanReach(new LocalTargetInfo(equipment), PathEndMode.ClosestTouch, Danger.Deadly)) { } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { } else if (!equipment.def.IsWeapon) { } else if (equipment.IsBurning()) { } else if (pawn.IsQuestLodger()) { } else if (!StatCalculator.canCarrySidearmInstance(equipment, pawn, out errStr)) { "CannotEquip".Translate(); item3 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + errStr, null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.Add(item3); } else { string text2 = "Equip".Translate(labelShort); if (((pawn.CombinedDisabledWorkTags & WorkTags.Violent) != 0) || equipment.toThingDefStuffDefPair().isToolNotWeapon()) { text2 += "AsTool".Translate(); } else { text2 += "AsSidearm".Translate(); } if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(SidearmsDefOf.EquipSecondary, equipment), JobTag.Misc); //MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //why is this gone? PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); opts.Add(item3); } } } } catch (Exception e) { Log.Error("Exception during SimpleSidearms floatmenumaker intercept. Cancelling intercept. Exception: " + e.ToString()); } }
internal static List <FloatMenuOption> ChoicesAtFor(Vector3 clickPos, Pawn pawn) { IntVec3 clickCell = IntVec3.FromVector3(clickPos); DangerUtility.NotifyDirectOrderingThisFrame(pawn); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!clickCell.InBounds()) { return(list); } // ***** Beginning of drafted options ***** if (pawn.Drafted) { foreach (TargetInfo attackTarg in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true)) { // *** Fire at option *** if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange) { string str; Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str); string text = "FireAt".Translate(new object[] { attackTarg.Thing.LabelCap }); FloatMenuOption floatMenuOption = new FloatMenuOption(); floatMenuOption.priority = MenuOptionPriority.High; if (rangedAct == null) { text = text + " (" + str + ")"; } else { floatMenuOption.autoTakeable = true; floatMenuOption.action = new Action(delegate { MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f); rangedAct(); }); } floatMenuOption.label = text; list.Add(floatMenuOption); } // *** Melee attack option *** string str2; Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2); Pawn pawn2 = attackTarg.Thing as Pawn; string text2; if (pawn2 != null && pawn2.Downed) { text2 = "MeleeAttackToDeath".Translate(new object[] { attackTarg.Thing.LabelCap }); } else { text2 = "MeleeAttack".Translate(new object[] { attackTarg.Thing.LabelCap }); } Thing thing = attackTarg.Thing; FloatMenuOption floatMenuOption2 = new FloatMenuOption(string.Empty, null, MenuOptionPriority.High, null, thing); if (meleeAct == null) { text2 = text2 + " (" + str2 + ")"; } else { floatMenuOption2.action = new Action(delegate { MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f); meleeAct(); }); } floatMenuOption2.label = text2; list.Add(floatMenuOption2); } // *** Arrest option *** if (pawn.RaceProps.Humanlike && !pawn.Downed) { foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true)) { TargetInfo dest = current2; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else if (!pawn.CanReserve(dest.Thing, 1)) { list.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Medium, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action = new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed); job.playerForced = true; job.maxNumToCarry = 1; pawn.drafter.TakeOrderedJob(job); TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies); }); List <FloatMenuOption> arg_3F1_0 = list; Thing thing = dest.Thing; arg_3F1_0.Add(new FloatMenuOption("TryToArrest".Translate(new object[] { dest.Thing.LabelCap }), action, MenuOptionPriority.Medium, null, thing)); } } } // *** Goto option *** int num = GenRadial.NumCellsInRadius(2.9f); for (int i = 0; i < num; i++) { IntVec3 curLoc = GenRadial.RadialPattern[i] + clickCell; if (curLoc.Standable()) { if (curLoc != pawn.Position) { if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { FloatMenuOption item = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Low, null, null); list.Add(item); } else { Action action2 = new Action(delegate { IntVec3 dest = Pawn_DraftController.BestGotoDestNear(curLoc, pawn); Job job = new Job(JobDefOf.Goto, dest); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(dest, ThingDefOf.Mote_FeedbackGoto, 1f); }); list.Add(new FloatMenuOption("GoHere".Translate(), action2, MenuOptionPriority.Low, null, null) { autoTakeable = true }); } } break; } } } // *** End of drafted options *** // *** Beginning of humanlike options *** if (pawn.RaceProps.Humanlike) { int num2 = 0; if (pawn.story != null) { num2 = pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire); } // *** Consume option *** foreach (Thing current3 in clickCell.GetThingList()) { Thing t = current3; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { FloatMenuOption item2; if (t.def.ingestible.isPleasureDrug && num2 < 0) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "Teetotaler".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(t, 1)) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(t, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }), new Action(delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.maxNumToCarry = t.def.ingestible.maxNumToIngestAtOnce; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } list.Add(item2); } } // *** Rescue/Capture downed option *** foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current4.Thing; if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && !victim.IsPrisonerOfColony) { if ((victim.Faction == Faction.OfColony && victim.MentalStateDef == null) || (victim.Faction != Faction.OfColony && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfColony)))) { List <FloatMenuOption> arg_8E1_0 = list; Pawn victim2 = victim; arg_8E1_0.Add(new FloatMenuOption("Rescue".Translate(new object[] { victim2.LabelCap }), new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed == null) { string str; if (victim.RaceProps.Animal) { str = "NoAnimalBed".Translate(); } else { str = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str, victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, victim2)); } if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfColony)) { List <FloatMenuOption> arg_962_0 = list; Pawn victim2 = victim; arg_962_0.Add(new FloatMenuOption("Capture".Translate(new object[] { victim2.LabelCap }), new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, victim2)); } } } // *** Carry to cryosleep option *** foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { TargetInfo targetInfo = current5; Pawn victim = (Pawn)targetInfo.Thing; if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null) { string label = "CarryToCryptosleepCasket".Translate(new object[] { targetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action3 = new Action(delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(jDef, victim, building_CryptosleepCasket); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }); List <FloatMenuOption> arg_A80_0 = list; Pawn victim2 = victim; arg_A80_0.Add(new FloatMenuOption(label, action3, MenuOptionPriority.Medium, null, victim2)); } } // *** Strip option *** foreach (TargetInfo current6 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { TargetInfo stripTarg = current6; FloatMenuOption item3; if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { item3 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else { item3 = new FloatMenuOption("Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), new Action(delegate { stripTarg.Thing.SetForbidden(false, false); Job job = new Job(JobDefOf.Strip, stripTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } list.Add(item3); } // *** Equip option *** CompInventory compInventory = pawn.TryGetComp <CompInventory>(); // Need compInventory here for equip and wear options if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = clickCell.GetThingList(); for (int j = 0; j < thingList.Count; j++) { if (thingList[j].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[j]; break; } } if (equipment != null) { string eqLabel = GenLabel.ThingLabel(equipment.def, equipment.Stuff, 1); FloatMenuOption equipOption; if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(equipment, 1)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(equipment, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else { // Added check for inventory space here int count; if (compInventory != null && !compInventory.CanFitInInventory(equipment, out count, true)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { equipment.SetForbidden(false, true); Job job = new Job(JobDefOf.Equip, equipment); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, null); } } list.Add(equipOption); } } // *** Wear option *** if (pawn.apparel != null) { Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(clickCell); if (apparel != null) { FloatMenuOption wearOption; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(apparel, 1)) { Pawn pawn3 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction); wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "ReservedBy".Translate(new object[] { pawn3.LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else { // Added check for inventory capacity int count; if (compInventory != null && !compInventory.CanFitInInventory(apparel, out count, false, true)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { wearOption = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelBaseShort }), new Action(delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } } list.Add(wearOption); } } // *** NEW: Pick up option *** if (compInventory != null) { List <Thing> thingList = clickCell.GetThingList(); if (!thingList.NullOrEmpty <Thing>()) { Thing item = thingList.FirstOrDefault(thing => thing.def.alwaysHaulable && !(thing is Corpse)); if (item != null) { FloatMenuOption pickUpOption; int count = 0; if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "NoPath".Translate() + ")", null); } else if (!pawn.CanReserve(item)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(item, pawn.Faction) }), null); } else if (!compInventory.CanFitInInventory(item, out count)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "CR_InventoryFull".Translate() + ")", null); } else { pickUpOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort, new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = 1 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); } list.Add(pickUpOption); if (count > 1 && item.stackCount > 1) { int numToCarry = Math.Min(count, item.stackCount); FloatMenuOption pickUpStackOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort + " x" + numToCarry.ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); list.Add(pickUpStackOption); } } } } // *** Deposit/drop equipment options *** if (pawn.equipment != null && pawn.equipment.Primary != null) { Thing thing2 = Find.ThingGrid.ThingAt(clickCell, ThingDefOf.EquipmentRack); if (thing2 != null) { if (!pawn.CanReach(thing2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotDeposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing2.def.label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else { using (IEnumerator <IntVec3> enumerator7 = GenAdj.CellsOccupiedBy(thing2).GetEnumerator()) { while (enumerator7.MoveNext()) { IntVec3 c = enumerator7.Current; if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { Action action4 = new Action(delegate { ThingWithComps t; if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true)) { t.SetForbidden(false, true); Job job = new Job(JobDefOf.HaulToCell, t, c); job.haulMode = HaulMode.ToCellStorage; job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); } }); list.Add(new FloatMenuOption("Deposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing2.def.label }), action4, MenuOptionPriority.Medium, null, null)); break; } } } } } if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>()) { Action action5 = new Action(delegate { ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false)); } ); list.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.LabelCap }), action5, MenuOptionPriority.Medium, null, null)); } } // *** Trade with option *** foreach (TargetInfo current7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { TargetInfo dest2 = current7; if (!pawn.CanReach(dest2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else if (!pawn.CanReserve(dest2.Thing, 1)) { list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else { Pawn pTarg = (Pawn)dest2.Thing; Action action6 = new Action(delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }); string str3 = string.Empty; if (pTarg.Faction != null) { str3 = " (" + pTarg.Faction.name + ")"; } List <FloatMenuOption> arg_142E_0 = list; Thing thing = dest2.Thing; arg_142E_0.Add(new FloatMenuOption("TradeWith".Translate(new object[] { pTarg.LabelBaseShort }) + str3, action6, MenuOptionPriority.Medium, null, thing)); } } foreach (Thing current8 in Find.ThingGrid.ThingsAt(clickCell)) { foreach (FloatMenuOption current9 in current8.GetFloatMenuOptions(pawn)) { list.Add(current9); } } } // *** End of humanlike options *** // *** Beginning of non-drafted options *** if (!pawn.Drafted) { bool flag = false; bool flag2 = false; foreach (Thing current10 in Find.ThingGrid.ThingsAt(clickCell)) { flag2 = true; if (pawn.CanReach(current10, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { flag = true; break; } } if (flag2 && !flag) { list.Add(new FloatMenuOption("(" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); return(list); } foreach (Thing current11 in Find.ThingGrid.ThingsAt(clickCell)) { Pawn pawn4 = Find.Reservations.FirstReserverOf(current11, pawn.Faction); if (pawn4 != null && pawn4 != pawn) { list.Add(new FloatMenuOption("IsReservedBy".Translate(new object[] { current11.LabelBaseShort.CapitalizeFirst(), pawn4.LabelBaseShort }), null, MenuOptionPriority.Medium, null, null)); } else { JobGiver_Work jobGiver_Work = pawn.thinker.TryGetMainTreeThinkNode <JobGiver_Work>(); if (jobGiver_Work != null) { foreach (WorkTypeDef current12 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int k = 0; k < current12.workGiversByPriority.Count; k++) { WorkGiver_Scanner workGiver_Scanner = current12.workGiversByPriority[k].Worker as WorkGiver_Scanner; if (workGiver_Scanner != null) { if (workGiver_Scanner.def.directOrderable) { if (!workGiver_Scanner.ShouldSkip(pawn)) { JobFailReason.Clear(); Job job; if (!workGiver_Scanner.HasJobOnThingForced(pawn, current11)) { job = null; } else { job = workGiver_Scanner.JobOnThingForced(pawn, current11); } if (workGiver_Scanner.PotentialWorkThingRequest.Accepts(current11) || (workGiver_Scanner.PotentialWorkThingsGlobal(pawn) != null && workGiver_Scanner.PotentialWorkThingsGlobal(pawn).Contains(current11))) { if (job == null) { if (JobFailReason.HaveReason) { string label2 = "CannotGenericWork".Translate(new object[] { workGiver_Scanner.def.verb, current11.LabelBaseShort }) + " (" + JobFailReason.Reason + ")"; list.Add(new FloatMenuOption(label2, null, MenuOptionPriority.Medium, null, null)); } } else { string label; WorkTypeDef workType = workGiver_Scanner.def.workType; Action action7 = null; PawnCapacityDef pawnCapacityDef = workGiver_Scanner.MissingRequiredCapacity(pawn); if (pawnCapacityDef != null) { label = "CannotMissingHealthActivities".Translate(new object[] { pawnCapacityDef.label }); } else if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job)) { label = "CannotGenericAlreadyAm".Translate(new object[] { workType.gerundLabel, current11.LabelBaseShort }); } else if (pawn.workSettings.GetPriority(workType) == 0) { label = "CannotPrioritizeIsNotA".Translate(new object[] { pawn.NameStringShort, workType.pawnLabel }); } else if (job.def == JobDefOf.Research && current11 is Building_ResearchBench) { label = "CannotPrioritizeResearch".Translate(); } else if (current11.IsForbidden(pawn)) { label = "CannotPrioritizeForbidden".Translate(new object[] { current11.Label }); } else if (!pawn.CanReach(current11, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { label = current11.Label + ": " + "NoPath".Translate(); } else { label = "PrioritizeGeneric".Translate(new object[] { workGiver_Scanner.def.gerund, current11.Label }); Job localJob = job; WorkTypeDef localWorkTypeDef = workType; action7 = new Action(delegate { pawn.thinker.GetMainTreeThinkNode <JobGiver_Work>().TryStartPrioritizedWorkOn(pawn, localJob, localWorkTypeDef); }); } if (!list.Any(op => op.label == label)) { list.Add(new FloatMenuOption(label, action7, MenuOptionPriority.Medium, null, null)); } } } } } } } } } } } } // *** End of non-drafted options *** foreach (FloatMenuOption current13 in pawn.GetExtraFloatMenuOptionsFor(clickCell)) { list.Add(current13); } DangerUtility.DoneDirectOrdering(); return(list); }
public static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Thing current in c.GetThingList(pawn.Map)) { Thing t = current; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { string text; if (t.def.ingestible.ingestCommandString.NullOrEmpty()) { text = "ConsumeThing".Translate(new object[] { t.LabelShort }); } else { text = string.Format(t.def.ingestible.ingestCommandString, t.LabelShort); } FloatMenuOption item = null; if (t.def.IsPleasureDrug && pawn.story != null && pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire) < 0) { item = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else { MenuOptionPriority priority = (!(t is Corpse)) ? MenuOptionPriority.Default : MenuOptionPriority.Low; ITWN.PostMenuOption(opts, pawn, current, text, delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.count = FoodUtility.WillIngestStackCountOf(pawn, t.def); pawn.jobs.TryTakeOrderedJob(job); }, priority: priority); } if (item != null) { opts.Add(item); } } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current2.Thing; if (!victim.InBed() && pawn.CanReach(victim, PathEndMode.OnCell, Danger.Deadly)) { if ((victim.Faction == Faction.OfPlayer && victim.MentalStateDef == null) || (victim.Faction != Faction.OfPlayer && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer)))) { Pawn victim2 = victim; ITWN.PostMenuOption(opts, pawn, victim2, "Rescue".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed == null) { string str2; if (victim.RaceProps.Animal) { str2 = "NoAnimalBed".Translate(); } else { str2 = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); }, MenuOptionPriority.RescueOrCapture, null, victim2, 0f, null); } if (victim.RaceProps.Humanlike && (victim.MentalStateDef != null || victim.Faction != Faction.OfPlayer || (victim.Downed && victim.guilt.IsGuilty))) { Pawn victim2 = victim; ITWN.PostMenuOption(opts, pawn, victim2, "Capture".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); }, MenuOptionPriority.RescueOrCapture, null, victim2, 0f, null); } } } foreach (LocalTargetInfo current3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { LocalTargetInfo targetInfo = current3; Pawn victim = (Pawn)targetInfo.Thing; if (victim.Downed && pawn.CanReach(victim, PathEndMode.OnCell, Danger.Deadly) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null) { string label = "CarryToCryptosleepCasket".Translate(new object[] { targetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(jDef, victim, building_CryptosleepCasket); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; Pawn victim2 = victim; ITWN.PostMenuOption(opts, pawn, victim2, label, action, MenuOptionPriority.Default, null, victim2, 0f, null); } } } foreach (LocalTargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { LocalTargetInfo stripTarg = current4; FloatMenuOption item2 = null; if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else { ITWN.PostMenuOption(opts, pawn, stripTarg.Thing, "Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), delegate { stripTarg.Thing.SetForbidden(false, false); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Strip, stripTarg)); }); } if (item2 != null) { opts.Add(item2); } } if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; FloatMenuOption item3 = null; if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "IsIncapableOfViolenceLower".Translate(new object[] { pawn.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { labelShort }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else { string text2 = "Equip".Translate(new object[] { labelShort }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text2 = text2 + " " + "EquipWarningBrawler".Translate(); } ITWN.PostMenuOption(opts, pawn, equipment, text2, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }); } if (item3 != null) { opts.Add(item3); } } } if (pawn.apparel != null) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(c); if (apparel != null) { FloatMenuOption item4 = null; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null); } else { ITWN.PostMenuOption(opts, pawn, apparel, "ForceWear".Translate(new object[] { apparel.LabelShort }), delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job); }, priority: MenuOptionPriority.High); } if (item4 != null) { opts.Add(item4); } } } if (!pawn.Map.IsPlayerHome) { Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(new object[] { item.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, 1)) { ITWN.PostMenuOption(opts, pawn, item, "CannotPickUp".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null); } else if (item.stackCount == 1) { ITWN.PostMenuOption(opts, pawn, item, "PickUp".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(JobDefOf.TakeInventory, item); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }, priority: MenuOptionPriority.High); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, item.stackCount)) { ITWN.PostMenuOption(opts, pawn, item, "CannotPickUpAll".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null); } else { ITWN.PostMenuOption(opts, pawn, item, "PickUpAll".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(JobDefOf.TakeInventory, item); job.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job); }, priority: MenuOptionPriority.High); } ITWN.PostMenuOption(opts, pawn, item, "PickUpSome".Translate(new object[] { item.Label }), delegate { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item), item.stackCount); Dialog_Slider window = new Dialog_Slider("PickUpCount".Translate(new object[] { item.LabelShort }), 1, to, delegate(int count) { item.SetForbidden(false, false); Job job = new Job(JobDefOf.TakeInventory, item); job.count = count; pawn.jobs.TryTakeOrderedJob(job); }, -2147483648); Find.WindowStack.Add(window); }, priority: MenuOptionPriority.High); } } } if (!pawn.Map.IsPlayerHome) { Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { Pawn bestPackAnimal = GiveToPackAnimalUtility.PackAnimalWithTheMostFreeSpace(pawn.Map, pawn.Faction); if (bestPackAnimal != null) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(new object[] { item.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, 1)) { ITWN.PostMenuOption(opts, pawn, item, "CannotGiveToPackAnimal".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null); } else if (item.stackCount == 1) { ITWN.PostMenuOption(opts, pawn, item, "GiveToPackAnimal".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(JobDefOf.GiveToPackAnimal, item); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, item.stackCount)) { ITWN.PostMenuOption(opts, pawn, item, "CannotGiveToPackAnimalAll".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { ITWN.PostMenuOption(opts, pawn, item, "GiveToPackAnimalAll".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(JobDefOf.GiveToPackAnimal, item); job.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High, null, null, 0f, null, null); } ITWN.PostMenuOption(opts, pawn, item, "GiveToPackAnimalSome".Translate(new object[] { item.Label }), delegate { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item), item.stackCount); Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(new object[] { item.LabelShort }), 1, to, delegate(int count) { item.SetForbidden(false, false); Job job = new Job(JobDefOf.GiveToPackAnimal, item); job.count = count; pawn.jobs.TryTakeOrderedJob(job); }, -2147483648); Find.WindowStack.Add(window); }, MenuOptionPriority.High, null, null, 0f, null, null); } } } } if (!pawn.Map.IsPlayerHome) { foreach (LocalTargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn p = (Pawn)current5.Thing; if (p.Faction == Faction.OfPlayer || p.HostFaction == Faction.OfPlayer) { if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(new object[] { p.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { IntVec3 exitSpot; if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot, TraverseMode.ByPawn)) { ITWN.PostMenuOption(opts, pawn, p, "CannotCarryToExit".Translate(new object[] { p.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { ITWN.PostMenuOption(opts, pawn, p, "CarryToExit".Translate(new object[] { p.Label }), delegate { Job job = new Job(JobDefOf.CarryDownedPawnToExit, p, exitSpot); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High, null, null, 0f, null, null); } } } } } if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <LocalTargetInfo>()) { Action action2 = delegate { pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, pawn.equipment.Primary)); }; opts.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.Label }), action2, MenuOptionPriority.Default, null, null, 0f, null, null)); } foreach (LocalTargetInfo current6 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { LocalTargetInfo dest = current6; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action3 = delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } Thing thing = dest.Thing; ITWN.PostMenuOption(opts, pawn, pTarg, "TradeWith".Translate(new object[] { pTarg.LabelShort + ", " + pTarg.TraderKind.label }) + str, action3, MenuOptionPriority.InitiateSocial, null, thing, 0f, null, null); } } foreach (Thing current7 in pawn.Map.thingGrid.ThingsAt(c)) { foreach (FloatMenuOption current8 in current7.GetFloatMenuOptions(pawn)) { opts.Add(current8); } } }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (!AwesomeInventoryServiceProvider.TryGetImplementation <IInventoryHelper>(out IInventoryHelper inventoryHelper)) { Log.Error(string.Format(ErrorMessage.NotImplemented, typeof(IInventoryHelper).Name)); return; } IntVec3 position = IntVec3.FromVector3(clickPos); // Add options for equipment. if (pawn.equipment != null) { List <Thing> things = position.GetThingList(pawn.Map); foreach (Thing thing in things) { if (thing.TryGetComp <CompEquippable>() != null) { ThingWithComps equipment = (ThingWithComps)thing; if (equipment.def.IsWeapon && !pawn.WorkTagIsDisabled(WorkTags.Violent) && pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly) && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && !(pawn.IsQuestLodger() && (!equipment.def.IsWeapon || pawn.equipment.Primary != null)) && EquipmentUtility.CanEquip(equipment, pawn, out _)) { string text3 = UIText.AIEquip.Translate(thing.LabelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 += " " + UIText.EquipWarningBrawler.Translate(); } var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( text3, () => { TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn); CompBladelinkWeapon compBladelinkWeapon = equipment.TryGetComp <CompBladelinkWeapon>(); if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn) { if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n"; } equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate(); } if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate(); Find.WindowStack.Add( new Dialog_MessageBox( equipWeaponConfirmationDialogText, "Yes".Translate(), () => { Equip(); }, "No".Translate())); } else { Equip(); } }, MenuOptionPriority.High), pawn, equipment); opts.Add(option); } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(AwesomeInventory_JobDefOf.AwesomeInventory_MapEquip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } } } } // Add options for apparel. if (pawn.apparel != null) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(position); if (apparel != null) { if (pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly) && !apparel.IsBurning() && !pawn.apparel.WouldReplaceLockedApparel(apparel) && ApparelUtility.HasPartsToWear(pawn, apparel.def)) { FloatMenuOption option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIForceWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = true; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( UIText.AIWear.Translate(apparel.LabelShort), () => { DressJob dressJob = SimplePool <DressJob> .Get(); dressJob.def = AwesomeInventory_JobDefOf.AwesomeInventory_Dress; dressJob.targetA = apparel; dressJob.ForceWear = false; apparel.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(dressJob); }, MenuOptionPriority.High), pawn, apparel); opts.Add(option); } } } List <Thing> items = position.GetThingList(pawn.Map); foreach (Thing item in items) { if (item.def.category == ThingCategory.Item) { int count = MassUtility.CountToPickUpUntilOverEncumbered(pawn, item); if (count == 0) { continue; } count = Math.Min(count, item.stackCount); string displayText = UIText.Pickup.Translate(item.LabelNoCount + " x" + count); var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( displayText , () => { Job job = JobMaker.MakeJob(JobDefOf.TakeInventory, item); job.count = count; pawn.jobs.TryTakeOrderedJob(job); }) , pawn , item); opts.Add(option); } } }
private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Thing thing2 in c.GetThingList(pawn.Map)) { Thing t = thing2; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { string text = (!t.def.ingestible.ingestCommandString.NullOrEmpty()) ? string.Format(t.def.ingestible.ingestCommandString, t.LabelShort) : "ConsumeThing".Translate(t.LabelShort); if (!t.IsSociallyProper(pawn)) { text = text + " (" + "ReservedForPrisoners".Translate() + ")"; } FloatMenuOption item3; if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler()) { item3 = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { MenuOptionPriority priority = (MenuOptionPriority)((!(t is Corpse)) ? 4 : 2); item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate { t.SetForbidden(false, true); Job job13 = new Job(JobDefOf.Ingest, t); job13.count = FoodUtility.WillIngestStackCountOf(pawn, t.def); pawn.jobs.TryTakeOrderedJob(job13, JobTag.Misc); }, priority, null, null, 0f, null, null), pawn, t, "ReservedBy"); } opts.Add(item3); } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo item7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)item7.Thing; if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true)) { if (!victim.IsPrisonerOfColony && !victim.InMentalState && (victim.Faction == Faction.OfPlayer || victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer))) { string label = "Rescue".Translate(victim.LabelCap); Action action = delegate { Building_Bed building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed2 == null) { building_Bed2 = RestUtility.FindBedFor(victim, pawn, false, false, true); } if (building_Bed2 == null) { string str2 = (!victim.RaceProps.Animal) ? "NoNonPrisonerBed".Translate() : "NoAnimalBed".Translate(); Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageTypeDefOf.RejectInput); } else { Job job12 = new Job(JobDefOf.Rescue, victim, building_Bed2); job12.count = 1; pawn.jobs.TryTakeOrderedJob(job12, JobTag.Misc); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); } }; MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture; Pawn revalidateClickTarget = victim; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy")); } if (!victim.NonHumanlikeOrWildMan() && (victim.InMentalState || victim.Faction != Faction.OfPlayer || (victim.Downed && (victim.guilt.IsGuilty || victim.IsPrisonerOfColony)))) { string label = "Capture".Translate(victim.LabelCap); Action action = delegate { Building_Bed 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) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageTypeDefOf.RejectInput); } else { Job job11 = new Job(JobDefOf.Capture, victim, building_Bed); job11.count = 1; pawn.jobs.TryTakeOrderedJob(job11, JobTag.Misc); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); } }; MenuOptionPriority priority2 = MenuOptionPriority.RescueOrCapture; Pawn revalidateClickTarget = victim; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy")); } } } foreach (LocalTargetInfo item8 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { LocalTargetInfo localTargetInfo = item8; Pawn victim2 = (Pawn)localTargetInfo.Thing; if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true) != null) { string text2 = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action2 = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, false); if (building_CryptosleepCasket == null) { building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, true); } if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput); } else { Job job10 = new Job(jDef, victim2, building_CryptosleepCasket); job10.count = 1; pawn.jobs.TryTakeOrderedJob(job10, JobTag.Misc); } }; string label = text2; Action action = action2; Pawn revalidateClickTarget = victim2; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, revalidateClickTarget, 0f, null, null), pawn, victim2, "ReservedBy")); } } } foreach (LocalTargetInfo item9 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { LocalTargetInfo stripTarg = item9; FloatMenuOption item4 = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap), delegate { stripTarg.Thing.SetForbidden(false, false); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Strip, stripTarg), JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, stripTarg, "ReservedBy") : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.Add(item4); } if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); int num = 0; while (num < thingList.Count) { if (thingList[num].TryGetComp <CompEquippable>() == null) { num++; continue; } equipment = (ThingWithComps)thingList[num]; break; } if (equipment != null) { string labelShort = equipment.LabelShort; FloatMenuOption item5; if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item5 = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { string text3 = "Equip".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 = text3 + " " + "EquipWarningBrawler".Translate(); } item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate { equipment.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment), JobTag.Misc); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy"); } opts.Add(item5); } } if (pawn.apparel != null) { Apparel apparel = pawn.Map.thingGrid.ThingAt <Apparel>(c); if (apparel != null) { FloatMenuOption item6 = pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) ? (ApparelUtility.HasPartsToWear(pawn, apparel.def) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(apparel.LabelShort), delegate { apparel.SetForbidden(false, true); Job job9 = new Job(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job9, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, apparel, "ReservedBy") : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)) : new FloatMenuOption("CannotWear".Translate(apparel.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.Add(item6); } } if (!pawn.Map.IsPlayerHome) { Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, 1)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (item.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item.Label), delegate { item.SetForbidden(false, false); Job job8 = new Job(JobDefOf.TakeInventory, item); job8.count = 1; pawn.jobs.TryTakeOrderedJob(job8, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, item.stackCount)) { opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item.Label), delegate { item.SetForbidden(false, false); Job job7 = new Job(JobDefOf.TakeInventory, item); job7.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job7, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item.Label), delegate { int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item), item.stackCount); Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item.LabelShort), 1, to2, delegate(int count) { item.SetForbidden(false, false); Job job6 = new Job(JobDefOf.TakeInventory, item); job6.count = count; pawn.jobs.TryTakeOrderedJob(job6, JobTag.Misc); }, -2147483648); Find.WindowStack.Add(window2); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } } } if (!pawn.Map.IsPlayerHome) { Thing item2 = c.GetFirstItem(pawn.Map); if (item2 != null && item2.def.EverHaulable) { Pawn bestPackAnimal = GiveToPackAnimalUtility.PackAnimalWithTheMostFreeSpace(pawn.Map, pawn.Faction); if (bestPackAnimal != null) { if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, 1)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (item2.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item2.Label), delegate { item2.SetForbidden(false, false); Job job5 = new Job(JobDefOf.GiveToPackAnimal, item2); job5.count = 1; pawn.jobs.TryTakeOrderedJob(job5, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy")); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item2, item2.stackCount)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item2.Label) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item2.Label), delegate { item2.SetForbidden(false, false); Job job4 = new Job(JobDefOf.GiveToPackAnimal, item2); job4.count = item2.stackCount; pawn.jobs.TryTakeOrderedJob(job4, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy")); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item2.Label), delegate { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item2), item2.stackCount); Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item2.LabelShort), 1, to, delegate(int count) { item2.SetForbidden(false, false); Job job3 = new Job(JobDefOf.GiveToPackAnimal, item2); job3.count = count; pawn.jobs.TryTakeOrderedJob(job3, JobTag.Misc); }, -2147483648); Find.WindowStack.Add(window); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item2, "ReservedBy")); } } } } if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid) { foreach (LocalTargetInfo item10 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn p = (Pawn)item10.Thing; if (p.Faction == Faction.OfPlayer || p.HostFaction == Faction.OfPlayer) { IntVec3 exitSpot; if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("CarryToExit".Translate(p.Label), delegate { Job job2 = new Job(JobDefOf.CarryDownedPawnToExit, p, exitSpot); job2.count = 1; pawn.jobs.TryTakeOrderedJob(job2, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item10, "ReservedBy")); } } } } if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any()) { Action action3 = delegate { pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, pawn.equipment.Primary), JobTag.Misc); }; opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label), action3, MenuOptionPriority.Default, null, null, 0f, null, null)); } foreach (LocalTargetInfo item11 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { LocalTargetInfo dest = item11; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action4 = delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } string label = "TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + str; Action action = action4; MenuOptionPriority priority2 = MenuOptionPriority.InitiateSocial; Thing thing = dest.Thing; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, priority2, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy")); } } foreach (Thing item12 in pawn.Map.thingGrid.ThingsAt(c)) { foreach (FloatMenuOption floatMenuOption in item12.GetFloatMenuOptions(pawn)) { opts.Add(floatMenuOption); } } }
public static void Postfix(ref List <FloatMenuOption> __result, Vector3 clickPos, Pawn pawn, bool suppressAutoTakeableGoto = false) { if (!pawn.RaceProps.Humanlike) { var compMachine = pawn.GetComp <CompMachine>(); if (compMachine != null && compMachine.Props.canPickupWeapons) { IntVec3 c = IntVec3.FromVector3(clickPos); ThingWithComps equipment = null; List <Thing> thingList2 = c.GetThingList(pawn.Map); for (int i = 0; i < thingList2.Count; i++) { if (thingList2[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList2[i]; break; } } if (equipment != null) { string labelShort = equipment.LabelShort; FloatMenuOption item6; string cantReason; if (equipment.def.IsWeapon && pawn.WorkTagIsDisabled(WorkTags.Violent)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "IsIncapableOfViolenceLower".Translate(pawn.LabelShort, pawn), null); } else if (equipment.def.IsRangedWeapon && pawn.WorkTagIsDisabled(WorkTags.Shooting)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "IsIncapableOfShootingLower".Translate(pawn), null); } else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "NoPath".Translate().CapitalizeFirst(), null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "Incapable".Translate(), null); } else if (equipment.IsBurning()) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "BurningLower".Translate(), null); } else if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(equipment, pawn)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null); } else if (!EquipmentUtility.CanEquip(equipment, pawn, out cantReason, checkBonded: false)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + cantReason.CapitalizeFirst(), null); } else { string text4 = "Equip".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text4 += " " + "EquipWarningBrawler".Translate(); } if (EquipmentUtility.AlreadyBondedToWeapon(equipment, pawn)) { text4 += " " + "BladelinkAlreadyBonded".Translate(); TaggedString dialogText = "BladelinkAlreadyBondedDialog".Translate(pawn.Named("PAWN"), equipment.Named("WEAPON"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON")); item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, delegate { Find.WindowStack.Add(new Dialog_MessageBox(dialogText)); }, MenuOptionPriority.High), pawn, equipment); } else { item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, delegate { string personaWeaponConfirmationText = EquipmentUtility.GetPersonaWeaponConfirmationText(equipment, pawn); if (!personaWeaponConfirmationText.NullOrEmpty()) { Find.WindowStack.Add(new Dialog_MessageBox(personaWeaponConfirmationText, "Yes".Translate(), delegate { Equip(); }, "No".Translate())); } else { Equip(); } }, MenuOptionPriority.High), pawn, equipment); } } __result.Add(item6); if (SimpleSidearmsPatch.SimpleSidearmsActive) { AppendSidearmsOptions(pawn, equipment, ref __result); } } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment), JobTag.Misc); FleckMaker.Static(equipment.DrawPos, equipment.MapHeld, FleckDefOf.FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } } } }