コード例 #1
0
        public static bool IsGoodDropSpot(IntVec3 c, Map map, bool allowFogged, bool canRoofPunch)
        {
            if (!c.InBounds(map) || !c.Standable(map))
            {
                return(false);
            }
            if (!DropCellFinder.CanPhysicallyDropInto(c, map, canRoofPunch))
            {
                if (DebugViewSettings.drawDestSearch)
                {
                    map.debugDrawer.FlashCell(c, 0f, "phys", 50);
                }
                return(false);
            }
            if (Current.ProgramState == ProgramState.Playing && !allowFogged && c.Fogged(map))
            {
                return(false);
            }
            List <Thing> thingList = c.GetThingList(map);

            for (int i = 0; i < thingList.Count; i++)
            {
                Thing thing = thingList[i];
                if (thing is IActiveDropPod || thing is Skyfaller)
                {
                    return(false);
                }
                if (thing.def.category != ThingCategory.Plant && GenSpawn.SpawningWipes(ThingDefOf.ActiveDropPod, thing.def))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
 private void BeginCallAid(Pawn caller, Map map, Faction faction, bool free, float biocodeChance = 1f)
 {
     targetingParameters = new TargetingParameters();
     targetingParameters.canTargetLocations = true;
     targetingParameters.canTargetSelf      = false;
     targetingParameters.canTargetPawns     = false;
     targetingParameters.canTargetFires     = false;
     targetingParameters.canTargetBuildings = false;
     targetingParameters.canTargetItems     = false;
     targetingParameters.validator          = delegate(TargetInfo target)
     {
         if (def.royalAid.targetingRange > 0f && target.Cell.DistanceTo(caller.Position) > def.royalAid.targetingRange)
         {
             return(false);
         }
         if (target.Cell.Fogged(map) || !DropCellFinder.CanPhysicallyDropInto(target.Cell, map, canRoofPunch: true))
         {
             return(false);
         }
         return(target.Cell.GetEdifice(map) == null && !target.Cell.Impassable(map));
     };
     this.caller        = caller;
     this.map           = map;
     calledFaction      = faction;
     this.free          = free;
     this.biocodeChance = biocodeChance;
     Find.Targeter.BeginTargeting(this);
 }
コード例 #3
0
        public static bool TryFindRaidDropCenterClose(out IntVec3 spot, Map map)
        {
            Faction faction = map.ParentFaction ?? Faction.OfPlayer;
            int     num     = 0;

            while (true)
            {
                IntVec3 root = IntVec3.Invalid;
                if (map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).Count <Pawn>() > 0)
                {
                    root = map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).RandomElement <Pawn>().Position;
                }
                else
                {
                    if (faction == Faction.OfPlayer)
                    {
                        List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist;
                        for (int i = 0; i < allBuildingsColonist.Count; i++)
                        {
                            if (DropCellFinder.TryFindDropSpotNear(allBuildingsColonist[i].Position, map, out root, true, true))
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial);
                        for (int j = 0; j < list.Count; j++)
                        {
                            if (list[j].Faction == faction && DropCellFinder.TryFindDropSpotNear(list[j].Position, map, out root, true, true))
                            {
                                break;
                            }
                        }
                    }
                    if (!root.IsValid)
                    {
                        root = DropCellFinder.RandomDropSpot(map);
                    }
                }
                spot = CellFinder.RandomClosewalkCellNear(root, map, 10, null);
                if (DropCellFinder.CanPhysicallyDropInto(spot, map, true))
                {
                    break;
                }
                num++;
                if (num > 300)
                {
                    goto Block_9;
                }
            }
            return(true);

Block_9:
            spot = CellFinderLoose.RandomCellWith((IntVec3 c) => DropCellFinder.CanPhysicallyDropInto(c, map, true), map, 1000);
            return(false);
        }
