protected override LordJob MakeLordJob(IncidentParms parms, Map map, List <Pawn> pawns, int raidSeed) { IntVec3 originCell = (!parms.spawnCenter.IsValid) ? pawns[0].PositionHeld : parms.spawnCenter; if (parms.faction.HostileTo(Faction.OfPlayer)) { return(new LordJob_AssaultColony(parms.faction)); } RCellFinder.TryFindRandomSpotJustOutsideColony(originCell, map, out IntVec3 result); return(new LordJob_AssistColony(parms.faction, result)); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!base.TryResolveParms(parms)) { return(false); } List <Pawn> list = base.SpawnPawns(parms); if (list.Count == 0) { return(false); } IntVec3 chillSpot = default(IntVec3); RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out chillSpot); LordJob_VisitColony lordJob = new LordJob_VisitColony(parms.faction, chillSpot); LordMaker.MakeNewLord(parms.faction, lordJob, map, list); bool flag = false; if (Rand.Value < 0.75) { flag = this.TryConvertOnePawnToSmallTrader(list, parms.faction, map); } Pawn pawn = list.Find((Pawn x) => parms.faction.leader == x); string label; string text3; if (list.Count == 1) { string text = (!flag) ? string.Empty : "SingleVisitorArrivesTraderInfo".Translate(); string text2 = (pawn == null) ? string.Empty : "SingleVisitorArrivesLeaderInfo".Translate(); label = "LetterLabelSingleVisitorArrives".Translate(); text3 = "SingleVisitorArrives".Translate(list[0].story.Title.ToLower(), parms.faction.Name, list[0].Name, text, text2); text3 = text3.AdjustedFor(list[0]); } else { string text4 = (!flag) ? string.Empty : "GroupVisitorsArriveTraderInfo".Translate(); string text5 = (pawn == null) ? string.Empty : "GroupVisitorsArriveLeaderInfo".Translate(pawn.LabelShort); label = "LetterLabelGroupVisitorsArrive".Translate(); text3 = "GroupVisitorsArrive".Translate(parms.faction.Name, text4, text5); } PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref text3, "LetterRelatedPawnsNeutralGroup".Translate(), true, true); Find.LetterStack.ReceiveLetter(label, text3, LetterDefOf.NeutralEvent, list[0], null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!base.TryResolveParms(parms)) { return(false); } if (parms.faction.HostileTo(Faction.OfPlayer)) { return(false); } List <Pawn> list = base.SpawnPawns(parms); if (list.Count == 0) { return(false); } for (int i = 0; i < list.Count; i++) { if (list[i].needs != null && list[i].needs.food != null) { list[i].needs.food.CurLevel = list[i].needs.food.MaxLevel; } } TraderKindDef traderKindDef = null; for (int j = 0; j < list.Count; j++) { Pawn pawn = list[j]; if (pawn.TraderKind != null) { traderKindDef = pawn.TraderKind; break; } } string label = "LetterLabelTraderCaravanArrival".Translate(parms.faction.Name, traderKindDef.label).CapitalizeFirst(); string text = "LetterTraderCaravanArrival".Translate(parms.faction.Name, traderKindDef.label).CapitalizeFirst(); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref label, ref text, "LetterRelatedPawnsNeutralGroup".Translate(), true, true); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.PositiveEvent, list[0], null); IntVec3 chillSpot = default(IntVec3); RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out chillSpot); LordJob_TradeWithColony lordJob = new LordJob_TradeWithColony(parms.faction, chillSpot); LordMaker.MakeNewLord(parms.faction, lordJob, map, list); return(true); }
public override void UpdateAllDuties() { LordToilData_HuntEnemies data = this.Data; for (int i = 0; i < this.lord.ownedPawns.Count; i++) { Pawn pawn = this.lord.ownedPawns[i]; if (!data.fallbackLocation.IsValid) { RCellFinder.TryFindRandomSpotJustOutsideColony(this.lord.ownedPawns[0], out data.fallbackLocation); } pawn.mindState.duty = new PawnDuty(DutyDefOf.HuntEnemiesIndividual); pawn.mindState.duty.focusSecond = data.fallbackLocation; } }
protected override LordJob MakeLordJob(IncidentParms parms, Map map, List <Pawn> pawns, int raidSeed) { IntVec3 originCell = (!parms.spawnCenter.IsValid) ? pawns[0].PositionHeld : parms.spawnCenter; LordJob result; if (parms.faction.HostileTo(Faction.OfPlayer)) { result = new LordJob_AssaultColony(parms.faction, true, true, false, false, true); } else { IntVec3 fallbackLocation; RCellFinder.TryFindRandomSpotJustOutsideColony(originCell, map, out fallbackLocation); result = new LordJob_AssistColony(parms.faction, fallbackLocation); } return(result); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryResolveParms(parms)) { return(false); } List <Pawn> list = SpawnPawns(parms); if (list.Count == 0) { return(false); } RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out IntVec3 result); LordJob_VisitColony lordJob = new LordJob_VisitColony(parms.faction, result); LordMaker.MakeNewLord(parms.faction, lordJob, map, list); bool flag = false; if (Rand.Value < 0.75f) { flag = TryConvertOnePawnToSmallTrader(list, parms.faction, map); } Pawn pawn = list.Find((Pawn x) => parms.faction.leader == x); string letterLabel; string letterText; if (list.Count == 1) { string value = (!flag) ? string.Empty : ("\n\n" + "SingleVisitorArrivesTraderInfo".Translate(list[0].Named("PAWN")).AdjustedFor(list[0])); string value2 = (pawn == null) ? string.Empty : ("\n\n" + "SingleVisitorArrivesLeaderInfo".Translate(list[0].Named("PAWN")).AdjustedFor(list[0])); letterLabel = "LetterLabelSingleVisitorArrives".Translate(); letterText = "SingleVisitorArrives".Translate(list[0].story.Title, parms.faction.Name, list[0].Name.ToStringFull, value, value2, list[0].Named("PAWN")).AdjustedFor(list[0]); } else { string value3 = (!flag) ? string.Empty : ("\n\n" + "GroupVisitorsArriveTraderInfo".Translate()); string value4 = (pawn == null) ? string.Empty : ("\n\n" + "GroupVisitorsArriveLeaderInfo".Translate(pawn.LabelShort, pawn)); letterLabel = "LetterLabelGroupVisitorsArrive".Translate(); letterText = "GroupVisitorsArrive".Translate(parms.faction.Name, value3, value4); } PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NeutralEvent, list[0], parms.faction); return(true); }
private void <FindCellToDropCorpseToil> m__0() { IntVec3 c = IntVec3.Invalid; if (!Rand.Chance(0.8f) || !this.TryFindTableCell(out c)) { bool flag = false; IntVec3 root; if (RCellFinder.TryFindRandomSpotJustOutsideColony(this.pawn, out root) && CellFinder.TryRandomClosewalkCellNear(root, this.pawn.Map, 5, out c, (IntVec3 x) => this.pawn.CanReserve(x, 1, -1, null, false) && x.GetFirstItem(this.pawn.Map) == null)) { flag = true; } if (!flag) { c = CellFinder.RandomClosewalkCellNear(this.pawn.Position, this.pawn.Map, 10, (IntVec3 x) => this.pawn.CanReserve(x, 1, -1, null, false) && x.GetFirstItem(this.pawn.Map) == null); } } this.job.SetTarget(TargetIndex.C, c); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TryResolveParms(parms)) { return(false); } if (parms.faction.HostileTo(Faction.OfPlayer)) { return(false); } List <Pawn> list = SpawnPawns(parms); if (list.Count == 0) { return(false); } for (int i = 0; i < list.Count; i++) { if (list[i].needs != null && list[i].needs.food != null) { list[i].needs.food.CurLevel = list[i].needs.food.MaxLevel; } } TraderKindDef traderKind = null; for (int j = 0; j < list.Count; j++) { Pawn pawn = list[j]; if (pawn.TraderKind != null) { traderKind = pawn.TraderKind; break; } } SendLetter(parms, list, traderKind); RCellFinder.TryFindRandomSpotJustOutsideColony(list[0], out var result); LordJob_TradeWithColony lordJob = new LordJob_TradeWithColony(parms.faction, result); LordMaker.MakeNewLord(parms.faction, lordJob, map, list); return(true); }
private Toil FindCellToDropCorpseToil() { return(new Toil { initAction = delegate { IntVec3 result = IntVec3.Invalid; if (!Rand.Chance(0.8f) || !TryFindTableCell(out result)) { bool flag = false; if (RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out var result2) && CellFinder.TryRandomClosewalkCellNear(result2, pawn.Map, 5, out result, (IntVec3 x) => pawn.CanReserve(x) && x.GetFirstItem(pawn.Map) == null)) { flag = true; } if (!flag) { result = CellFinder.RandomClosewalkCellNear(pawn.Position, pawn.Map, 10, (IntVec3 x) => pawn.CanReserve(x) && x.GetFirstItem(pawn.Map) == null); } } job.SetTarget(TargetIndex.C, result); },
public override void UpdateAllDuties() { LordToilData_HuntEnemies data = Data; if (!data.fallbackLocation.IsValid) { for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; if (pawn.Spawned && RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out data.fallbackLocation) && data.fallbackLocation.IsValid) { break; } } } for (int j = 0; j < lord.ownedPawns.Count; j++) { Pawn pawn2 = lord.ownedPawns[j]; pawn2.mindState.duty = new PawnDuty(DutyDefOf.HuntEnemiesIndividual); pawn2.mindState.duty.focusSecond = data.fallbackLocation; } }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.guest != null && pawn.guest.ShouldWaitInsteadOfEscaping) { Room room = pawn.GetRoom(RegionType.Set_Passable); if (room != null && room.isPrisonCell) { return(null); } IntVec3 spotToWaitInsteadOfEscaping = pawn.guest.spotToWaitInsteadOfEscaping; if (!spotToWaitInsteadOfEscaping.IsValid || !pawn.CanReach(spotToWaitInsteadOfEscaping, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { if (!RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out spotToWaitInsteadOfEscaping)) { return(null); } pawn.guest.spotToWaitInsteadOfEscaping = spotToWaitInsteadOfEscaping; } return(base.TryGiveJob(pawn)); } return(null); }
private bool TryFindRandomPackingSpot(IntVec3 exitSpot, out IntVec3 packingSpot) { Dialog_FormCaravan.tmpPackingSpots.Clear(); List <Thing> list = this.map.listerThings.ThingsOfDef(ThingDefOf.CaravanPackingSpot); TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false); for (int i = 0; i < list.Count; i++) { if (this.map.reachability.CanReach(exitSpot, list[i], PathEndMode.OnCell, traverseParams)) { Dialog_FormCaravan.tmpPackingSpots.Add(list[i]); } } if (Dialog_FormCaravan.tmpPackingSpots.Any <Thing>()) { Thing thing = Dialog_FormCaravan.tmpPackingSpots.RandomElement <Thing>(); Dialog_FormCaravan.tmpPackingSpots.Clear(); packingSpot = thing.Position; return(true); } return(RCellFinder.TryFindRandomSpotJustOutsideColony(exitSpot, this.map, out packingSpot)); }
protected override Job TryGiveJob(Pawn pawn) { Room room = pawn.GetRoom(); if (room.PsychologicallyOutdoors && room.TouchesMapEdge) { return(null); } if (!pawn.CanReachMapEdge()) { return(null); } if (!RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out IntVec3 result)) { return(null); } if (result == pawn.Position) { return(null); } return(JobMaker.MakeJob(JobDefOf.Goto, result)); }
public static bool TryFindStoreCellNearColonyDesperate(Thing item, Pawn carrier, out IntVec3 storeCell) { if (StoreUtility.TryFindBestBetterStoreCellFor(item, carrier, carrier.Map, StoragePriority.Unstored, carrier.Faction, out storeCell, true)) { return(true); } for (int i = -4; i < 20; i++) { int num = (i >= 0) ? i : Rand.RangeInclusive(0, 4); IntVec3 intVec = carrier.Position + GenRadial.RadialPattern[num]; if (intVec.InBounds(carrier.Map) && carrier.Map.areaManager.Home[intVec] && carrier.CanReach(intVec, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) && intVec.GetSlotGroup(carrier.Map) == null && StoreUtility.IsGoodStoreCell(intVec, carrier.Map, item, carrier, carrier.Faction)) { storeCell = intVec; return(true); } } if (RCellFinder.TryFindRandomSpotJustOutsideColony(carrier.Position, carrier.Map, carrier, out storeCell, (IntVec3 x) => x.GetSlotGroup(carrier.Map) == null && StoreUtility.IsGoodStoreCell(x, carrier.Map, item, carrier, carrier.Faction))) { return(true); } storeCell = IntVec3.Invalid; return(false); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.guest == null || !pawn.guest.ShouldWaitInsteadOfEscaping) { return(null); } Room room = pawn.GetRoom(); if (room != null && room.isPrisonCell) { return(null); } IntVec3 result = pawn.guest.spotToWaitInsteadOfEscaping; if (!result.IsValid || !pawn.CanReach(result, PathEndMode.OnCell, Danger.Deadly)) { if (!RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out result)) { return(null); } pawn.guest.spotToWaitInsteadOfEscaping = result; } return(base.TryGiveJob(pawn)); }
protected override Job TryGiveJob(Pawn pawn) { Room room = pawn.GetRoom(RegionType.Set_Passable); if (room.PsychologicallyOutdoors && room.TouchesMapEdge) { return(null); } if (!pawn.CanReachMapEdge()) { return(null); } IntVec3 intVec; if (!RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out intVec)) { return(null); } if (intVec == pawn.Position) { return(null); } return(new Job(JobDefOf.Goto, intVec)); }
public static bool TryFindRandomSpotJustOutsideColony(IntVec3 originCell, Map map, out IntVec3 result) { return(RCellFinder.TryFindRandomSpotJustOutsideColony(originCell, map, null, out result, null)); }
// Token: 0x06003DA8 RID: 15784 RVA: 0x0016D79C File Offset: 0x0016B99C protected override bool TryFindGoodExitDest(Pawn pawn, bool canDig, out IntVec3 spot) { TraverseMode mode = canDig ? TraverseMode.PassAllDestroyableThings : TraverseMode.ByPawn; return(RCellFinder.TryFindRandomSpotJustOutsideColony(pawn, out spot)); //RCellFinder.TryFindBestExitSpot(pawn, out spot, mode); }
public static bool TryGetCeremonySpot(Pawn pawn, Faction bestowingFaction, out LocalTargetInfo spot, out IntVec3 absoluteSpot) { Building_Throne throne; Room throneRoom; if (pawn != null) { RoyalTitleDef titleAwardedWhenUpdating = pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction)); if (titleAwardedWhenUpdating != null && titleAwardedWhenUpdating.throneRoomRequirements != null && pawn.ownership.AssignedThrone != null) { throne = pawn.ownership.AssignedThrone; throneRoom = throne.GetRoom(); spot = throne; IntVec3 facingCell = spot.Thing.Rotation.FacingCell; absoluteSpot = spot.Thing.InteractionCell + facingCell * 3; bool flag = false; for (int i = 0; i < 3; i++) { if (ValidateSpot(absoluteSpot)) { flag = true; break; } absoluteSpot -= facingCell; } if (flag) { return(true); } absoluteSpot = spot.Thing.InteractionCell - facingCell * 3; for (int j = 0; j < 3; j++) { if (ValidateSpot(absoluteSpot)) { flag = true; break; } absoluteSpot += facingCell; } if (flag) { return(true); } if (throneRoom != null && throneRoom.Cells.Where((IntVec3 c) => ValidateSpot(c)).TryRandomElementByWeight((IntVec3 c) => c.DistanceTo(throne.Position), out absoluteSpot)) { return(true); } } if (pawn.Map != null && pawn.Map.IsPlayerHome && (RCellFinder.TryFindGatheringSpot_NewTemp(pawn, GatheringDefOf.Party, ignoreRequiredColonistCount: true, out var result) || RCellFinder.TryFindRandomSpotJustOutsideColony(pawn.Position, pawn.Map, out result))) { spot = (absoluteSpot = result); return(true); } } spot = LocalTargetInfo.Invalid; absoluteSpot = IntVec3.Invalid; return(false); bool ValidateSpot(IntVec3 s) { if (!s.InBounds(throne.Map)) { return(false); } if (!s.Standable(throne.Map)) { return(false); } if (s.GetRoom(throne.Map) != throneRoom) { return(false); } return(true); } }
public static bool TryFindRandomSpotJustOutsideColony(Pawn searcher, out IntVec3 result) { return(RCellFinder.TryFindRandomSpotJustOutsideColony(searcher.Position, searcher.Map, searcher, out result, null)); }