コード例 #1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!RCellFinder.TryFindBestExitSpot(pawn, out var spot))
            {
                return(null);
            }
            Pawn pawn2 = KidnapAIUtility.ReachableWoundedGuest(pawn);

            if (pawn2 == null)
            {
                return(null);
            }
            Job job = JobMaker.MakeJob(JobDefOf.Kidnap);

            job.targetA = pawn2;
            job.targetB = spot;
            job.count   = 1;
            return(job);
        }
コード例 #2
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (!pawn2.guest.CanBeBroughtFood)
            {
                return(null);
            }
            if (!pawn2.Position.IsInPrisonCell(pawn2.Map))
            {
                return(null);
            }
            if (pawn2.needs.food.CurLevelPercentage >= pawn2.needs.food.PercentageThreshHungry + 0.02f)
            {
                return(null);
            }
            if (WardenFeedUtility.ShouldBeFed(pawn2))
            {
                return(null);
            }
            if (!FoodUtility.TryFindBestFoodSourceFor(pawn, pawn2, pawn2.needs.food.CurCategory == HungerCategory.Starving, out Thing foodSource, out ThingDef foodDef, canRefillDispenser: false, canUseInventory: true, allowForbidden: false, allowCorpse: false))
            {
                return(null);
            }
            if (foodSource.GetRoom() == pawn2.GetRoom())
            {
                return(null);
            }
            if (FoodAvailableInRoomTo(pawn2))
            {
                return(null);
            }
            float nutrition = FoodUtility.GetNutrition(foodSource, foodDef);
            Job   job       = JobMaker.MakeJob(JobDefOf.DeliverFood, foodSource, pawn2);

            job.count   = FoodUtility.WillIngestStackCountOf(pawn2, foodDef, nutrition);
            job.targetC = RCellFinder.SpotToChewStandingNear(pawn2, foodSource);
            return(job);
        }
コード例 #3
0
        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 IntVec3 result);
            LordJob_TradeWithColony lordJob = new LordJob_TradeWithColony(parms.faction, result);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            return(true);
        }
コード例 #4
0
        public override void Generate(Map map, GenStepParams parms)
        {
            int num = 0;

            while (!map.wildAnimalSpawner.AnimalEcosystemFull)
            {
                num++;
                if (num >= 10000)
                {
                    Log.Error("Too many iterations.");
                    break;
                }
                IntVec3 loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map);
                if (!map.wildAnimalSpawner.SpawnRandomWildAnimalAt(loc))
                {
                    break;
                }
            }
        }
コード例 #5
0
        private CellRect FindRandomRectToDefend(Map map)
        {
            if (!MapGenerator.TryGetVar("UsedRects", out List <CellRect> usedRects))
            {
                usedRects = null;
            }
            int           rectRadius     = Mathf.Max(Mathf.RoundToInt((float)Mathf.Min(map.Size.x, map.Size.z) * 0.07f), 1);
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassDoors);

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(delegate(IntVec3 x)
            {
                if (!map.reachability.CanReachMapEdge(x, traverseParams))
                {
                    return(false);
                }
                CellRect cellRect = CellRect.CenteredOn(x, rectRadius);
                int num = 0;
                foreach (IntVec3 c in cellRect)
                {
                    if (!c.InBounds(map))
                    {
                        return(false);
                    }
                    if (usedRects != null && cellRect.IsOnEdge(c) && usedRects.Any((CellRect y) => y.Contains(c)))
                    {
                        return(false);
                    }
                    if (c.Standable(map) || c.GetPlant(map) != null)
                    {
                        num++;
                    }
                }
                return((float)num / (float)cellRect.Area >= 0.6f);
            }, map, out IntVec3 result))
            {
                return(CellRect.CenteredOn(result, rectRadius));
            }
            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map), map, out result))
            {
                return(CellRect.CenteredOn(result, rectRadius));
            }
            return(CellRect.CenteredOn(CellFinder.RandomCell(map), rectRadius).ClipInsideMap(map));
        }
