protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            if (!base.CanScatterAt(c, map))
            {
                return(false);
            }
            if (!c.Standable(map))
            {
                return(false);
            }
            if (c.Roofed(map))
            {
                return(false);
            }
            if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors)))
            {
                return(false);
            }
            IntRange settlementSizeRange = SettlementSizeRange;
            int      min      = settlementSizeRange.min;
            CellRect cellRect = new CellRect(c.x - min / 2, c.z - min / 2, min, min);
            IntVec3  size     = map.Size;
            int      x        = size.x;
            IntVec3  size2    = map.Size;

            if (!cellRect.FullyContainedWithin(new CellRect(0, 0, x, size2.z)))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        private static void GeneratePods(ResolveParams rp, int num2, int num, IntVec3 bottomLeft)
        {
            var podContentsType = rp.podContentsType;

            if (podContentsType == null)
            {
                var value = Rand.Value;
                switch (value)
                {
                case < 0.5f:
                    break;

                case < 0.7f:
                    podContentsType = PodContentsType.Slave;
                    break;

                default:
                    podContentsType = PodContentsType.AncientHostile;
                    break;
                }
            }

            var ancientCryptosleepCasketGroupID = rp.ancientCryptosleepCasketGroupID;
            var value2 = ancientCryptosleepCasketGroupID ??
                         Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID();
            var num3 = 0;

            for (var i = 0; i < num2; i++)
            {
                for (var j = 0; j < num; j++)
                {
                    if (Rand.Chance(0.25f))
                    {
                        continue;
                    }

                    if (num3 >= 6)
                    {
                        break;
                    }

                    var rect = new CellRect(
                        bottomLeft.x + (j * (StandardAncientShrineSize.x + 1)),
                        bottomLeft.z + (i * (StandardAncientShrineSize.z + 1)),
                        StandardAncientShrineSize.x,
                        StandardAncientShrineSize.z);
                    if (!rect.FullyContainedWithin(rp.rect))
                    {
                        continue;
                    }

                    var resolveParams = rp;
                    resolveParams.rect = rect;
                    resolveParams.ancientCryptosleepCasketGroupID = value2;
                    resolveParams.podContentsType = podContentsType;
                    BaseGen.symbolStack.Push("ancientShrine", resolveParams);
                    num3++;
                }
            }
        }
Exemple #3
0
        private bool TryFindMortarSpawnCell(CellRect rect, Rot4 rot, ThingDef mortarDef, out IntVec3 cell)
        {
            Map map = BaseGen.globalSettings.map;
            Predicate <CellRect> edgeTouchCheck;

            if (rot == Rot4.North)
            {
                edgeTouchCheck = (CellRect x) => x.Cells.Any((IntVec3 y) => y.z == rect.maxZ);
            }
            else if (rot == Rot4.South)
            {
                edgeTouchCheck = (CellRect x) => x.Cells.Any((IntVec3 y) => y.z == rect.minZ);
            }
            else if (rot == Rot4.West)
            {
                edgeTouchCheck = (CellRect x) => x.Cells.Any((IntVec3 y) => y.x == rect.minX);
            }
            else
            {
                edgeTouchCheck = (CellRect x) => x.Cells.Any((IntVec3 y) => y.x == rect.maxX);
            }
            return(CellFinder.TryFindRandomCellInsideWith(rect, delegate(IntVec3 x)
            {
                CellRect obj = GenAdj.OccupiedRect(x, rot, mortarDef.size);
                if (!ThingUtility.InteractionCellWhenAt(mortarDef, x, rot, map).Standable(map))
                {
                    return false;
                }
                return obj.FullyContainedWithin(rect) && edgeTouchCheck(obj);
            }, out cell));
        }
