Ejemplo n.º 1
0
        public static IEnumerable <IntVec3> GroundCells(IntVec3 loc, Rot4 rot)
        {
            IntVec3 facingCell = rot.Rotated(RotationDirection.Counterclockwise).FacingCell;

            yield return(loc - rot.FacingCell);

            /*Error: Unable to find new state assignment for yield return*/;
        }
        // Token: 0x0600002C RID: 44 RVA: 0x00002FA1 File Offset: 0x000011A1
        public static IEnumerable <IntVec3> WaterUseCells(IntVec3 loc, Rot4 rot)
        {
            var perpOffset = rot.Rotated(RotationDirection.Counterclockwise).FacingCell;

            yield return(loc + rot.FacingCell);

            yield return(loc + rot.FacingCell - perpOffset);

            yield return(loc + rot.FacingCell + perpOffset);
        }
Ejemplo n.º 3
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    perpOffset    = rot.Rotated(RotationDirection.Counterclockwise).FacingCell;
                    this.$current = loc + rot.FacingCell * 3;
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = loc + rot.FacingCell * 3 - perpOffset;
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    this.$current = loc + rot.FacingCell * 3 - perpOffset * 2;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    this.$current = loc + rot.FacingCell * 3 + perpOffset;
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    this.$current = loc + rot.FacingCell * 3 + perpOffset * 2;
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
Ejemplo n.º 4
0
        public static IEnumerable <IntVec3> WaterCells(IntVec3 loc, Rot4 rot)
        {
            IntVec3 perpOffset = rot.Rotated(RotationDirection.Counterclockwise).FacingCell;

            yield return(loc + rot.FacingCell * 3);

            yield return(loc + rot.FacingCell * 3 - perpOffset);

            yield return(loc + rot.FacingCell * 3 - perpOffset * 2);

            yield return(loc + rot.FacingCell * 3 + perpOffset);

            yield return(loc + rot.FacingCell * 3 + perpOffset * 2);
        }
Ejemplo n.º 5
0
        public void RotateShip(RotationDirection rotationDirection)
        {
            this.curRotation = curRotation.Rotated(rotationDirection);
            var rootPos = terrains.Keys.First();

            rotatedTerrains.Clear();
            foreach (var terrain in terrains)
            {
                rotatedTerrains[(terrain.Key.RotatedBy(curRotation) - (rootPos.RotatedBy(curRotation)) + rootPos)] = terrain.Value;
            }
            rotatedCellsWithThings.Clear();
            foreach (var thing in cellsWithThings)
            {
                rotatedCellsWithThings[(thing.Key.RotatedBy(curRotation) - (rootPos.RotatedBy(curRotation)) + rootPos)] = thing.Value;
            }
        }
Ejemplo n.º 6
0
        public static IEnumerable <IntVec3> GroundCells(IntVec3 loc, Rot4 rot)
        {
            IntVec3 perpOffset = rot.Rotated(RotationDirection.Counterclockwise).FacingCell;

            yield return(loc - rot.FacingCell);

            yield return(loc - rot.FacingCell - perpOffset);

            yield return(loc - rot.FacingCell + perpOffset);

            yield return(loc);

            yield return(loc - perpOffset);

            yield return(loc + perpOffset);

            yield return(loc + rot.FacingCell);

            yield return(loc + rot.FacingCell - perpOffset);

            yield return(loc + rot.FacingCell + perpOffset);

            yield break;
        }
Ejemplo n.º 7
0
 public Stencil Rotate(RotationDirection dir)
 {
     return(new Stencil(map, pos, rot.Rotated(dir), bounds));
 }