コード例 #6
0
ファイル: RCellFinder.cs プロジェクト: sachdevs/RW-Decompile
 internal static IntVec3 FindSiegePositionFrom(IntVec3 entrySpot, Map map)
 {
     for (int i = 70; i >= 20; i -= 10)
     {
         IntVec3 result;
         if (RCellFinder.TryFindSiegePosition(entrySpot, (float)i, map, out result))
         {
             return(result);
         }
     }
     Log.Error(string.Concat(new object[]
     {
         "Could not find siege spot from ",
         entrySpot,
         ", using ",
         entrySpot
     }));
     return(entrySpot);
 }
コード例 #7
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Job result;

            if (pawn.RaceProps.intelligence < Intelligence.Humanlike)
            {
                result = null;
            }
            else if (pawn.mindState.knownExploder == null)
            {
                result = null;
            }
            else if (!pawn.mindState.knownExploder.Spawned)
            {
                pawn.mindState.knownExploder = null;
                result = null;
            }
            else if (PawnUtility.PlayerForcedJobNowOrSoon(pawn))
            {
                result = null;
            }
            else
            {
                Thing   knownExploder = pawn.mindState.knownExploder;
                IntVec3 c;
                if ((float)(pawn.Position - knownExploder.Position).LengthHorizontalSquared > 81f)
                {
                    result = null;
                }
                else if (!RCellFinder.TryFindDirectFleeDestination(knownExploder.Position, 9f, pawn, out c))
                {
                    result = null;
                }
                else
                {
                    result = new Job(JobDefOf.Goto, c)
                    {
                        locomotionUrgency = LocomotionUrgency.Sprint
                    };
                }
            }
            return(result);
        }
コード例 #8
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!ShouldTakeCareOfPrisoner(pawn, t))
            {
                return(null);
            }
            Pawn pawn2 = (Pawn)t;

            if (pawn2.guest.interactionMode == PrisonerInteractionModeDefOf.Release && !pawn2.Downed && pawn2.Awake())
            {
                if (!RCellFinder.TryFindPrisonerReleaseCell(pawn2, pawn, out IntVec3 result))
                {
                    return(null);
                }
                Job job = new Job(JobDefOf.ReleasePrisoner, pawn2, result);
                job.count = 1;
                return(job);
            }
            return(null);
        }
コード例 #9
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c = default(IntVec3);

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                return(null);
            }
            Thing thing = default(Thing);

            if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, pawn.Map, 12f, out thing, pawn, (List <Thing>)null) && !GenAI.InDangerousCombat(pawn))
            {
                Job job = new Job(JobDefOf.Steal);
                job.targetA = thing;
                job.targetB = c;
                job.count   = Mathf.Min(thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity, true) / thing.def.VolumePerUnit));
                return(job);
            }
            return(null);
        }
コード例 #10
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c;

            if (this.ShouldStartEscaping(pawn) && RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                if (!pawn.guest.Released)
                {
                    Messages.Message("MessagePrisonerIsEscaping".Translate(new object[]
                    {
                        pawn.NameStringShort
                    }), pawn, MessageTypeDefOf.ThreatSmall);
                }
                return(new Job(JobDefOf.Goto, c)
                {
                    exitMapOnArrival = true
                });
            }
            return(null);
        }
コード例 #11
0
        public bool TryStartParty()
        {
            Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, this.map);

            if (pawn == null)
            {
                return(false);
            }
            IntVec3 intVec;

            if (!RCellFinder.TryFindPartySpot(pawn, out intVec))
            {
                return(false);
            }
            LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn), this.map, null);
            Find.LetterStack.ReceiveLetter("LetterLabelNewParty".Translate(), "LetterNewParty".Translate(pawn.LabelShort, pawn), LetterDefOf.PositiveEvent, new TargetInfo(intVec, this.map, false), null, null);
            this.lastLordStartTick = Find.TickManager.TicksGame;
            this.startPartyASAP    = false;
            return(true);
        }
コード例 #12
0
        public override void OrderForceTarget(LocalTargetInfo target)
        {
            Map     map    = CasterPawn.Map;
            IntVec3 intVec = RCellFinder.BestOrderedGotoDestNear_NewTemp(target.Cell, CasterPawn, AcceptableDestination);
            Job     job    = JobMaker.MakeJob(JobDefOf.CastJump, intVec);

            job.verbToUse = this;
            if (CasterPawn.jobs.TryTakeOrderedJob(job))
            {
                MoteMaker.MakeStaticMote(intVec, map, ThingDefOf.Mote_FeedbackGoto);
            }
            bool AcceptableDestination(IntVec3 c)
            {
                if (ValidJumpTarget(map, c))
                {
                    return(CanHitTargetFrom(caster.Position, c));
                }
                return(false);
            }
        }
