public static FloatMenuOption EquipFoodOption(IntVec3 clickCell, Pawn pawn) { Thing food = clickCell.GetFirstItem(pawn.Map); if (food == null) { return(null); } int getcount = CountFoodEquippable(pawn, food); if (getcount == 0) { return(null); } Job job = new Job(JobDefOf.TakeInventory, food) { count = getcount }; Action action = delegate { if (pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc)) { MoteMaker.MakeStaticMote(clickCell, pawn.Map, ThingDefOf.Mote_FeedbackEquip, 1f); } }; return(new FloatMenuOption("Equip " + food.def.label, action, MenuOptionPriority.Low)); }
private float GetPillarSpawnScore(IntVec3 c) { Map map = BaseGen.globalSettings.map; if (!c.Impassable(map) && c.GetFirstBuilding(map) == null && c.GetFirstItem(map) == null && c.GetFirstPawn(map) == null) { bool flag = true; int num = 0; while (num < 8) { IntVec3 c2 = c + GenAdj.AdjacentCells[num]; if (c2.InBounds(map) && c2.Walkable(map)) { num++; continue; } flag = false; break; } if (flag) { return(2f); } return(1f); } return(0f); }
private float GetPillarSpawnScore(IntVec3 c) { Map map = BaseGen.globalSettings.map; if (c.Impassable(map) || c.GetFirstBuilding(map) != null || c.GetFirstItem(map) != null || c.GetFirstPawn(map) != null) { return(0f); } bool flag = true; for (int i = 0; i < 8; i++) { IntVec3 c2 = c + GenAdj.AdjacentCells[i]; if (!c2.InBounds(map) || !c2.Walkable(map)) { flag = false; break; } } if (flag) { return(2f); } return(1f); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef = ((rp.faction != null && (int)rp.faction.def.techLevel < 4) ? ThingDefOf.TorchLamp : ThingDefOf.StandingLamp); FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (!randomCell.Standable(map) || randomCell.GetFirstItem(map) != null || randomCell.GetFirstPawn(map) != null || randomCell.GetFirstBuilding(map) != null) { continue; } Region region = randomCell.GetRegion(map); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { if (!rp.spawnBridgeIfTerrainCantSupportThing.HasValue || rp.spawnBridgeIfTerrainCantSupportThing.Value) { BaseGenUtility.CheckSpawnBridgeUnder(thingDef, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(thingDef, randomCell, map); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction); } nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } nearbyGlowers.Clear(); }
// Token: 0x06000190 RID: 400 RVA: 0x0000F358 File Offset: 0x0000D558 public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef glowPod = RimWorld.ThingDefOf.GlowPod; this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; bool flag = randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null; if (flag) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); bool flag2 = region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !this.AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map); if (flag2) { bool flag3 = rp.spawnBridgeIfTerrainCantSupportThing == null || rp.spawnBridgeIfTerrainCantSupportThing.Value; if (flag3) { BaseGenUtility.CheckSpawnBridgeUnder(glowPod, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(glowPod, randomCell, map, WipeMode.Vanish); bool flag4 = thing.def.CanHaveFaction && thing.Faction != rp.faction; if (flag4) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLightingHivebase.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } SymbolResolver_OutdoorLightingHivebase.nearbyGlowers.Clear(); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef def = (rp.faction != null && (int)rp.faction.def.techLevel < 4) ? ThingDefOf.TorchLamp : ThingDefOf.StandingLamp; this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature && !this.AnyGlowerNearby(randomCell) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { Thing thing = GenSpawn.Spawn(def, randomCell, map); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLighting.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } SymbolResolver_OutdoorLighting.nearbyGlowers.Clear(); }
private void GrowLowRockFormationFrom(IntVec3 root, Map map) { ThingDef filth_RubbleRock = ThingDefOf.Filth_RubbleRock; ThingDef mineableThing = Find.World.NaturalRockTypesIn(map.Tile).RandomElement <ThingDef>().building.mineableThing; Rot4 random = Rot4.Random; MapGenFloatGrid elevation = MapGenerator.Elevation; IntVec3 intVec = root; while (true) { Rot4 random2 = Rot4.Random; if (!(random2 == random)) { intVec += random2.FacingCell; if (!intVec.InBounds(map) || intVec.GetEdifice(map) != null || intVec.GetFirstItem(map) != null) { break; } if (elevation[intVec] > 0.55f) { return; } if (!map.terrainGrid.TerrainAt(intVec).affordances.Contains(TerrainAffordanceDefOf.Heavy)) { return; } GenSpawn.Spawn(mineableThing, intVec, map, WipeMode.Vanish); IntVec3[] adjacentCellsAndInside = GenAdj.AdjacentCellsAndInside; for (int i = 0; i < adjacentCellsAndInside.Length; i++) { IntVec3 b = adjacentCellsAndInside[i]; if (Rand.Value < 0.5f) { IntVec3 c = intVec + b; if (c.InBounds(map)) { bool flag = false; List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing thing = thingList[j]; if (thing.def.category != ThingCategory.Plant && thing.def.category != ThingCategory.Item && thing.def.category != ThingCategory.Pawn) { flag = true; break; } } if (!flag) { FilthMaker.MakeFilth(c, map, filth_RubbleRock, 1); } } } } } } }
private void GrowLowRockFormationFrom(IntVec3 root, Map map) { ThingDef rockRubble = ThingDefOf.Filth_RubbleRock; ThingDef mineableThing = Find.World.NaturalRockTypesIn(map.Tile).RandomElement <ThingDef>().building.mineableThing; Rot4 excludedDir = Rot4.Random; MapGenFloatGrid elevation = MapGenerator.Elevation; IntVec3 cell = root; int maxRockChunks = MaxRockChunksPerGroup.RandomInRange; for (int i = 0; i < maxRockChunks; i++) { Rot4 nextDir = Rot4Utility.RandomButExclude(excludedDir); cell += nextDir.FacingCell; if (!cell.InBounds(map) || cell.GetEdifice(map) != null || cell.GetFirstItem(map) != null) { break; } if (elevation[cell] < ThreshLooseRock) { break; } List <TerrainAffordanceDef> affordances = map.terrainGrid.TerrainAt(cell).affordances; if (!(affordances.Contains(TerrainAffordanceDefOf.Medium) || affordances.Contains(TerrainAffordanceDefOf.Heavy))) { break; } GenSpawn.Spawn(mineableThing, cell, map); foreach (IntVec3 adjCell in GenAdj.AdjacentCellsAndInside) { if (Rand.Value < RubbleProbability) { continue; } IntVec3 c = cell + adjCell; if (c.InBounds(map)) { bool cellUsed = false; List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing thing = thingList[j]; if (thing.def.category != ThingCategory.Plant && thing.def.category != ThingCategory.Item && thing.def.category != ThingCategory.Pawn) { cellUsed = true; break; } } if (!cellUsed) { FilthMaker.MakeFilth(c, map, rockRubble, 1); } } } } }
private static void DoPickupOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (!HugsLibUtility.ShiftIsHeld) { return; } IntVec3 c = IntVec3.FromVector3(clickPos); 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)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(new object[] { 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(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(NewOrderJobDefOf.QOL_PickupObject, item); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(NewOrderJobDefOf.QOL_PickupObject, item); job.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } } }
private void GrowLowRockFormationFrom(IntVec3 root, Map map) { ThingDef rockRubble = ThingDefOf.RockRubble; ThingDef mineableThing = Find.World.NaturalRockTypesIn(map.Tile).RandomElement().building.mineableThing; Rot4 random = Rot4.Random; MapGenFloatGrid elevation = MapGenerator.Elevation; IntVec3 intVec = root; while (true) { Rot4 random2 = Rot4.Random; if (random2 == random) { continue; } intVec += random2.FacingCell; if (intVec.InBounds(map) && intVec.GetEdifice(map) == null && intVec.GetFirstItem(map) == null && !(elevation[intVec] > 0.550000011920929) && map.terrainGrid.TerrainAt(intVec).affordances.Contains(TerrainAffordance.Heavy)) { GenSpawn.Spawn(mineableThing, intVec, map); IntVec3[] adjacentCellsAndInside = GenAdj.AdjacentCellsAndInside; foreach (IntVec3 b in adjacentCellsAndInside) { if (Rand.Value < 0.5) { IntVec3 c = intVec + b; if (c.InBounds(map)) { bool flag = false; List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing thing = thingList[j]; if (thing.def.category != ThingCategory.Plant && thing.def.category != ThingCategory.Item && thing.def.category != ThingCategory.Pawn) { flag = true; break; } } if (!flag) { FilthMaker.MakeFilth(c, map, rockRubble, 1); } } } } continue; } break; } }
// returning string text assigning false reason to AcceptanceReport public override AcceptanceReport CanDesignateCell(IntVec3 cell) { if (!cell.InBounds() || cell.Fogged() || cell.ContainsStaticFire()) { return false; } var firstItem = cell.GetFirstItem(); if (firstItem != null && CanDesignateThing(firstItem).Accepted) { return true; } return false; }
// returning string text assigning false reason to AcceptanceReport public override AcceptanceReport CanDesignateCell(IntVec3 cell) { if (!cell.InBounds(Map) || cell.Fogged(Map) || cell.ContainsStaticFire(Map)) { return(false); } Thing firstItem = cell.GetFirstItem(this.Map); if (firstItem != null && this.CanDesignateThing(firstItem).Accepted) { return(true); } this.numOfContents = this.SlotsBackpackComp.slots.Count; int designationsTotalStackCount = 0; foreach (Thing designation in this.SlotsBackpackComp.designatedThings) { designationsTotalStackCount += designation.stackCount; } // No Item space or no stack space if (this.SlotsBackpackComp.designatedThings.Count + this.numOfContents >= this.MaxItem || designationsTotalStackCount + this.SlotsBackpackComp.slots.TotalStackCount >= this.SlotsBackpackComp.MaxStack) { return(new AcceptanceReport("BackpackIsFull".Translate())); } foreach (Thing designation in this.SlotsBackpackComp.designatedThings) { if (designation.def.category == ThingCategory.Item && !designation.Map.reservationManager.IsReserved(designation, Faction.OfPlayer)) { return(true); } } return(new AcceptanceReport("InvalidPutInTarget".Translate())); // Thing firstItem = cell.GetFirstItem(); // if (firstItem != null && CanDesignateThing(firstItem).Accepted) // { // return true; // } // return false; }
internal bool <> m__0(IntVec3 c) { if (c.GetFirstItem(this.map) != null) { return(false); } if (!c.Standable(this.map)) { SurfaceType surfaceType = c.GetSurfaceType(this.map); if (surfaceType != SurfaceType.Item && surfaceType != SurfaceType.Eat) { return(false); } } return(true); }
private static void SpawnShrapnel(ThingDef def, int quantity, IntVec3 center, Map map, float angle, float distanceFactor) { for (int i = 0; i < quantity; i++) { IntVec3 intVec = SkyfallerShrapnelUtility.GenerateShrapnelLocation(center, angle, distanceFactor); if (SkyfallerShrapnelUtility.IsGoodShrapnelCell(intVec, map)) { if (def.category != ThingCategory.Item || intVec.GetFirstItem(map) == null) { if (intVec.GetFirstThing(map, def) == null) { GenSpawn.Spawn(def, intVec, map, WipeMode.Vanish); } } } } }
// Token: 0x0600018B RID: 395 RVA: 0x0000EC70 File Offset: 0x0000CE70 public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; Rand.PushState(); for (int i = 0; i < Rand.RangeInclusive(5, 20); i++) { Faction faction = rp.faction; IntVec3 randomCell = rp.rect.RandomCell; bool flag = randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null; if (flag) { bool flag2 = Rand.RangeInclusive(1, 4) < 3; if (flag2) { ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive; Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish); hive.SetFaction(faction, null); foreach (CompSpawner compSpawner in hive.GetComps <CompSpawner>()) { if (compSpawner.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly) { compSpawner.TryDoSpawn(); break; } } } else { ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive; Hive hive2 = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish); hive2.SetFaction(faction, null); foreach (CompSpawner compSpawner2 in hive2.GetComps <CompSpawner>()) { if (compSpawner2.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly) { compSpawner2.TryDoSpawn(); break; } } } } } Rand.PopState(); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.faction == null || rp.faction.def.techLevel >= TechLevel.Industrial) { thingDef = ThingDefOf.StandingLamp; } else { thingDef = ThingDefOf.TorchLamp; } this.FindNearbyGlowers(rp.rect); for (int i = 0; i < rp.rect.Area / 4; i++) { IntVec3 randomCell = rp.rect.RandomCell; if (randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null) { Region region = randomCell.GetRegion(map, RegionType.Set_Passable); if (region != null && region.Room.PsychologicallyOutdoors && region.Room.UsesOutdoorTemperature) { if (!this.AnyGlowerNearby(randomCell)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(randomCell, map)) { if (rp.spawnBridgeIfTerrainCantSupportThing == null || rp.spawnBridgeIfTerrainCantSupportThing.Value) { BaseGenUtility.CheckSpawnBridgeUnder(thingDef, randomCell, Rot4.North); } Thing thing = GenSpawn.Spawn(thingDef, randomCell, map, WipeMode.Vanish); if (thing.def.CanHaveFaction && thing.Faction != rp.faction) { thing.SetFaction(rp.faction, null); } SymbolResolver_OutdoorLighting.nearbyGlowers.Add(thing.TryGetComp <CompGlower>()); } } } } } SymbolResolver_OutdoorLighting.nearbyGlowers.Clear(); }
private void TrySpawnCavePlant() { WildSpawner.undergroundCells.Clear(); CellRect.CellRectIterator iterator = CellRect.WholeMap(this.map).GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (GenPlantReproduction.GoodRoofForCavePlantReproduction(current, this.map)) { if (current.GetFirstItem(this.map) == null && current.GetFirstPawn(this.map) == null && current.GetFirstBuilding(this.map) == null) { bool flag = false; for (int i = 0; i < WildSpawner.cavePlants.Count; i++) { if (WildSpawner.cavePlants[i].CanEverPlantAt(current, this.map)) { flag = true; break; } } if (flag) { WildSpawner.undergroundCells.Add(current); } } } iterator.MoveNext(); } if (WildSpawner.undergroundCells.Any <IntVec3>()) { IntVec3 cell = WildSpawner.undergroundCells.RandomElement <IntVec3>(); ThingDef plantDef = (from x in WildSpawner.cavePlants where x.CanEverPlantAt(cell, this.map) select x).RandomElement <ThingDef>(); GenPlantReproduction.TryReproduceFrom(cell, plantDef, SeedTargFindMode.Cave, this.map); } }
internal bool <> m__0(IntVec3 x) { return(x.Standable(this.map) && x.GetFirstItem(this.map) == null); }
private bool TryFindTableCell(out IntVec3 cell) { JobDriver_HaulCorpseToPublicPlace.tmpCells.Clear(); List <Building> allBuildingsColonist = base.pawn.Map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count; i++) { Building building = allBuildingsColonist[i]; if (building.def.IsTable) { CellRect.CellRectIterator iterator = building.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; if (base.pawn.CanReserveAndReach(current, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, false) && current.GetFirstItem(base.pawn.Map) == null) { JobDriver_HaulCorpseToPublicPlace.tmpCells.Add(current); } iterator.MoveNext(); } } } if (!JobDriver_HaulCorpseToPublicPlace.tmpCells.Any()) { cell = IntVec3.Invalid; return(false); } cell = JobDriver_HaulCorpseToPublicPlace.tmpCells.RandomElement(); return(true); }
public static bool AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Thing thing in c.GetThingList(pawn.Map)) { Pawn pawn2; if ((pawn2 = (thing as Pawn)) != null) { Lord lord = pawn2.GetLord(); if (lord != null && lord.CurLordToil != null) { IEnumerable <FloatMenuOption> enumerable = lord.CurLordToil.ExtraFloatMenuOptions(pawn2, pawn); if (enumerable != null) { foreach (FloatMenuOption item8 in enumerable) { opts.Add(item8); } } } } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo item9 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForArrest(pawn), thingsOnly: true)) { bool flag = item9.HasThing && item9.Thing is Pawn && ((Pawn)item9.Thing).IsWildMan(); if (pawn.Drafted || flag) { if (item9.Thing is Pawn && (pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.HomeFaction) || pawn.InSameExtraFaction((Pawn)item9.Thing, ExtraFactionType.MiniFaction))) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "SameFaction".Translate((Pawn)item9.Thing), null)); } else if (!pawn.CanReach(item9, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else { Pawn pTarg2 = (Pawn)item9.Thing; Action action = delegate { Building_Bed building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false); if (building_Bed3 == null) { building_Bed3 = RestUtility.FindBedFor(pTarg2, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed3 == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg2, MessageTypeDefOf.RejectInput, historical: false); } else { Job job19 = JobMaker.MakeJob(JobDefOf.Arrest, pTarg2, building_Bed3); job19.count = 1; pawn.jobs.TryTakeOrderedJob(job19); if (pTarg2.Faction != null && ((pTarg2.Faction != Faction.OfPlayer && !pTarg2.Faction.Hidden) || pTarg2.IsQuestLodger())) { TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()); } } }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TryToArrest".Translate(item9.Thing.LabelCap, item9.Thing, pTarg2.GetAcceptArrestChance(pawn).ToStringPercent()), action, MenuOptionPriority.High, null, item9.Thing), pawn, pTarg2)); } } } } 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) : ((string)"ConsumeThing".Translate(t.LabelShort, t)); if (!t.IsSociallyProper(pawn)) { text = text + ": " + "ReservedForPrisoners".Translate().CapitalizeFirst(); } FloatMenuOption floatMenuOption; if (t.def.IsNonMedicalDrug && pawn.IsTeetotaler()) { floatMenuOption = new FloatMenuOption(text + ": " + TraitDefOf.DrugDesire.DataAtDegree(-1).GetLabelCapFor(pawn), null); } else if (FoodUtility.InappropriateForTitle(t.def, pawn, allowIfStarving: true)) { floatMenuOption = new FloatMenuOption(text + ": " + "FoodBelowTitleRequirements".Translate(pawn.royalty.MostSeniorTitle.def.GetLabelFor(pawn)), null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly)) { floatMenuOption = new FloatMenuOption(text + ": " + "NoPath".Translate().CapitalizeFirst(), null); } else { MenuOptionPriority priority = (t is Corpse) ? MenuOptionPriority.Low : MenuOptionPriority.Default; int maxAmountToPickup = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition))); floatMenuOption = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate { int maxAmountToPickup2 = FoodUtility.GetMaxAmountToPickup(t, pawn, FoodUtility.WillIngestStackCountOf(pawn, t.def, t.GetStatValue(StatDefOf.Nutrition))); if (maxAmountToPickup2 != 0) { t.SetForbidden(value: false); Job job18 = JobMaker.MakeJob(JobDefOf.Ingest, t); job18.count = maxAmountToPickup2; pawn.jobs.TryTakeOrderedJob(job18); } }, priority), pawn, t); if (maxAmountToPickup == 0) { floatMenuOption.action = null; } } opts.Add(floatMenuOption); } } foreach (LocalTargetInfo item10 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForQuestPawnsWhoWillJoinColony(pawn), thingsOnly: true)) { Pawn toHelpPawn = (Pawn)item10.Thing; FloatMenuOption item4 = pawn.CanReach(item10, PathEndMode.Touch, Danger.Deadly) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(toHelpPawn.IsPrisoner ? "FreePrisoner".Translate() : "OfferHelp".Translate(), delegate { pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.OfferHelp, toHelpPawn)); }, MenuOptionPriority.RescueOrCapture, null, toHelpPawn), pawn, toHelpPawn) : new FloatMenuOption("CannotGoNoPath".Translate(), null); opts.Add(item4); } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (Thing thing3 in c.GetThingList(pawn.Map)) { Corpse corpse = thing3 as Corpse; if (corpse != null && corpse.IsInValidStorage()) { StoragePriority priority2 = StoreUtility.CurrentHaulDestinationOf(corpse).GetStoreSettings().Priority; if (StoreUtility.TryFindBestBetterNonSlotGroupStorageFor(corpse, pawn, pawn.Map, priority2, Faction.OfPlayer, out IHaulDestination haulDestination, acceptSamePriority: true) && haulDestination.GetStoreSettings().Priority == priority2 && haulDestination is Building_Grave) { Building_Grave grave = haulDestination as Building_Grave; string label = "PrioritizeGeneric".Translate("Burying".Translate(), corpse.Label); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, delegate { pawn.jobs.TryTakeOrderedJob(HaulAIUtility.HaulToContainerJob(pawn, corpse, grave)); }), pawn, new LocalTargetInfo(corpse))); } } } foreach (LocalTargetInfo item11 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { Pawn victim3 = (Pawn)item11.Thing; if (!victim3.InBed() && pawn.CanReserveAndReach(victim3, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !victim3.mindState.WillJoinColonyIfRescued) { if (!victim3.IsPrisonerOfColony && (!victim3.InMentalState || victim3.health.hediffSet.HasHediff(HediffDefOf.Scaria)) && (victim3.Faction == Faction.OfPlayer || victim3.Faction == null || !victim3.Faction.HostileTo(Faction.OfPlayer))) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Rescue".Translate(victim3.LabelCap, victim3), delegate { Building_Bed building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false); if (building_Bed2 == null) { building_Bed2 = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: false, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed2 == null) { string t3 = (!victim3.RaceProps.Animal) ? ((string)"NoNonPrisonerBed".Translate()) : ((string)"NoAnimalBed".Translate()); Messages.Message("CannotRescue".Translate() + ": " + t3, victim3, MessageTypeDefOf.RejectInput, historical: false); } else { Job job17 = JobMaker.MakeJob(JobDefOf.Rescue, victim3, building_Bed2); job17.count = 1; pawn.jobs.TryTakeOrderedJob(job17); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); } }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3)); } if (victim3.RaceProps.Humanlike && (victim3.InMentalState || victim3.Faction != Faction.OfPlayer || (victim3.Downed && (victim3.guilt.IsGuilty || victim3.IsPrisonerOfColony)))) { TaggedString taggedString = "Capture".Translate(victim3.LabelCap, victim3); if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony) { taggedString += ": " + "AngersFaction".Translate().CapitalizeFirst(); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString, delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(victim3, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true); } if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim3, MessageTypeDefOf.RejectInput, historical: false); } else { Job job16 = JobMaker.MakeJob(JobDefOf.Capture, victim3, building_Bed); job16.count = 1; pawn.jobs.TryTakeOrderedJob(job16); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); if (victim3.Faction != null && victim3.Faction != Faction.OfPlayer && !victim3.Faction.Hidden && !victim3.Faction.HostileTo(Faction.OfPlayer) && !victim3.IsPrisonerOfColony) { Messages.Message("MessageCapturingWillAngerFaction".Translate(victim3.Named("PAWN")).AdjustedFor(victim3), victim3, MessageTypeDefOf.CautionInput, historical: false); } } }, MenuOptionPriority.RescueOrCapture, null, victim3), pawn, victim3)); } } } foreach (LocalTargetInfo item12 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { LocalTargetInfo localTargetInfo = item12; Pawn victim2 = (Pawn)localTargetInfo.Thing; if (victim2.Downed && pawn.CanReserveAndReach(victim2, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true) != null) { string text2 = "CarryToCryptosleepCasket".Translate(localTargetInfo.Thing.LabelCap, localTargetInfo.Thing); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action2 = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn); if (building_CryptosleepCasket == null) { building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim2, pawn, ignoreOtherReservations: true); } if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim2, MessageTypeDefOf.RejectInput, historical: false); } else { Job job15 = JobMaker.MakeJob(jDef, victim2, building_CryptosleepCasket); job15.count = 1; pawn.jobs.TryTakeOrderedJob(job15); } }; if (victim2.IsQuestLodger()) { text2 += " (" + "CryptosleepCasketGuestsNotAllowed".Translate() + ")"; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } else if (victim2.GetExtraHostFaction() != null) { text2 += " (" + "CryptosleepCasketGuestPrisonersNotAllowed".Translate() + ")"; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, null, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, action2, MenuOptionPriority.Default, null, victim2), pawn, victim2)); } } } if (ModsConfig.RoyaltyActive) { foreach (LocalTargetInfo item13 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForShuttle(pawn), thingsOnly: true)) { LocalTargetInfo localTargetInfo2 = item13; Pawn victim = (Pawn)localTargetInfo2.Thing; Predicate <Thing> validator = (Thing thing) => thing.TryGetComp <CompShuttle>()?.IsAllowedNow(victim) ?? false; Thing shuttleThing = GenClosest.ClosestThingReachable(victim.Position, victim.Map, ThingRequest.ForDef(ThingDefOf.Shuttle), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, validator); if (shuttleThing != null && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true) && !pawn.WorkTypeIsDisabled(WorkTypeDefOf.Hauling)) { string label2 = "CarryToShuttle".Translate(localTargetInfo2.Thing); Action action3 = delegate { CompShuttle compShuttle = shuttleThing.TryGetComp <CompShuttle>(); if (!compShuttle.LoadingInProgressOrReadyToLaunch) { TransporterUtility.InitiateLoading(Gen.YieldSingle(compShuttle.Transporter)); } Job job14 = JobMaker.MakeJob(JobDefOf.HaulToTransporter, victim, shuttleThing); job14.ignoreForbidden = true; job14.count = 1; pawn.jobs.TryTakeOrderedJob(job14); }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label2, action3), pawn, victim)); } } } } foreach (LocalTargetInfo item14 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForStrip(pawn), thingsOnly: true)) { LocalTargetInfo stripTarg = item14; FloatMenuOption item5 = pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly) ? ((stripTarg.Pawn == null || !stripTarg.Pawn.HasExtraHomeFaction()) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Strip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing), delegate { stripTarg.Thing.SetForbidden(value: false, warnOnFail: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Strip, stripTarg)); StrippableUtility.CheckSendStrippingImpactsGoodwillMessage(stripTarg.Thing); }), pawn, stripTarg) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null)) : new FloatMenuOption("CannotStrip".Translate(stripTarg.Thing.LabelCap, stripTarg.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null); opts.Add(item5); } ThingWithComps equipment; if (pawn.equipment != null) { 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 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 (!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_NewTmp(equipment, pawn, out cantReason, checkBonded: false)) { item6 = new FloatMenuOption("CannotEquip".Translate(labelShort) + ": " + cantReason.CapitalizeFirst(), null); } else { string text3 = "Equip".Translate(labelShort); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text3 += " " + "EquipWarningBrawler".Translate(); } if (EquipmentUtility.AlreadyBondedToWeapon(equipment, pawn)) { text3 += " " + "BladelinkAlreadyBonded".Translate(); TaggedString dialogText = "BladelinkAlreadyBondedDialog".Translate(pawn.Named("PAWN"), equipment.Named("WEAPON"), pawn.equipment.bondedWeapon.Named("BONDEDWEAPON")); item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate { Find.WindowStack.Add(new Dialog_MessageBox(dialogText)); }, MenuOptionPriority.High), pawn, equipment); } else { item6 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, 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); } } opts.Add(item6); } } foreach (Pair <CompReloadable, Thing> item15 in ReloadableUtility.FindPotentiallyReloadableGear(pawn, c.GetThingList(pawn.Map))) { CompReloadable comp = item15.First; Thing second = item15.Second; string text4 = "Reload".Translate(comp.parent.Named("GEAR"), NamedArgumentUtility.Named(comp.AmmoDef, "AMMO")) + " (" + comp.LabelRemaining + ")"; List <Thing> chosenAmmo; if (!pawn.CanReach(second, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!comp.NeedsReload(allowForcedReload: true)) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null)); } else if ((chosenAmmo = ReloadableUtility.FindEnoughAmmo(pawn, second.Position, comp, forceReload: true)) == null) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null)); } else { Action action4 = delegate { pawn.jobs.TryTakeOrderedJob(JobGiver_Reload.MakeReloadJob(comp, chosenAmmo)); }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4), pawn, second)); } } if (pawn.apparel != null) { if (pawn.Map.thingGrid.ThingAt(c, ThingCategory.Item) is Apparel apparel) { string key = "CannotWear"; string key2 = "ForceWear"; if (apparel.def.apparel.LastLayer.IsUtilityLayer) { key = "CannotEquipApparel"; key2 = "ForceEquipApparel"; } string cantReason2; FloatMenuOption item7 = (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "NoPath".Translate().CapitalizeFirst(), null) : (apparel.IsBurning() ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "Burning".Translate(), null) : (pawn.apparel.WouldReplaceLockedApparel(apparel) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "WouldReplaceLockedApparel".Translate().CapitalizeFirst(), null) : ((!ApparelUtility.HasPartsToWear(pawn, apparel.def)) ? new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + "CannotWearBecauseOfMissingBodyParts".Translate(), null) : (EquipmentUtility.CanEquip_NewTmp(apparel, pawn, out cantReason2) ? FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(key2.Translate(apparel.LabelShort, apparel), delegate { apparel.SetForbidden(value: false); Job job13 = JobMaker.MakeJob(JobDefOf.Wear, apparel); pawn.jobs.TryTakeOrderedJob(job13); }, MenuOptionPriority.High), pawn, apparel) : new FloatMenuOption(key.Translate(apparel.Label, apparel) + ": " + cantReason2, null))))); opts.Add(item7); } } if (pawn.IsFormingCaravan()) { Thing item3 = c.GetFirstItem(pawn.Map); if (item3 != null && item3.def.EverHaulable && item3.def.canLoadIntoCaravan) { Pawn packTarget = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn) ?? pawn; JobDef jobDef = (packTarget == pawn) ? JobDefOf.TakeInventory : JobDefOf.GiveToPackAnimal; if (!pawn.CanReach(item3, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, 1)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravan".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null)); } else { LordJob_FormAndSendCaravan lordJob = (LordJob_FormAndSendCaravan)pawn.GetLord().LordJob; float capacityLeft = CaravanFormingUtility.CapacityLeft(lordJob); if (item3.stackCount == 1) { float capacityLeft2 = capacityLeft - item3.GetStatValue(StatDefOf.Mass); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravan".Translate(item3.Label, item3), capacityLeft2), delegate { item3.SetForbidden(value: false, warnOnFail: false); Job job12 = JobMaker.MakeJob(jobDef, item3); job12.count = 1; job12.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job12); }, MenuOptionPriority.High), pawn, item3)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(packTarget, item3, item3.stackCount)) { opts.Add(new FloatMenuOption("CannotLoadIntoCaravanAll".Translate(item3.Label, item3) + ": " + "TooHeavy".Translate(), null)); } else { float capacityLeft3 = capacityLeft - (float)item3.stackCount * item3.GetStatValue(StatDefOf.Mass); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(CaravanFormingUtility.AppendOverweightInfo("LoadIntoCaravanAll".Translate(item3.Label, item3), capacityLeft3), delegate { item3.SetForbidden(value: false, warnOnFail: false); Job job11 = JobMaker.MakeJob(jobDef, item3); job11.count = item3.stackCount; job11.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job11); }, MenuOptionPriority.High), pawn, item3)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("LoadIntoCaravanSome".Translate(item3.LabelNoCount, item3), delegate { int to3 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(packTarget, item3), item3.stackCount); Dialog_Slider window3 = new Dialog_Slider(delegate(int val) { float capacityLeft4 = capacityLeft - (float)val * item3.GetStatValue(StatDefOf.Mass); return(CaravanFormingUtility.AppendOverweightInfo(string.Format("LoadIntoCaravanCount".Translate(item3.LabelNoCount, item3), val), capacityLeft4)); }, 1, to3, delegate(int count) { item3.SetForbidden(value: false, warnOnFail: false); Job job10 = JobMaker.MakeJob(jobDef, item3); job10.count = count; job10.checkEncumbrance = (packTarget == pawn); pawn.jobs.TryTakeOrderedJob(job10); }); Find.WindowStack.Add(window3); }, MenuOptionPriority.High), pawn, item3)); } } } } if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan()) { Thing item2 = c.GetFirstItem(pawn.Map); if (item2 != null && item2.def.EverHaulable) { if (!pawn.CanReach(item2, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, 1)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null)); } else if (item2.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item2.Label, item2), delegate { item2.SetForbidden(value: false, warnOnFail: false); Job job9 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job9.count = 1; job9.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job9); }, MenuOptionPriority.High), pawn, item2)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item2, item2.stackCount)) { opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item2.Label, item2) + ": " + "TooHeavy".Translate(), null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item2.Label, item2), delegate { item2.SetForbidden(value: false, warnOnFail: false); Job job8 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job8.count = item2.stackCount; job8.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job8); }, MenuOptionPriority.High), pawn, item2)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item2.LabelNoCount, item2), delegate { int to2 = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(pawn, item2), item2.stackCount); Dialog_Slider window2 = new Dialog_Slider("PickUpCount".Translate(item2.LabelNoCount, item2), 1, to2, delegate(int count) { item2.SetForbidden(value: false, warnOnFail: false); Job job7 = JobMaker.MakeJob(JobDefOf.TakeInventory, item2); job7.count = count; job7.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job7); }); Find.WindowStack.Add(window2); }, MenuOptionPriority.High), pawn, item2)); } } } if (!pawn.Map.IsPlayerHome && !pawn.IsFormingCaravan()) { Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { Pawn bestPackAnimal = GiveToPackAnimalUtility.UsablePackAnimalWithTheMostFreeSpace(pawn); if (bestPackAnimal != null) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, 1)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimal".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null)); } else if (item.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimal".Translate(item.Label, item), delegate { item.SetForbidden(value: false, warnOnFail: false); Job job6 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job6.count = 1; pawn.jobs.TryTakeOrderedJob(job6); }, MenuOptionPriority.High), pawn, item)); } else { if (MassUtility.WillBeOverEncumberedAfterPickingUp(bestPackAnimal, item, item.stackCount)) { opts.Add(new FloatMenuOption("CannotGiveToPackAnimalAll".Translate(item.Label, item) + ": " + "TooHeavy".Translate(), null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalAll".Translate(item.Label, item), delegate { item.SetForbidden(value: false, warnOnFail: false); Job job5 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job5.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job5); }, MenuOptionPriority.High), pawn, item)); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("GiveToPackAnimalSome".Translate(item.LabelNoCount, item), delegate { int to = Mathf.Min(MassUtility.CountToPickUpUntilOverEncumbered(bestPackAnimal, item), item.stackCount); Dialog_Slider window = new Dialog_Slider("GiveToPackAnimalCount".Translate(item.LabelNoCount, item), 1, to, delegate(int count) { item.SetForbidden(value: false, warnOnFail: false); Job job4 = JobMaker.MakeJob(JobDefOf.GiveToPackAnimal, item); job4.count = count; pawn.jobs.TryTakeOrderedJob(job4); }); Find.WindowStack.Add(window); }, MenuOptionPriority.High), pawn, item)); } } } } if (!pawn.Map.IsPlayerHome && pawn.Map.exitMapGrid.MapUsesExitGrid) { foreach (LocalTargetInfo item16 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForRescue(pawn), thingsOnly: true)) { Pawn p = (Pawn)item16.Thing; if (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony || CaravanUtility.ShouldAutoCapture(p, Faction.OfPlayer)) { IntVec3 exitSpot; if (!pawn.CanReach(p, PathEndMode.ClosestTouch, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!RCellFinder.TryFindBestExitSpot(pawn, out exitSpot)) { opts.Add(new FloatMenuOption("CannotCarryToExit".Translate(p.Label, p) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else { TaggedString taggedString2 = (p.Faction == Faction.OfPlayer || p.IsPrisonerOfColony) ? "CarryToExit".Translate(p.Label, p) : "CarryToExitAndCapture".Translate(p.Label, p); opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(taggedString2, delegate { Job job3 = JobMaker.MakeJob(JobDefOf.CarryDownedPawnToExit, p, exitSpot); job3.count = 1; job3.failIfCantJoinOrCreateCaravan = true; pawn.jobs.TryTakeOrderedJob(job3); }, MenuOptionPriority.High), pawn, item16)); } } } } if (pawn.equipment != null && pawn.equipment.Primary != null && GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForSelf(pawn), thingsOnly: true).Any()) { if (pawn.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanUnequip(pawn.equipment.Primary, pawn)) { opts.Add(new FloatMenuOption("CannotDrop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary) + ": " + "QuestRelated".Translate().CapitalizeFirst(), null)); } else { Action action5 = delegate { pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.DropEquipment, pawn.equipment.Primary)); }; opts.Add(new FloatMenuOption("Drop".Translate(pawn.equipment.Primary.Label, pawn.equipment.Primary), action5, MenuOptionPriority.Default, null, pawn)); } } foreach (LocalTargetInfo item17 in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForTrade(), thingsOnly: true)) { if (!pawn.CanReach(item17, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (pawn.skills.GetSkill(SkillDefOf.Social).TotallyDisabled) { opts.Add(new FloatMenuOption("CannotPrioritizeWorkTypeDisabled".Translate(SkillDefOf.Social.LabelCap), null)); } else if (!pawn.CanTradeWith(((Pawn)item17.Thing).Faction, ((Pawn)item17.Thing).TraderKind)) { opts.Add(new FloatMenuOption("CannotTradeMissingTitleAbility".Translate(), null)); } else { Pawn pTarg = (Pawn)item17.Thing; Action action6 = delegate { Job job2 = JobMaker.MakeJob(JobDefOf.TradeWithPawn, pTarg); job2.playerForced = true; pawn.jobs.TryTakeOrderedJob(job2); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string t2 = ""; if (pTarg.Faction != null) { t2 = " (" + pTarg.Faction.Name + ")"; } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("TradeWith".Translate(pTarg.LabelShort + ", " + pTarg.TraderKind.label) + t2, action6, MenuOptionPriority.InitiateSocial, null, item17.Thing), pawn, pTarg)); } } foreach (LocalTargetInfo casket in GenUI.TargetsAt_NewTemp(clickPos, TargetingParameters.ForOpen(pawn), thingsOnly: true)) { if (!pawn.CanReach(casket, PathEndMode.OnCell, Danger.Deadly)) { opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { opts.Add(new FloatMenuOption("CannotOpen".Translate(casket.Thing) + ": " + "Incapable".Translate(), null)); } else if (casket.Thing.Map.designationManager.DesignationOn(casket.Thing, DesignationDefOf.Open) == null) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("Open".Translate(casket.Thing), delegate { Job job = JobMaker.MakeJob(JobDefOf.Open, casket.Thing); job.ignoreDesignations = true; pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High), pawn, casket.Thing)); } } foreach (Thing item18 in pawn.Map.thingGrid.ThingsAt(c)) { foreach (FloatMenuOption floatMenuOption2 in item18.GetFloatMenuOptions(pawn)) { opts.Add(floatMenuOption2); } } void Equip() { equipment.SetForbidden(value: false); pawn.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Equip, equipment)); MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); } return(false); }
internal bool <> m__0(IntVec3 c) { bool result; if (c.Standable(this.map) && !c.Roofed(this.map) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(c, this.map) && c.GetFirstItem(this.map) == null) { result = !GenSpawn.WouldWipeAnythingWith(c, Rot4.North, ThingDefOf.Campfire, this.map, (Thing x) => x.def.category == ThingCategory.Building); } else { result = false; } return(result); }
protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; Pawn pawn = this.launcher as Pawn; if (!this.initialized) { CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_pwr"); MagicPowerSkill ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_CorpseExplosion.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_CorpseExplosion_ver"); pwrVal = pwr.level; verVal = ver.level; Initialize(); CellRect cellRect = CellRect.CenteredOn(base.Position, 1); cellRect.ClipInsideMap(map); IntVec3 curCell = cellRect.CenterCell; if (curCell.InBounds(map) && curCell.IsValid) { Pawn undead = curCell.GetFirstPawn(map); bool flag = undead != null && !undead.Dead; if (flag) { if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { this.targetPawn = undead; } if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD)) { this.targetPawn = undead; } } Thing corpseThing = curCell.GetFirstItem(map); Corpse corpse = null; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn corpsePawn = corpse.InnerPawn; if (corpsePawn.RaceProps.IsFlesh) { if (corpsePawn.RaceProps.Humanlike || corpsePawn.RaceProps.Animal) { this.targetCorpse = corpse; } } } } } } if (this.targetPawn != null && !this.targetPawn.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetPawn.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetPawn.Position.ToVector3Shifted(), map, .8f); if (this.targetPawn.RaceProps.Humanlike) { this.targetPawn.inventory.DropAllNearPawn(this.targetPawn.Position, false, true); this.targetPawn.equipment.DropAllEquipment(this.targetPawn.Position, false); this.targetPawn.apparel.DropAll(this.targetPawn.Position, false); } GenExplosion.DoExplosion(this.targetPawn.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt(Rand.Range(18f, 30f) + (5f * pwrVal)), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetPawn.Destroyed) { this.targetPawn.Destroy(); } } } if (this.targetCorpse != null && !this.targetCorpse.Destroyed) { if (this.age == 360) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "6", -.5f); } if (this.age == 300) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "5", -.5f); } if (this.age == 240) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "4", -.5f); } if (this.age == 180) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "3", -.5f); } if (this.age == 120) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "2", -.5f); } if (this.age == 60) { MoteMaker.ThrowText(this.targetCorpse.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.MoteOverhead), map, "1", -.5f); } if (this.age == 1) { //explode TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, 1.2f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .6f); TM_MoteMaker.ThrowBloodSquirt(this.targetCorpse.Position.ToVector3Shifted(), map, .8f); Pawn corpsePawn = this.targetCorpse.InnerPawn; if (corpsePawn.RaceProps.Humanlike) { corpsePawn.inventory.DropAllNearPawn(this.targetCorpse.Position, false, true); corpsePawn.equipment.DropAllEquipment(this.targetCorpse.Position, false); corpsePawn.apparel.DropAll(this.targetCorpse.Position, false); } GenExplosion.DoExplosion(this.targetCorpse.Position, map, this.radius, TMDamageDefOf.DamageDefOf.TM_CorpseExplosion, this.launcher, Mathf.RoundToInt(Rand.Range(18f, 30f) + (5f * pwrVal)), this.def.projectile.soundExplode, def, this.equipmentDef, null, 0f, 01, false, null, 0f, 0, 0.0f, true); if (!this.targetCorpse.Destroyed) { this.targetCorpse.Destroy(); } } } }
public override void DesignateSingleCell(IntVec3 cell) { DesignateThing(cell.GetFirstItem()); }
public static bool Prefix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); CompItemBelt comp = pawn.TryGetComp <CompItemBelt>(); if (comp != null) { if (c.GetThingList(pawn.Map).Count == 0 && !pawn.Drafted) { if (comp.innerContainer != null && comp.innerContainer.Count > 0) { if (!pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("IB_CannotDrop".Translate(new object[] { comp.innerContainer[0].Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("IB_DropItemBeltAll".Translate(new object[] { comp.innerContainer.ContentsString }), delegate { Job job = new Job(ItemBeltDefOf.RemoveItemFromBelt, c); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, c, "ReservedBy")); } } } foreach (Thing current in c.GetThingList(pawn.Map)) { Thing t = current; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { 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)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (item.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("IB_AddToItemBelt".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(ItemBeltDefOf.AddItemToBelt, item); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, 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(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("IB_AddAllToBelt".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(ItemBeltDefOf.AddItemToBelt, item); job.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("IB_AddSomeToBelt".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(ItemBeltDefOf.AddItemToBelt, item); job.count = count; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, -2147483648); Find.WindowStack.Add(window); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } } } } } return(true); }
private bool TrySpawnPowerTransmittingBuildingNear(IntVec3 position, Map map, Faction faction, ThingDef def, out Building newBuilding, Predicate <IntVec3> extraValidator = null) { TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassAllDestroyableThings, Danger.Deadly, false); IntVec3 loc; if (RCellFinder.TryFindRandomCellNearWith(position, delegate(IntVec3 x) { if (!x.Standable(map) || x.Roofed(map) || !this.EverPossibleToTransmitPowerAt(x, map)) { return(false); } if (!map.reachability.CanReach(position, x, PathEndMode.OnCell, traverseParams)) { return(false); } CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, def.size).GetIterator(); while (!iterator.Done()) { IntVec3 c = iterator.Current; if (!c.InBounds(map) || c.Roofed(map) || c.GetEdifice(map) != null || c.GetFirstItem(map) != null || c.GetTransmitter(map) != null) { return(false); } iterator.MoveNext(); } return(extraValidator == null || extraValidator(x)); }, map, out loc, 8, 2147483647)) { newBuilding = (Building)GenSpawn.Spawn(ThingMaker.MakeThing(def, null), loc, map, Rot4.North, WipeMode.Vanish, false); newBuilding.SetFaction(faction, null); return(true); } newBuilding = null; return(false); }
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); } } }
protected override bool TryCastShot() { CellRect cellRect = CellRect.CenteredOn(this.currentTarget.Cell, 1); Map map = base.CasterPawn.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; //FlyingObject flyingPawn = new FlyingObject(); Pawn summonablePawn = new Pawn(); bool pflag = true; Thing summonableThing = centerCell.GetFirstPawn(map); if (summonableThing == null) { pflag = false; summonableThing = centerCell.GetFirstItem(map); } else { pVect = summonableThing.TrueCenter(); pVect.x = base.caster.TrueCenter().x; pVect.z = base.caster.TrueCenter().z; pVect.y = 0f; summonablePawn = summonableThing as Pawn; if (summonablePawn != base.CasterPawn) { //flyingPawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map); } else { //flyingPawn = null; summonableThing = null; Messages.Message("TM_CantSummonSelf".Translate(), MessageTypeDefOf.NegativeEvent); } } bool result = false; bool arg_40_0; if (this.currentTarget != null && base.CasterPawn != null) { arg_40_0 = this.currentTarget.Cell.IsValid; } else { arg_40_0 = false; } bool flag = arg_40_0; if (flag) { if (summonableThing != null) { if (pflag)// && flyingPawn != null) { //Thing p = summonablePawn; if (!summonablePawn.RaceProps.Humanlike || summonablePawn.Faction == this.CasterPawn.Faction) { summonablePawn.DeSpawn(); GenSpawn.Spawn(summonablePawn, base.CasterPawn.Position, map); } else if (summonablePawn.RaceProps.Humanlike && summonablePawn.Faction != this.CasterPawn.Faction && Rand.Chance(TM_Calc.GetSpellSuccessChance(this.CasterPawn, summonablePawn, true))) { //summonablePawn.DeSpawn(); //GenSpawn.Spawn(p, base.caster.Position, base.CasterPawn.Map, Rot4.North, false); //Pawn p = summonablePawn; summonablePawn.DeSpawn(); //p.SetPositionDirect(this.currentTarget.Cell); GenSpawn.Spawn(summonablePawn, base.CasterPawn.Position, map); //flyingPawn = null; if (summonablePawn.IsColonist && !base.CasterPawn.IsColonist) { TM_Action.SpellAffectedPlayerWarning(summonablePawn); } //summonablePawn.Position = base.CasterPawn.Position; //p.jobs.StopAll(false); } else { MoteMaker.ThrowText(summonablePawn.DrawPos, summonablePawn.Map, "TM_ResistedSpell".Translate(), -1); } } else { summonableThing.DeSpawn(DestroyMode.Vanish); GenPlace.TryPlaceThing(summonableThing, this.CasterPawn.Position, this.CasterPawn.Map, ThingPlaceMode.Near); //summonableThing.Position = base.CasterPawn.Position; //summonableThing.Rotation = Rot4.North; //summonableThing.SetPositionDirect(base.CasterPawn.InteractionCell); } result = true; } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; return(result); }
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 override void DesignateSingleCell(IntVec3 cell) { this.DesignateThing(cell.GetFirstItem(Map)); }
protected override bool TryCastShot() { CellRect cellRect = CellRect.CenteredOn(this.currentTarget.Cell, 1); Map map = base.CasterPawn.Map; cellRect.ClipInsideMap(map); IntVec3 centerCell = cellRect.CenterCell; Thing summonableThing = new Thing(); //FlyingObject flyingPawn = new FlyingObject(); Pawn summonablePawn = new Pawn(); bool pflag = true; summonableThing = centerCell.GetFirstPawn(map); if (summonableThing == null) { pflag = false; summonableThing = centerCell.GetFirstItem(map); } else { pVect = summonableThing.TrueCenter(); pVect.x = base.caster.TrueCenter().x; pVect.z = base.caster.TrueCenter().z; pVect.y = 0f; summonablePawn = summonableThing as Pawn; if (summonablePawn != base.CasterPawn) { //flyingPawn = (FlyingObject)GenSpawn.Spawn(ThingDef.Named("TM_SummonedPawn"), summonableThing.Position, summonableThing.Map); } else { //flyingPawn = null; summonableThing = null; Messages.Message("TM_CantSummonSelf".Translate(), MessageTypeDefOf.NegativeEvent); } } bool result = false; bool arg_40_0; if (this.currentTarget != null && base.CasterPawn != null) { IntVec3 arg_29_0 = this.currentTarget.Cell; arg_40_0 = this.currentTarget.Cell.IsValid; } else { arg_40_0 = false; } bool flag = arg_40_0; if (flag) { if (summonableThing != null) { if (pflag)// && flyingPawn != null) { //Thing p = summonablePawn; //summonablePawn.DeSpawn(); //GenSpawn.Spawn(p, base.caster.Position, base.CasterPawn.Map, Rot4.North, false); //Pawn p = summonablePawn; summonablePawn.DeSpawn(); //p.SetPositionDirect(this.currentTarget.Cell); GenSpawn.Spawn(summonablePawn, base.CasterPawn.Position, map); //flyingPawn = null; //summonablePawn.Position = base.CasterPawn.Position; //p.jobs.StopAll(false); } else { summonableThing.Position = base.CasterPawn.Position; summonableThing.Rotation = Rot4.North; //summonableThing.SetPositionDirect(base.CasterPawn.InteractionCell); } result = true; } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60; return(result); }
private bool <FindCellToDropCorpseToil> m__3(IntVec3 x) { return(this.pawn.CanReserve(x, 1, -1, null, false) && x.GetFirstItem(this.pawn.Map) == null); }
public static bool RemoveRockFilth(ref IntVec3 root, ref Map map) { if ((map.Biome.defName == "MA_MechanoidAssimilation")) { ThingDef mineableThing = Find.World.NaturalRockTypesIn(map.Tile).RandomElement <ThingDef>().building.mineableThing; Rot4 random = Rot4.Random; MapGenFloatGrid elevation = MapGenerator.Elevation; IntVec3 intVec = root; for (; ;) { Rot4 random2 = Rot4.Random; if (!(random2 == random)) { intVec += random2.FacingCell; if (!intVec.InBounds(map) || intVec.GetEdifice(map) != null || intVec.GetFirstItem(map) != null) { break; } if (elevation[intVec] > 0.55f) { return(false); } if (!map.terrainGrid.TerrainAt(intVec).affordances.Contains(TerrainAffordanceDefOf.Heavy)) { return(false); } GenSpawn.Spawn(mineableThing, intVec, map, WipeMode.Vanish); foreach (IntVec3 b in GenAdj.AdjacentCellsAndInside) { if (Rand.Value < 0.5f) { IntVec3 c = intVec + b; if (c.InBounds(map)) { bool flag = false; List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing thing = thingList[j]; if (thing.def.category != ThingCategory.Plant && thing.def.category != ThingCategory.Item && thing.def.category != ThingCategory.Pawn) { flag = true; break; } } if (!flag) { FilthMaker.TryMakeFilth(c, map, DefDatabase <ThingDef> .GetNamed("MA_SlagRubble"), 1); } } } } } } return(false); } else { return(true); } }