Ejemplo n.º 8
0
        private bool TryFindExitSpot(List <Pawn> pawns, bool reachableForEveryColonist, out IntVec3 spot)
        {
            Rot4 rotFromTo = Find.WorldGrid.GetRotFromTo(this.CurrentTile, this.startingTile);

            return(this.TryFindExitSpot(pawns, reachableForEveryColonist, rotFromTo, out spot) || this.TryFindExitSpot(pawns, reachableForEveryColonist, rotFromTo.Rotated(RotationDirection.Clockwise), out spot) || this.TryFindExitSpot(pawns, reachableForEveryColonist, rotFromTo.Rotated(RotationDirection.Counterclockwise), out spot));
        }
        private static void GenerateInt(bool[,] grid, bool horizontalSymmetry, bool verticalSymmetry, bool allowEnclosedFalses, bool preferOutlines, float wipedCircleRadiusPct)
        {
            int length  = grid.GetLength(0);
            int length2 = grid.GetLength(1);

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length2; j++)
                {
                    grid[i, j] = false;
                }
            }
            int num;
            int num2;
            int num3;
            int num4;
            int num5;
            int num6;

            if (preferOutlines)
            {
                num  = 0;
                num2 = 2;
                num3 = 0;
                num4 = 4;
                num5 = 2;
                num6 = ((length < 16 && length2 < 16) ? ((length < 13 && length2 < 13) ? ((length < 12 && length2 < 12) ? 1 : 2) : 3) : 4);
            }
            else
            {
                num  = Rand.RangeInclusive(1, 3);
                num2 = 0;
                num3 = Rand.RangeInclusive(1, 3);
                num6 = 0;
                num4 = 0;
                num5 = 0;
            }
            float num7  = 0.3f;
            float num8  = 0.3f;
            float num9  = 0.7f;
            float num10 = 0.7f;

            for (int k = 0; k < num; k++)
            {
                foreach (IntVec3 item in CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length) * num7), 1), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length2) * num7), 1)))
                {
                    if (item.x >= 0 && item.x < length && item.z >= 0 && item.z < length2)
                    {
                        grid[item.x, item.z] = true;
                    }
                }
            }
            for (int l = 0; l < num2; l++)
            {
                CellRect cellRect = CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length) * num8), 1), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length2) * num8), 1));
                Rot4     random   = Rot4.Random;
                foreach (IntVec3 edgeCell in cellRect.EdgeCells)
                {
                    if ((allowEnclosedFalses || !cellRect.IsOnEdge(edgeCell, random) || cellRect.IsOnEdge(edgeCell, random.Rotated(RotationDirection.Clockwise)) || cellRect.IsOnEdge(edgeCell, random.Rotated(RotationDirection.Counterclockwise))) && edgeCell.x >= 0 && edgeCell.x < length && edgeCell.z >= 0 && edgeCell.z < length2)
                    {
                        grid[edgeCell.x, edgeCell.z] = true;
                    }
                }
            }
            for (int m = 0; m < num3; m++)
            {
                IntVec2 intVec = new IntVec2(Rand.RangeInclusive(0, length - 1), Rand.RangeInclusive(0, length2 - 1));
                foreach (IntVec3 item2 in GenRadial.RadialPatternInRadius(Mathf.Max(Mathf.RoundToInt((float)(Mathf.Max(length, length2) / 2) * num9), 1)))
                {
                    IntVec3 current3 = item2;
                    current3.x += intVec.x;
                    current3.z += intVec.z;
                    if (current3.x >= 0 && current3.x < length && current3.z >= 0 && current3.z < length2)
                    {
                        grid[current3.x, current3.z] = true;
                    }
                }
            }
            for (int n = 0; n < num6; n++)
            {
                float   num11   = Rand.Range(0.7f, 1f);
                IntVec2 intVec2 = new IntVec2(Rand.RangeInclusive(0, length - 1), Rand.RangeInclusive(0, length2 - 1));
                int     num12   = Mathf.Max(Mathf.RoundToInt((float)(Mathf.Max(length, length2) / 2) * num10 * num11), 1);
                bool    @bool   = Rand.Bool;
                tmpCircleCells.Clear();
                tmpCircleCells.AddRange(GenRadial.RadialPatternInRadius(num12));
                foreach (IntVec3 tmpCircleCell in tmpCircleCells)
                {
                    if ((allowEnclosedFalses || ((!@bool || tmpCircleCell.x >= 0) && (@bool || tmpCircleCell.z >= 0))) && (!tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z + 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z + 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z + 1))))
                    {
                        IntVec3 intVec3 = tmpCircleCell;
                        intVec3.x += intVec2.x;
                        intVec3.z += intVec2.z;
                        if (intVec3.x >= 0 && intVec3.x < length && intVec3.z >= 0 && intVec3.z < length2)
                        {
                            grid[intVec3.x, intVec3.z] = true;
                        }
                    }
                }
            }
            for (int num13 = 0; num13 < num4; num13++)
            {
                bool bool2 = Rand.Bool;
                foreach (IntVec3 item3 in CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), (!bool2) ? 1 : Mathf.RoundToInt(Rand.RangeInclusive(1, length)), bool2 ? 1 : Mathf.RoundToInt(Rand.RangeInclusive(1, length2))))
                {
                    if (item3.x >= 0 && item3.x < length && item3.z >= 0 && item3.z < length2)
                    {
                        grid[item3.x, item3.z] = true;
                    }
                }
            }
            for (int num14 = 0; num14 < num5; num14++)
            {
                bool     bool3     = Rand.Bool;
                CellRect cellRect2 = CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.RoundToInt(Rand.RangeInclusive(1, length)), 1);
                foreach (IntVec3 item4 in cellRect2)
                {
                    int num15 = item4.x - cellRect2.minX - cellRect2.Width / 2;
                    if (bool3)
                    {
                        num15 = -num15;
                    }
                    IntVec3 intVec4 = item4;
                    intVec4.z += num15;
                    if (intVec4.x >= 0 && intVec4.x < length && intVec4.z >= 0 && intVec4.z < length2)
                    {
                        grid[intVec4.x, intVec4.z] = true;
                    }
                }
            }
            if (preferOutlines)
            {
                for (int num16 = 0; num16 < grid.GetLength(0) - 1; num16++)
                {
                    for (int num17 = 0; num17 < grid.GetLength(1) - 1; num17++)
                    {
                        if (grid[num16, num17] && grid[num16 + 1, num17] && grid[num16, num17 + 1] && grid[num16 + 1, num17 + 1])
                        {
                            switch (Rand.Range(0, 4))
                            {
                            case 0:
                                grid[num16, num17] = false;
                                break;

                            case 1:
                                grid[num16 + 1, num17] = false;
                                break;

                            case 2:
                                grid[num16, num17 + 1] = false;
                                break;

                            default:
                                grid[num16 + 1, num17 + 1] = false;
                                break;
                            }
                        }
                    }
                }
            }
            if (wipedCircleRadiusPct > 0f)
            {
                IntVec2 intVec5 = new IntVec2(length / 2, length2 / 2);
                foreach (IntVec3 item5 in GenRadial.RadialPatternInRadius(Mathf.FloorToInt((float)Mathf.Min(length, length2) * wipedCircleRadiusPct)))
                {
                    IntVec3 current7 = item5;
                    current7.x += intVec5.x;
                    current7.z += intVec5.z;
                    if (current7.x >= 0 && current7.x < length && current7.z >= 0 && current7.z < length2)
                    {
                        grid[current7.x, current7.z] = false;
                    }
                }
            }
            if (horizontalSymmetry)
            {
                for (int num18 = grid.GetLength(0) / 2; num18 < grid.GetLength(0); num18++)
                {
                    for (int num19 = 0; num19 < grid.GetLength(1); num19++)
                    {
                        grid[num18, num19] = grid[grid.GetLength(0) - num18 - 1, num19];
                    }
                }
            }
            if (!verticalSymmetry)
            {
                return;
            }
            for (int num20 = 0; num20 < grid.GetLength(0); num20++)
            {
                for (int num21 = grid.GetLength(1) / 2; num21 < grid.GetLength(1); num21++)
                {
                    grid[num20, num21] = grid[num20, grid.GetLength(1) - num21 - 1];
                }
            }
        }