Exemple #4
0
        protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            if (!base.CanScatterAt(c, map))
            {
                return(false);
            }
            if (!c.Standable(map))
            {
                return(false);
            }
            if (c.Roofed(map))
            {
                return(false);
            }
            if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                return(false);
            }
            CellRect cellRect = new CellRect(c.x - GenStep_EscapeShip.EscapeShipSizeWidth.min / 2, c.z - GenStep_EscapeShip.EscapeShipSizeHeight.min / 2, GenStep_EscapeShip.EscapeShipSizeWidth.min, GenStep_EscapeShip.EscapeShipSizeHeight.min);

            if (!cellRect.FullyContainedWithin(new CellRect(0, 0, map.Size.x, map.Size.z)))
            {
                return(false);
            }
            foreach (IntVec3 c2 in cellRect)
            {
                TerrainDef terrainDef = map.terrainGrid.TerrainAt(c2);
                if (!terrainDef.affordances.Contains(TerrainAffordanceDefOf.Heavy) && (terrainDef.driesTo == null || !terrainDef.driesTo.affordances.Contains(TerrainAffordanceDefOf.Heavy)))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #5
0
        protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            bool result;

            if (!base.CanScatterAt(c, map))
            {
                result = false;
            }
            else if (!c.Standable(map))
            {
                result = false;
            }
            else if (c.Roofed(map))
            {
                result = false;
            }
            else if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                result = false;
            }
            else
            {
                int      min      = GenStep_Settlement.SettlementSizeRange.min;
                CellRect cellRect = new CellRect(c.x - min / 2, c.z - min / 2, min, min);
                result = cellRect.FullyContainedWithin(new CellRect(0, 0, map.Size.x, map.Size.z));
            }
            return(result);
        }
        protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            if (!base.CanScatterAt(c, map))
            {
                return(false);
            }
            if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                return(false);
            }
            CellRect rect = CellRect.CenteredOn(c, Size, Size);

            if (!rect.FullyContainedWithin(new CellRect(0, 0, map.Size.x, map.Size.z)))
            {
                return(false);
            }
            foreach (IntVec3 cell in rect.Cells)
            {
                TerrainDef terrain = map.terrainGrid.TerrainAt(cell);
                if (!terrain.affordances.Contains(TerrainAffordance.Heavy) && terrain.driesTo != null)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #7
0
        public override void Resolve(ResolveParams rp)
        {
            int             num = rp.rect.Width + 1;
            IntVec2         standardAncientShrineSize = StandardAncientShrineSize;
            int             num2 = num / (standardAncientShrineSize.x + 1);
            int             num3 = rp.rect.Height + 1;
            IntVec2         standardAncientShrineSize2 = StandardAncientShrineSize;
            int             num4            = num3 / (standardAncientShrineSize2.z + 1);
            IntVec3         bottomLeft      = rp.rect.BottomLeft;
            PodContentsType?podContentsType = rp.podContentsType;

            if (!podContentsType.HasValue)
            {
                float value = Rand.Value;
                podContentsType = ((value < 0.5f) ? null : ((!(value < 0.7f)) ? new PodContentsType?(PodContentsType.AncientHostile) : new PodContentsType?(PodContentsType.Slave)));
            }
            int?ancientCryptosleepCasketGroupID = rp.ancientCryptosleepCasketGroupID;
            int value2 = (!ancientCryptosleepCasketGroupID.HasValue) ? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID() : ancientCryptosleepCasketGroupID.Value;
            int num5   = 0;

            for (int i = 0; i < num4; i++)
            {
                for (int j = 0; j < num2; j++)
                {
                    if (!Rand.Chance(0.25f))
                    {
                        if (num5 >= 6)
                        {
                            break;
                        }
                        int      x    = bottomLeft.x;
                        int      num6 = j;
                        IntVec2  standardAncientShrineSize3 = StandardAncientShrineSize;
                        int      minX = x + num6 * (standardAncientShrineSize3.x + 1);
                        int      z    = bottomLeft.z;
                        int      num7 = i;
                        IntVec2  standardAncientShrineSize4 = StandardAncientShrineSize;
                        int      minZ = z + num7 * (standardAncientShrineSize4.z + 1);
                        IntVec2  standardAncientShrineSize5 = StandardAncientShrineSize;
                        int      x2 = standardAncientShrineSize5.x;
                        IntVec2  standardAncientShrineSize6 = StandardAncientShrineSize;
                        CellRect rect = new CellRect(minX, minZ, x2, standardAncientShrineSize6.z);
                        if (rect.FullyContainedWithin(rp.rect))
                        {
                            ResolveParams resolveParams = rp;
                            resolveParams.rect = rect;
                            resolveParams.ancientCryptosleepCasketGroupID = value2;
                            resolveParams.podContentsType = podContentsType;
                            BaseGen.symbolStack.Push("ancientShrine", resolveParams);
                            num5++;
                        }
                    }
                }
            }
        }
Exemple #8
0
        private static void GeneratePods(ResolveParams rp, int num2, int num, IntVec3 bottomLeft)
        {
            PodContentsType?podContentsType = rp.podContentsType;

            if (podContentsType == null)
            {
                var value = Rand.Value;
                if (value < 0.5f)
                {
                    podContentsType = null;
                }
                else if (value < 0.7f)
                {
                    podContentsType = new PodContentsType?(PodContentsType.Slave);
                }
                else
                {
                    podContentsType = new PodContentsType?(PodContentsType.AncientHostile);
                }
            }
            var ancientCryptosleepCasketGroupID = rp.ancientCryptosleepCasketGroupID;
            var value2 = (ancientCryptosleepCasketGroupID == null)
                                ? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID()
                                : ancientCryptosleepCasketGroupID.Value;
            var num3 = 0;

            for (var i = 0; i < num2; i++)
            {
                for (var j = 0; j < num; j++)
                {
                    if (!Rand.Chance(0.25f))
                    {
                        if (num3 >= 6)
                        {
                            break;
                        }
                        var rect = new CellRect(
                            bottomLeft.x + (j * (StandardAncientShrineSize.x + 1)),
                            bottomLeft.z + (i * (StandardAncientShrineSize.z + 1)),
                            StandardAncientShrineSize.x,
                            StandardAncientShrineSize.z);
                        if (rect.FullyContainedWithin(rp.rect))
                        {
                            ResolveParams resolveParams = rp;
                            resolveParams.rect = rect;
                            resolveParams.ancientCryptosleepCasketGroupID = new int?(value2);
                            resolveParams.podContentsType = podContentsType;
                            BaseGen.symbolStack.Push("ancientShrine", resolveParams);
                            num3++;
                        }
                    }
                }
            }
        }
Exemple #9
0
        public override void Resolve(ResolveParams rp)
        {
            int             num             = (rp.rect.Width + 1) / (SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.x + 1);
            int             num2            = (rp.rect.Height + 1) / (SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.z + 1);
            IntVec3         bottomLeft      = rp.rect.BottomLeft;
            PodContentsType?podContentsType = rp.podContentsType;

            if (!podContentsType.HasValue)
            {
                float value = Rand.Value;
                if (value < 0.5f)
                {
                    podContentsType = null;
                }
                else if (value < 0.7f)
                {
                    podContentsType = new PodContentsType?(PodContentsType.Slave);
                }
                else
                {
                    podContentsType = new PodContentsType?(PodContentsType.AncientHostile);
                }
            }
            int?ancientCryptosleepCasketGroupID = rp.ancientCryptosleepCasketGroupID;
            int value2 = (!ancientCryptosleepCasketGroupID.HasValue) ? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID() : ancientCryptosleepCasketGroupID.Value;
            int num3   = 0;

            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    if (!Rand.Chance(0.25f))
                    {
                        if (num3 >= 6)
                        {
                            break;
                        }
                        CellRect rect = new CellRect(bottomLeft.x + j * (SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.x + 1), bottomLeft.z + i * (SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.z + 1), SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.x, SymbolResolver_AncientShrinesGroup.StandardAncientShrineSize.z);
                        if (rect.FullyContainedWithin(rp.rect))
                        {
                            ResolveParams resolveParams = rp;
                            resolveParams.rect = rect;
                            resolveParams.ancientCryptosleepCasketGroupID = new int?(value2);
                            resolveParams.podContentsType = podContentsType;
                            BaseGen.symbolStack.Push("ancientShrine", resolveParams);
                            num3++;
                        }
                    }
                }
            }
        }
        protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            if (!base.CanScatterAt(c, map))
            {
                return(false);
            }
            if (!c.Standable(map))
            {
                return(false);
            }
            if (c.Roofed(map))
            {
                return(false);
            }
            if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                return(false);
            }
            int      x = c.x;
            IntRange escapeShipSizeWidth = GenStep_EscapeShip.EscapeShipSizeWidth;
            int      minX = x - escapeShipSizeWidth.min / 2;
            int      z    = c.z;
            IntRange escapeShipSizeHeight = GenStep_EscapeShip.EscapeShipSizeHeight;
            int      minZ = z - escapeShipSizeHeight.min / 2;
            IntRange escapeShipSizeWidth2 = GenStep_EscapeShip.EscapeShipSizeWidth;
            int      min = escapeShipSizeWidth2.min;
            IntRange escapeShipSizeHeight2 = GenStep_EscapeShip.EscapeShipSizeHeight;
            CellRect cellRect = new CellRect(minX, minZ, min, escapeShipSizeHeight2.min);
            IntVec3  size     = map.Size;
            int      x2       = size.x;
            IntVec3  size2    = map.Size;

            if (!cellRect.FullyContainedWithin(new CellRect(0, 0, x2, size2.z)))
            {
                return(false);
            }
            foreach (IntVec3 item in cellRect)
            {
                TerrainDef terrainDef = map.terrainGrid.TerrainAt(item);
                if (!terrainDef.affordances.Contains(TerrainAffordance.Heavy) && (terrainDef.driesTo == null || !terrainDef.driesTo.affordances.Contains(TerrainAffordance.Heavy)))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #11
0
        public override void Resolve(ResolveParams rp)
        {
            Map             map             = BaseGen.globalSettings.map;
            int             num             = (rp.rect.Width + Mathf.Max(-1, 0)) / (StandardAncientShrineSize.x + -1);
            int             num2            = (rp.rect.Height + Mathf.Max(-1, 0)) / (StandardAncientShrineSize.z + -1);
            IntVec3         bottomLeft      = rp.rect.BottomLeft;
            PodContentsType?podContentsType = rp.podContentsType;

            if (!podContentsType.HasValue)
            {
                float value = Rand.Value;
                podContentsType = ((value < 0.5f) ? null : ((value < 0.7f) ? new PodContentsType?(PodContentsType.Slave) : new PodContentsType?(PodContentsType.AncientHostile)));
            }
            int value2 = rp.ancientCryptosleepCasketGroupID ?? Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID();
            int num3   = 0;

            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    if (!Rand.Chance(0.25f))
                    {
                        if (num3 >= 6)
                        {
                            break;
                        }
                        CellRect rect = new CellRect(bottomLeft.x + j * (StandardAncientShrineSize.x + -1), bottomLeft.z + i * (StandardAncientShrineSize.z + -1), StandardAncientShrineSize.x, StandardAncientShrineSize.z);
                        if (rect.FullyContainedWithin(rp.rect) && ThingUtility.InteractionCellWhenAt(center: new IntVec3(rect.minX + rect.Width / 2 - 1, 0, rect.minZ + rect.Height / 2), def: ThingDefOf.AncientCryptosleepCasket, rot: Rot4.East, map: map).Standable(map))
                        {
                            ResolveParams resolveParams = rp;
                            resolveParams.rect = rect;
                            resolveParams.ancientCryptosleepCasketGroupID = value2;
                            resolveParams.podContentsType = podContentsType;
                            BaseGen.symbolStack.Push("ancientShrine", resolveParams);
                            num3++;
                        }
                    }
                }
            }
        }
        protected override bool CanScatterAt(IntVec3 c, Map map)
        {
            if (!base.CanScatterAt(c, map))
            {
                return(false);
            }
            if (!c.Standable(map))
            {
                return(false);
            }
            if (c.Roofed(map))
            {
                return(false);
            }
            if (!map.reachability.CanReachMapEdge(c, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
            {
                return(false);
            }
            int      min      = GenStep_FactionBase.FactionBaseSizeRange.min;
            CellRect cellRect = new CellRect(c.x - min / 2, c.z - min / 2, min, min);

            return(cellRect.FullyContainedWithin(new CellRect(0, 0, map.Size.x, map.Size.z)));
        }
        private IntVec3 FindBestSpawnCellForNonItem(CellRect rect, ThingDef thingDef, Rot4 rot, out bool hasToWipeBuilding, out bool doesntFit)
        {
            Map map = BaseGen.globalSettings.map;

            if (thingDef.category == ThingCategory.Building)
            {
                foreach (IntVec3 item in rect.Cells.InRandomOrder())
                {
                    CellRect rect2 = GenAdj.OccupiedRect(item, rot, thingDef.size);
                    if (rect2.FullyContainedWithin(rect) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(rect2, map) && !AnyNonStandableCellOrAnyBuildingInside(rect2) && GenConstruct.TerrainCanSupport(rect2, map, thingDef))
                    {
                        hasToWipeBuilding = false;
                        doesntFit         = false;
                        return(item);
                    }
                }
                foreach (IntVec3 item2 in rect.Cells.InRandomOrder())
                {
                    CellRect rect3 = GenAdj.OccupiedRect(item2, rot, thingDef.size);
                    if (rect3.FullyContainedWithin(rect) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(rect3, map) && !AnyNonStandableCellOrAnyBuildingInside(rect3))
                    {
                        hasToWipeBuilding = false;
                        doesntFit         = false;
                        return(item2);
                    }
                }
            }
            foreach (IntVec3 item3 in rect.Cells.InRandomOrder())
            {
                CellRect rect4 = GenAdj.OccupiedRect(item3, rot, thingDef.size);
                if (rect4.FullyContainedWithin(rect) && !AnyNonStandableCellOrAnyBuildingInside(rect4))
                {
                    hasToWipeBuilding = false;
                    doesntFit         = false;
                    return(item3);
                }
            }
            foreach (IntVec3 item4 in rect.Cells.InRandomOrder())
            {
                if (GenAdj.OccupiedRect(item4, rot, thingDef.size).FullyContainedWithin(rect))
                {
                    hasToWipeBuilding = true;
                    doesntFit         = false;
                    return(item4);
                }
            }
            IntVec3  centerCell = rect.CenterCell;
            CellRect cellRect   = GenAdj.OccupiedRect(centerCell, rot, thingDef.size);

            if (cellRect.minX < 0)
            {
                centerCell.x += -cellRect.minX;
            }
            if (cellRect.minZ < 0)
            {
                centerCell.z += -cellRect.minZ;
            }
            if (cellRect.maxX >= map.Size.x)
            {
                centerCell.x -= cellRect.maxX - map.Size.x + 1;
            }
            if (cellRect.maxZ >= map.Size.z)
            {
                centerCell.z -= cellRect.maxZ - map.Size.z + 1;
            }
            hasToWipeBuilding = true;
            doesntFit         = true;
            return(centerCell);
        }
            internal bool <> m__4(IntVec3 x)
            {
                CellRect obj = GenAdj.OccupiedRect(x, this.rot, this.mortarDef.size);

                return(ThingUtility.InteractionCellWhenAt(this.mortarDef, x, this.rot, this.map).Standable(this.map) && obj.FullyContainedWithin(this.rect) && this.edgeTouchCheck(obj));
            }
Exemple #15
0
        // RimWorld.BaseGen.SymbolResolver_SingleThing
        private static IntVec3 FindBestSpawnCellForNonItem(Map map, CellRect rect, ThingDef thingDef, Rot4 rot, out bool hasToWipeBuilding, out bool doesntFit)
        {
            if (thingDef.category == ThingCategory.Building)
            {
                foreach (IntVec3 current in rect.Cells.InRandomOrder(null))
                {
                    CellRect rect2 = GenAdj.OccupiedRect(current, rot, thingDef.size);
                    if (rect2.FullyContainedWithin(rect) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(rect2, map) && !RunwayUtility.AnyNonStandableCellOrAnyBuildingInside(map, rect2) && GenConstruct.TerrainCanSupport(rect2, map, thingDef))
                    {
                        hasToWipeBuilding = false;
                        doesntFit         = false;
                        IntVec3 result = current;
                        return(result);
                    }
                }
                foreach (IntVec3 current2 in rect.Cells.InRandomOrder(null))
                {
                    CellRect rect3 = GenAdj.OccupiedRect(current2, rot, thingDef.size);
                    if (rect3.FullyContainedWithin(rect) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(rect3, map) && !RunwayUtility.AnyNonStandableCellOrAnyBuildingInside(map, rect3))
                    {
                        hasToWipeBuilding = false;
                        doesntFit         = false;
                        IntVec3 result = current2;
                        return(result);
                    }
                }
            }
            foreach (IntVec3 current3 in rect.Cells.InRandomOrder(null))
            {
                CellRect rect4 = GenAdj.OccupiedRect(current3, rot, thingDef.size);
                if (rect4.FullyContainedWithin(rect) && !RunwayUtility.AnyNonStandableCellOrAnyBuildingInside(map, rect4))
                {
                    hasToWipeBuilding = false;
                    doesntFit         = false;
                    IntVec3 result = current3;
                    return(result);
                }
            }
            foreach (IntVec3 current4 in rect.Cells.InRandomOrder(null))
            {
                if (GenAdj.OccupiedRect(current4, rot, thingDef.size).FullyContainedWithin(rect))
                {
                    hasToWipeBuilding = true;
                    doesntFit         = false;
                    IntVec3 result = current4;
                    return(result);
                }
            }
            IntVec3  centerCell = rect.CenterCell;
            CellRect cellRect   = GenAdj.OccupiedRect(centerCell, rot, thingDef.size);

            if (cellRect.minX < 0)
            {
                centerCell.x += -cellRect.minX;
            }
            if (cellRect.minZ < 0)
            {
                centerCell.z += -cellRect.minZ;
            }
            if (cellRect.maxX >= map.Size.x)
            {
                centerCell.x -= cellRect.maxX - map.Size.x + 1;
            }
            if (cellRect.maxZ >= map.Size.z)
            {
                centerCell.z -= cellRect.maxZ - map.Size.z + 1;
            }
            hasToWipeBuilding = true;
            doesntFit         = true;
            return(centerCell);
        }
 internal bool <> m__0(CellRect x)
 {
     return(!x.FullyContainedWithin(this.mapRect));
 }