コード例 #13
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c = default(IntVec3);

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                return(null);
            }
            Pawn t = default(Pawn);

            if (KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 18f, out t, (List <Thing>)null) && !GenAI.InDangerousCombat(pawn))
            {
                Job job = new Job(JobDefOf.Kidnap);
                job.targetA = t;
                job.targetB = c;
                job.count   = 1;
                return(job);
            }
            return(null);
        }
コード例 #14
0
        private CellRect FindRandomRectToDefend(Map map)
        {
            IntVec3       size           = map.Size;
            int           x2             = size.x;
            IntVec3       size2          = map.Size;
            int           rectRadius     = Mathf.Max(Mathf.RoundToInt((float)((float)Mathf.Min(x2, size2.z) * 0.070000000298023224)), 1);
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false);
            IntVec3       center         = default(IntVec3);

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((Predicate <IntVec3>) delegate(IntVec3 x)
            {
                if (!map.reachability.CanReachMapEdge(x, traverseParams))
                {
                    return(false);
                }
                CellRect cellRect = CellRect.CenteredOn(x, rectRadius);
                int num = 0;
                CellRect.CellRectIterator iterator = cellRect.GetIterator();
                while (!iterator.Done())
                {
                    if (!iterator.Current.InBounds(map))
                    {
                        return(false);
                    }
                    if (iterator.Current.Standable(map) || iterator.Current.GetPlant(map) != null)
                    {
                        num++;
                    }
                    iterator.MoveNext();
                }
                return((float)num / (float)cellRect.Area >= 0.60000002384185791);
            }, map, out center))
            {
                return(CellRect.CenteredOn(center, rectRadius));
            }
            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((Predicate <IntVec3>)((IntVec3 x) => x.Standable(map)), map, out center))
            {
                return(CellRect.CenteredOn(center, rectRadius));
            }
            return(CellRect.CenteredOn(CellFinder.RandomCell(map), rectRadius).ClipInsideMap(map));
        }
コード例 #15
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                return(null);
            }
            Pawn pawn2 = KidnapAIUtility.ReachableWoundedGuest(pawn);

            if (pawn2 == null)
            {
                return(null);
            }
            return(new Job(JobDefOf.Kidnap)
            {
                targetA = pawn2,
                targetB = c,
                count = 1
            });
        }
コード例 #16
0
        // Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                c = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(XenomorphDefOf.RRY_EggXenomorphFertilized), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 9999f, null, null, 0, -1, false, RegionType.Set_Passable, false).Position;
            }
            Pawn t;

            if (TryFindGoodKidnapVictim(pawn, 18f, out t, null) && !GenAI.InDangerousCombat(pawn))
            {
                return(new Job(JobDefOf.Kidnap)
                {
                    targetA = t,
                    targetB = c,
                    count = 1
                });
            }
            return(null);
        }
コード例 #17
0
 public static bool TryFindGoodAdjacentSpotToTouch(Pawn toucher, Thing touchee, out IntVec3 result)
 {
     foreach (IntVec3 item in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (item.Standable(toucher.Map) && !RCellFinder.ContainsKnownTrap(item, toucher.Map, toucher))
         {
             result = item;
             return(true);
         }
     }
     foreach (IntVec3 item2 in GenAdj.CellsAdjacent8Way(touchee).InRandomOrder(null))
     {
         if (item2.Walkable(toucher.Map))
         {
             result = item2;
             return(true);
         }
     }
     result = touchee.Position;
     return(false);
 }
コード例 #18
0
        public override void Generate(Map map, GenStepParams parms)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false);
            IntVec3       root;

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map) && !x.Fogged(map) && map.reachability.CanReachMapEdge(x, traverseParams) && x.GetRoom(map, RegionType.Set_Passable).CellCount >= this.MinRoomCells, map, out root))
            {
                float       randomInRange = this.pointsRange.RandomInRange;
                PawnKindDef animalKind;
                if (ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(randomInRange, map.Tile, out animalKind) || ManhunterPackIncidentUtility.TryFindManhunterAnimalKind(randomInRange, -1, out animalKind))
                {
                    List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, randomInRange);
                    for (int i = 0; i < list.Count; i++)
                    {
                        IntVec3 loc = CellFinder.RandomSpawnCellForPawnNear(root, map, 10);
                        GenSpawn.Spawn(list[i], loc, map, Rot4.Random, WipeMode.Vanish, false);
                        list[i].mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
                    }
                }
            }
        }
