コード例 #1
0
 public static bool CanPlace(Point origin, StructureMap structures)
 {
     if (WorldGen.BiomeTileCheck(origin.X, origin.Y))
     {
         return(false);
     }
     return(!GenBase._tiles[origin.X, origin.Y].active());
 }
コード例 #2
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.BiomeTileCheck(origin.X, origin.Y))
            {
                return(false);
            }
            if (this._slabs == null)
            {
                this._slabs = new MarbleBiome.Slab[56, 26];
            }
            int num1 = GenBase._random.Next(80, 150) / 3;
            int num2 = GenBase._random.Next(40, 60) / 3;
            int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;

            origin.X -= num1 * 3 / 2;
            origin.Y -= num2 * 3 / 2;
            for (int index1 = -1; index1 < num1 + 1; ++index1)
            {
                double num4 = (double)(index1 - num1 / 2) / (double)num1 + 0.5;
                int    num5 = (int)((0.5 - Math.Abs(num4 - 0.5)) * 5.0) - 2;
                for (int index2 = -1; index2 < num2 + 1; ++index2)
                {
                    bool hasWall = true;
                    bool flag1   = false;
                    bool flag2   = MarbleBiome.IsGroupSolid(index1 * 3 + origin.X, index2 * 3 + origin.Y, 3);
                    int  num6    = Math.Abs(index2 - num2 / 2) - num3 / 4 + num5;
                    if (num6 > 3)
                    {
                        flag1   = flag2;
                        hasWall = false;
                    }
                    else if (num6 > 0)
                    {
                        flag1   = index2 - num2 / 2 > 0 | flag2;
                        hasWall = index2 - num2 / 2 < 0 || num6 <= 2;
                    }
                    else if (num6 == 0)
                    {
                        flag1 = GenBase._random.Next(2) == 0 && index2 - num2 / 2 > 0 | flag2;
                    }
                    if (Math.Abs(num4 - 0.5) > 0.349999994039536 + (double)GenBase._random.NextFloat() * 0.100000001490116 && !flag2)
                    {
                        hasWall = false;
                        flag1   = false;
                    }
                    this._slabs[index1 + 1, index2 + 1] = MarbleBiome.Slab.Create(flag1 ? new MarbleBiome.SlabState(MarbleBiome.SlabStates.Solid) : new MarbleBiome.SlabState(MarbleBiome.SlabStates.Empty), hasWall);
                }
            }
            for (int index1 = 0; index1 < num1; ++index1)
            {
                for (int index2 = 0; index2 < num2; ++index2)
                {
                    this.SmoothSlope(index1 + 1, index2 + 1);
                }
            }
            int   num7  = num1 / 2;
            int   val1  = num2 / 2;
            int   num8  = (val1 + 1) * (val1 + 1);
            float num9  = (float)((double)GenBase._random.NextFloat() * 2.0 - 1.0);
            float num10 = (float)((double)GenBase._random.NextFloat() * 2.0 - 1.0);
            float num11 = (float)((double)GenBase._random.NextFloat() * 2.0 - 1.0);
            float num12 = 0.0f;

            for (int index1 = 0; index1 <= num1; ++index1)
            {
                float num4 = (float)val1 / (float)num7 * (float)(index1 - num7);
                int   num5 = Math.Min(val1, (int)Math.Sqrt((double)Math.Max(0.0f, (float)num8 - num4 * num4)));
                if (index1 < num1 / 2)
                {
                    num12 += MathHelper.Lerp(num9, num10, (float)index1 / (float)(num1 / 2));
                }
                else
                {
                    num12 += MathHelper.Lerp(num10, num11, (float)((double)index1 / (double)(num1 / 2) - 1.0));
                }
                for (int index2 = val1 - num5; index2 <= val1 + num5; ++index2)
                {
                    this.PlaceSlab(this._slabs[index1 + 1, index2 + 1], index1 * 3 + origin.X, index2 * 3 + origin.Y + (int)num12, 3);
                }
            }
            structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, num1 * 3, num2 * 3), 8);
            return(true);
        }
コード例 #3
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.BiomeTileCheck(origin.X, origin.Y))
            {
                return(false);
            }
            if (_slabs == null)
            {
                _slabs = new Slab[56, 26];
            }
            int num  = GenBase._random.Next(80, 150) / 3;
            int num2 = GenBase._random.Next(40, 60) / 3;
            int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;

            origin.X -= num * 3 / 2;
            origin.Y -= num2 * 3 / 2;
            for (int i = -1; i < num + 1; i++)
            {
                double num4 = (double)(i - num / 2) / (double)num + 0.5;
                int    num5 = (int)((0.5 - Math.Abs(num4 - 0.5)) * 5.0) - 2;
                for (int j = -1; j < num2 + 1; j++)
                {
                    bool hasWall = true;
                    bool flag    = false;
                    bool flag2   = IsGroupSolid(i * 3 + origin.X, j * 3 + origin.Y, 3);
                    int  num6    = Math.Abs(j - num2 / 2) - num3 / 4 + num5;
                    if (num6 > 3)
                    {
                        flag    = flag2;
                        hasWall = false;
                    }
                    else if (num6 > 0)
                    {
                        flag    = j - num2 / 2 > 0 || flag2;
                        hasWall = j - num2 / 2 < 0 || num6 <= 2;
                    }
                    else if (num6 == 0)
                    {
                        flag = GenBase._random.Next(2) == 0 && (j - num2 / 2 > 0 || flag2);
                    }
                    if (Math.Abs(num4 - 0.5) > (double)(0.35f + GenBase._random.NextFloat() * 0.1f) && !flag2)
                    {
                        hasWall = false;
                        flag    = false;
                    }
                    _slabs[i + 1, j + 1] = Slab.Create(flag ? new SlabState(SlabStates.Solid) : new SlabState(SlabStates.Empty), hasWall);
                }
            }
            for (int k = 0; k < num; k++)
            {
                for (int l = 0; l < num2; l++)
                {
                    SmoothSlope(k + 1, l + 1);
                }
            }
            int   num7   = num / 2;
            int   num8   = num2 / 2;
            int   num9   = (num8 + 1) * (num8 + 1);
            float value  = GenBase._random.NextFloat() * 2f - 1f;
            float num10  = GenBase._random.NextFloat() * 2f - 1f;
            float value2 = GenBase._random.NextFloat() * 2f - 1f;
            float num11  = 0f;

            for (int m = 0; m <= num; m++)
            {
                float num12 = (float)num8 / (float)num7 * (float)(m - num7);
                int   num13 = Math.Min(num8, (int)Math.Sqrt(Math.Max(0f, (float)num9 - num12 * num12)));
                num11 = ((m >= num / 2) ? (num11 + MathHelper.Lerp(num10, value2, (float)m / (float)(num / 2) - 1f)) : (num11 + MathHelper.Lerp(value, num10, (float)m / (float)(num / 2))));
                for (int n = num8 - num13; n <= num8 + num13; n++)
                {
                    PlaceSlab(_slabs[m + 1, n + 1], m * 3 + origin.X, n * 3 + origin.Y + (int)num11, 3);
                }
            }
            structures.AddStructure(new Rectangle(origin.X, origin.Y, num * 3, num2 * 3), 8);
            return(true);
        }