コード例 #4
0
        public static IntVec3 FindRaidDropCenterDistant(Map map)
        {
            Faction             hostFaction = map.ParentFaction ?? Faction.OfPlayer;
            IEnumerable <Thing> enumerable  = map.mapPawns.FreeHumanlikesSpawnedOfFaction(hostFaction).Cast <Thing>();

            if (hostFaction == Faction.OfPlayer)
            {
                enumerable = enumerable.Concat(map.listerBuildings.allBuildingsColonist.Cast <Thing>());
            }
            else
            {
                enumerable = enumerable.Concat(from x in map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial)
                                               where x.Faction == hostFaction
                                               select x);
            }
            int     num  = 0;
            float   num2 = 65f;
            IntVec3 intVec;

            for (;;)
            {
                intVec = CellFinder.RandomCell(map);
                num++;
                if (DropCellFinder.CanPhysicallyDropInto(intVec, map, true))
                {
                    if (num > 300)
                    {
                        break;
                    }
                    if (!intVec.Roofed(map))
                    {
                        num2 -= 0.2f;
                        bool flag = false;
                        foreach (Thing thing in enumerable)
                        {
                            if ((float)(intVec - thing.Position).LengthHorizontalSquared < num2 * num2)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag && map.reachability.CanReachFactionBase(intVec, hostFaction))
                        {
                            goto IL_167;
                        }
                    }
                }
            }
            return(intVec);

IL_167:
            return(intVec);
        }
コード例 #5
0
        public static IntVec3 FindRaidDropCenterDistant(Map map)
        {
            Faction             hostFaction = map.ParentFaction ?? Faction.OfPlayer;
            IEnumerable <Thing> first       = map.mapPawns.FreeHumanlikesSpawnedOfFaction(hostFaction).Cast <Thing>();

            first = ((hostFaction != Faction.OfPlayer) ? first.Concat(from x in map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial)
                                                                      where x.Faction == hostFaction
                                                                      select x) : first.Concat(map.listerBuildings.allBuildingsColonist.Cast <Thing>()));
            int   num  = 0;
            float num2 = 65f;

            goto IL_008e;
IL_008e:
            IntVec3 intVec;

            while (true)
            {
                intVec = CellFinder.RandomCell(map);
                num++;
                if (DropCellFinder.CanPhysicallyDropInto(intVec, map, true))
                {
                    if (num > 300)
                    {
                        return(intVec);
                    }
                    if (!intVec.Roofed(map))
                    {
                        num2 = (float)(num2 - 0.20000000298023224);
                        bool flag = false;
                        foreach (Thing item in first)
                        {
                            if ((float)(intVec - item.Position).LengthHorizontalSquared < num2 * num2)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag && map.reachability.CanReachFactionBase(intVec, hostFaction))
                        {
                            break;
                        }
                    }
                }
            }
            return(intVec);

IL_015d:
            goto IL_008e;
        }
コード例 #6
0
        private void BeginCallAid(Pawn caller, Map map, Faction faction, bool free, float biocodeChance = 1f)
        {
            IEnumerable <Faction> source = from f in (from p in map.mapPawns.AllPawnsSpawned
                                                      where p.Faction != null && !p.Faction.IsPlayer && p.Faction != faction
                                                      select p.Faction).Distinct()
                                           where f.HostileTo(Faction.OfPlayer) && !faction.HostileTo(f)
                                           select f;

            if (source.Any())
            {
                Find.WindowStack.Add(new Dialog_MessageBox("CommandCallRoyalAidWarningNonHostileFactions".Translate(faction, source.Select((Faction f) => f.NameColored.Resolve()).ToCommaList()), "Confirm".Translate(), Call, "GoBack".Translate()));
            }
            else
            {
                Call();
            }
            void Call()
            {
                targetingParameters = new TargetingParameters();
                targetingParameters.canTargetLocations = true;
                targetingParameters.canTargetSelf      = false;
                targetingParameters.canTargetPawns     = false;
                targetingParameters.canTargetFires     = false;
                targetingParameters.canTargetBuildings = false;
                targetingParameters.canTargetItems     = false;
                targetingParameters.validator          = delegate(TargetInfo target)
                {
                    if (def.royalAid.targetingRange > 0f && target.Cell.DistanceTo(caller.Position) > def.royalAid.targetingRange)
                    {
                        return(false);
                    }
                    if (target.Cell.Fogged(map) || !DropCellFinder.CanPhysicallyDropInto(target.Cell, map, canRoofPunch: true))
                    {
                        return(false);
                    }
                    return(target.Cell.GetEdifice(map) == null && !target.Cell.Impassable(map));
                };
                base.caller        = caller;
                base.map           = map;
                calledFaction      = faction;
                base.free          = free;
                this.biocodeChance = biocodeChance;
                Find.Targeter.BeginTargeting(this);
            }
        }