コード例 #19
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map         = (Map)parms.target;
            PawnKindDef alphabeaver = PawnKindDefOf.Alphabeaver;
            IntVec3     intVec;

            if (!RCellFinder.TryFindRandomPawnEntryCell(out intVec, map, CellFinder.EdgeRoadChance_Animal, null))
            {
                return(false);
            }
            int num = Rand.RangeInclusive(6, 12);

            for (int i = 0; i < num; i++)
            {
                IntVec3 loc      = CellFinder.RandomClosewalkCellNear(intVec, map, 10, null);
                Pawn    newThing = PawnGenerator.GeneratePawn(alphabeaver, null);
                GenSpawn.Spawn(newThing, loc, map);
            }
            Find.LetterStack.ReceiveLetter("LetterLabelBeaversArrived".Translate(), "BeaversArrived".Translate(), LetterDefOf.ThreatSmall, new TargetInfo(intVec, map, false), null);
            return(true);
        }
コード例 #20
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c = default(IntVec3);

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                return(null);
            }
            Pawn pawn2 = KidnapAIUtility.ReachableWoundedGuest(pawn);

            if (pawn2 == null)
            {
                return(null);
            }
            Job job = new Job(JobDefOf.Kidnap);

            job.targetA = pawn2;
            job.targetB = c;
            job.count   = 1;
            return(job);
        }
 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);
         },
コード例 #22
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 c;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
            {
                return(null);
            }
            Pawn t;

            if (KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 18f, out t, null) && !GenAI.InDangerousCombat(pawn))
            {
                return(new Job(JobDefOf.Kidnap)
                {
                    targetA = t,
                    targetB = c,
                    count = 1
                });
            }
            return(null);
        }
コード例 #23
0
        protected virtual bool ResolveRaidSpawnCenter(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (parms.spawnCenter.IsValid)
            {
                return(true);
            }
            if (parms.raidArrivalMode == PawnsArriveMode.CenterDrop || parms.raidArrivalMode == PawnsArriveMode.EdgeDrop)
            {
                if (parms.raidArrivalMode == PawnsArriveMode.CenterDrop)
                {
                    parms.raidPodOpenDelay = 520;
                    parms.spawnRotation    = Rot4.Random;
                    if (Rand.Value < 0.40000000596046448 && map.listerBuildings.ColonistsHaveBuildingWithPowerOn(ThingDefOf.OrbitalTradeBeacon))
                    {
                        parms.spawnCenter = DropCellFinder.TradeDropSpot(map);
                    }
                    else if (!DropCellFinder.TryFindRaidDropCenterClose(out parms.spawnCenter, map))
                    {
                        parms.raidArrivalMode = PawnsArriveMode.EdgeDrop;
                    }
                }
                if (parms.raidArrivalMode == PawnsArriveMode.EdgeDrop)
                {
                    parms.raidPodOpenDelay = 140;
                    parms.spawnCenter      = DropCellFinder.FindRaidDropCenterDistant(map);
                    parms.spawnRotation    = Rot4.Random;
                }
            }
            else
            {
                if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile, (Predicate <IntVec3>)null))
                {
                    return(false);
                }
                parms.spawnRotation = Rot4.FromAngleFlat((map.Center - parms.spawnCenter).AngleFlat);
            }
            return(true);
        }
コード例 #24
0
        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            = default(IntVec3);

            if (RCellFinder.TryFindRandomCellNearWith(position, (Predicate <IntVec3>) delegate(IntVec3 x)
            {
                if (x.Standable(map) && !x.Roofed(map) && this.EverPossibleToTransmitPowerAt(x, map))
                {
                    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 current = iterator.Current;
                        if (current.InBounds(map) && !current.Roofed(map) && current.GetEdifice(map) == null && current.GetFirstItem(map) == null && current.GetTransmitter(map) == null)
                        {
                            iterator.MoveNext();
                            continue;
                        }
                        return(false);
                    }
                    if (extraValidator != null && !extraValidator(x))
                    {
                        return(false);
                    }
                    return(true);
                }
                return(false);
            }, map, out loc, 8, 2147483647))
            {
                newBuilding = (Building)GenSpawn.Spawn(ThingMaker.MakeThing(def, null), loc, map, Rot4.North, false);
                newBuilding.SetFaction(faction, null);
                return(true);
            }
            newBuilding = null;
            return(false);
        }
コード例 #25
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!base.TryResolveParms(parms))
            {
                return(false);
            }
            IntVec3 travelDest;

            if (!RCellFinder.TryFindTravelDestFrom(parms.spawnCenter, map, out travelDest))
            {
                Log.Warning("Failed to do traveler incident from " + parms.spawnCenter + ": Couldn't find anywhere for the traveler to go.", false);
                return(false);
            }
            List <Pawn> list = base.SpawnPawns(parms);

            if (list.Count == 0)
            {
                return(false);
            }
            string text;

            if (list.Count == 1)
            {
                text = "SingleTravelerPassing".Translate(list[0].story.Title, parms.faction.Name, list[0].Name.ToStringFull, list[0].Named("PAWN"));
                text = text.AdjustedFor(list[0], "PAWN");
            }
            else
            {
                text = "GroupTravelersPassing".Translate(parms.faction.Name);
            }
            Messages.Message(text, list[0], MessageTypeDefOf.NeutralEvent, true);
            LordJob_TravelAndExit lordJob = new LordJob_TravelAndExit(travelDest);

            LordMaker.MakeNewLord(parms.faction, lordJob, map, list);
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, true, true);
            return(true);
        }
コード例 #26
0
 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);
 }
コード例 #27
0
        public bool TryStartMarriageCeremony(Pawn firstFiance, Pawn secondFiance)
        {
            IntVec3 intVec;
            bool    result;

            if (!RCellFinder.TryFindMarriageSite(firstFiance, secondFiance, out intVec))
            {
                result = false;
            }
            else
            {
                LordMaker.MakeNewLord(firstFiance.Faction, new LordJob_Joinable_MarriageCeremony(firstFiance, secondFiance, intVec), this.map, null);
                Messages.Message("MessageNewMarriageCeremony".Translate(new object[]
                {
                    firstFiance.LabelShort,
                    secondFiance.LabelShort
                }), new TargetInfo(intVec, this.map, false), MessageTypeDefOf.PositiveEvent, true);
                this.lastLordStartTick = Find.TickManager.TicksGame;
                result = true;
            }
            return(result);
        }
コード例 #28
0
        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));
        }
コード例 #29
0
 private bool TryFindStartAndEndCells(Map map, out IntVec3 start, out IntVec3 end)
 {
     if (!RCellFinder.TryFindRandomPawnEntryCell(out start, map, CellFinder.EdgeRoadChance_Animal))
     {
         end = IntVec3.Invalid;
         return(false);
     }
     end = IntVec3.Invalid;
     for (int i = 0; i < 8; i++)
     {
         IntVec3 startLocal = start;
         if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 x) => map.reachability.CanReach(startLocal, x, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Deadly), map, CellFinder.EdgeRoadChance_Ignore, out IntVec3 result))
         {
             break;
         }
         if (!end.IsValid || result.DistanceToSquared(start) > end.DistanceToSquared(start))
         {
             end = result;
         }
     }
     return(end.IsValid);
 }
コード例 #30
0
ファイル: GenGuest.cs プロジェクト: sachdevs/RW-Decompile
        public static void PrisonerRelease(Pawn p)
        {
            if (p.ownership != null)
            {
                p.ownership.UnclaimAll();
            }
            if (p.Faction == Faction.OfPlayer)
            {
                p.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.WasImprisoned, null);
                p.guest.SetGuestStatus(null, false);
                return;
            }
            p.guest.Released = true;
            IntVec3 c;

            if (RCellFinder.TryFindBestExitSpot(p, out c, TraverseMode.ByPawn))
            {
                Job job = new Job(JobDefOf.Goto, c);
                job.exitMapOnArrival = true;
                p.jobs.StartJob(job, JobCondition.None, null, false, true, null, null, false);
            }
        }