Inheritance: GenBase
Ejemplo n.º 1
0
 public override bool Place(Point origin, StructureMap structures)
 {
     Dictionary<ushort, int> nums = new Dictionary<ushort, int>();
     Point point = new Point(origin.X - 25, origin.Y - 25);
     Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50);
     ushort[] numArray = new ushort[] { 0, 59, 147, 1 };
     WorldUtils.Gen(point, rectangle, (new Actions.TileScanner(numArray)).Output(nums));
     int item = nums[0] + nums[1];
     int num = nums[59];
     int item1 = nums[147];
     if (item1 <= num || item1 <= item)
     {
         return false;
     }
     int num1 = 0;
     for (int i = GenBase._random.Next(10, 15); i > 5; i--)
     {
         int num2 = GenBase._random.Next(-5, 5);
         Point point1 = new Point(origin.X + num2, origin.Y + num1);
         Shapes.Circle circle = new Shapes.Circle(i);
         GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(4, 0.3), null, null };
         ushort[] numArray1 = new ushort[] { 147, 161, 224, 0, 1 };
         blotch[1] = new Modifiers.OnlyTiles(numArray1);
         blotch[2] = new Actions.SetTile(162, true, true);
         WorldUtils.Gen(point1, circle, Actions.Chain(blotch));
         Point point2 = new Point(origin.X + num2, origin.Y + num1);
         Shapes.Circle circle1 = new Shapes.Circle(i);
         GenAction[] genActionArray = new GenAction[] { new Modifiers.Blotches(4, 0.3), new Modifiers.HasLiquid(-1, -1), new Actions.SetTile(162, true, true), new Actions.SetLiquid(0, 0) };
         WorldUtils.Gen(point2, circle1, Actions.Chain(genActionArray));
         num1 = num1 + (i - 2);
     }
     return true;
 }
			public override bool Perform(Point origin, GenAction action)
			{
				float num = (float)this._radius;
				int num2 = (this._radius + 1) * (this._radius + 1);
				for (int i = origin.Y - (int)(num * this._yScale); i <= origin.Y; i++)
				{
					float num3 = (float)(i - origin.Y) / this._yScale;
					int num4 = (int)Math.Min((float)this._radius * this._xScale, this._xScale * (float)Math.Sqrt((double)((float)num2 - num3 * num3)));
					for (int j = origin.X - num4; j <= origin.X + num4; j++)
					{
						if (!base.UnitApply(action, origin, j, i, new object[0]) && this._quitOnFail)
						{
							return false;
						}
					}
				}
				for (int k = origin.Y + 1; k <= origin.Y + (int)(num * this._yScale * 0.5f) - 1; k++)
				{
					float num5 = (float)(k - origin.Y) * (2f / this._yScale);
					int num6 = (int)Math.Min((float)this._radius * this._xScale, this._xScale * (float)Math.Sqrt((double)((float)num2 - num5 * num5)));
					for (int l = origin.X - num6; l <= origin.X + num6; l++)
					{
						if (!base.UnitApply(action, origin, l, k, new object[0]) && this._quitOnFail)
						{
							return false;
						}
					}
				}
				return true;
			}
Ejemplo n.º 3
0
        private bool DoRoot(Point origin, GenAction action, float angle, float distance, float startingSize)
        {
            float num1 = (float)origin.X;
            float num2 = (float)origin.Y;
            for (float num3 = 0.0f; num3 < distance * 0.850000023841858; ++num3)
            {
                float amount = num3 / distance;
                float num4 = MathHelper.Lerp(startingSize, _endingSize, amount);
                num1 += (float)Math.Cos(angle);
                num2 += (float)Math.Sin(angle);
                angle += (float)(Utils.NextFloat(GenBase._random) - 0.5 + Utils.NextFloat(GenBase._random) * (_angle - 1.57079637050629) * 0.100000001490116 * (1.0 - amount));
                angle = (float)(angle * 0.400000005960464 + 0.449999988079071 * MathHelper.Clamp(angle, _angle - (float)(2.0 * (1.0 - 0.5 * amount)), 
                    _angle + (float)(2.0 * (1.0 - 0.5 * amount))) + MathHelper.Lerp(_angle, 1.570796f, amount) * 0.150000005960464);

                for (int index1 = 0; index1 < (int)num4; ++index1)
                {
                    for (int index2 = 0; index2 < (int)num4; ++index2)
                    {
                        if (!this.UnitApply(action, origin, (int)num1 + index1, (int)num2 + index2) && _quitOnFail)
                            return false;
                    }
                }
            }
            return true;
        }
Ejemplo n.º 4
0
 private bool DoRoot(Point origin, GenAction action, float angle, float distance, float startingSize)
 {
     float x = (float)origin.X;
     float y = (float)origin.Y;
     for (float i = 0f; i < distance * 0.85f; i = i + 1f)
     {
         float single = i / distance;
         float single1 = MathHelper.Lerp(startingSize, this._endingSize, single);
         x = x + (float)Math.Cos((double)angle);
         y = y + (float)Math.Sin((double)angle);
         angle = angle + (GenBase._random.NextFloat() - 0.5f + GenBase._random.NextFloat() * (this._angle - 1.57079637f) * 0.1f * (1f - single));
         angle = angle * 0.4f + 0.45f * MathHelper.Clamp(angle, this._angle - 2f * (1f - 0.5f * single), this._angle + 2f * (1f - 0.5f * single)) + MathHelper.Lerp(this._angle, 1.57079637f, single) * 0.15f;
         for (int j = 0; j < (int)single1; j++)
         {
             for (int k = 0; k < (int)single1; k++)
             {
                 if (!base.UnitApply(action, origin, (int)x + j, (int)y + k, new object[0]) && this._quitOnFail)
                 {
                     return false;
                 }
             }
         }
     }
     return true;
 }
		public override bool Perform(Point origin, GenAction action)
		{
			Vector2 vector = new Vector2((float)this._offset.X, (float)this._offset.Y);
			float num = vector.Length();
			int num2 = (int)(num / 6f);
			if (this._endPoints != null)
			{
				this._endPoints.Add(new Point(origin.X + this._offset.X, origin.Y + this._offset.Y));
			}
			if (!this.PerformSegment(origin, action, origin, new Point(origin.X + this._offset.X, origin.Y + this._offset.Y), num2))
			{
				return false;
			}
			int num3 = (int)(num / 8f);
			for (int i = 0; i < num3; i++)
			{
				float num4 = ((float)i + 1f) / ((float)num3 + 1f);
				Point point = new Point((int)(num4 * (float)this._offset.X), (int)(num4 * (float)this._offset.Y));
				Vector2 spinningpoint = new Vector2((float)(this._offset.X - point.X), (float)(this._offset.Y - point.Y));
				spinningpoint = spinningpoint.RotatedBy((double)(((float)GenBase._random.NextDouble() * 0.5f + 1f) * (float)((GenBase._random.Next(2) == 0) ? -1 : 1)), default(Vector2)) * 0.75f;
				Point point2 = new Point((int)spinningpoint.X + point.X, (int)spinningpoint.Y + point.Y);
				if (this._endPoints != null)
				{
					this._endPoints.Add(new Point(point2.X + origin.X, point2.Y + origin.Y));
				}
				if (!this.PerformSegment(origin, action, new Point(point.X + origin.X, point.Y + origin.Y), new Point(point2.X + origin.X, point2.Y + origin.Y), num2 - 1))
				{
					return false;
				}
			}
			return true;
		}
		private bool DoRoot(Point origin, GenAction action, float angle, float distance, float startingSize)
		{
			float num = (float)origin.X;
			float num2 = (float)origin.Y;
			for (float num3 = 0f; num3 < distance * 0.85f; num3 += 1f)
			{
				float num4 = num3 / distance;
				float num5 = MathHelper.Lerp(startingSize, this._endingSize, num4);
				num += (float)Math.Cos((double)angle);
				num2 += (float)Math.Sin((double)angle);
				angle += GenBase._random.NextFloat() - 0.5f + GenBase._random.NextFloat() * (this._angle - 1.57079637f) * 0.1f * (1f - num4);
				angle = angle * 0.4f + 0.45f * MathHelper.Clamp(angle, this._angle - 2f * (1f - 0.5f * num4), this._angle + 2f * (1f - 0.5f * num4)) + MathHelper.Lerp(this._angle, 1.57079637f, num4) * 0.15f;
				for (int i = 0; i < (int)num5; i++)
				{
					for (int j = 0; j < (int)num5; j++)
					{
						if (!base.UnitApply(action, origin, (int)num + i, (int)num2 + j, new object[0]) && this._quitOnFail)
						{
							return false;
						}
					}
				}
			}
			return true;
		}
Ejemplo n.º 7
0
 public override bool Perform(Point origin, GenAction action)
 {
     Vector2 vector2 = new Vector2((float)this._offset.X, (float)this._offset.Y);
     float single = vector2.Length();
     int num = (int)(single / 6f);
     if (this._endPoints != null)
     {
         this._endPoints.Add(new Point(origin.X + this._offset.X, origin.Y + this._offset.Y));
     }
     if (!this.PerformSegment(origin, action, origin, new Point(origin.X + this._offset.X, origin.Y + this._offset.Y), num))
     {
         return false;
     }
     int num1 = (int)(single / 8f);
     for (int i = 0; i < num1; i++)
     {
         float single1 = ((float)i + 1f) / ((float)num1 + 1f);
         Point point = new Point((int)(single1 * (float)this._offset.X), (int)(single1 * (float)this._offset.Y));
         Vector2 vector21 = new Vector2((float)(this._offset.X - point.X), (float)(this._offset.Y - point.Y));
         Vector2 vector22 = vector21;
         double num2 = (double)(((float)GenBase._random.NextDouble() * 0.5f + 1f) * (float)((GenBase._random.Next(2) == 0 ? -1 : 1)));
         Vector2 vector23 = new Vector2();
         vector21 = vector22.RotatedBy(num2, vector23) * 0.75f;
         Point point1 = new Point((int)vector21.X + point.X, (int)vector21.Y + point.Y);
         if (this._endPoints != null)
         {
             this._endPoints.Add(new Point(point1.X + origin.X, point1.Y + origin.Y));
         }
         if (!this.PerformSegment(origin, action, new Point(point.X + origin.X, point.Y + origin.Y), new Point(point1.X + origin.X, point1.Y + origin.Y), num - 1))
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 8
0
 protected bool UnitApply(GenAction action, Point origin, int x, int y, params object[] args)
 {
     if (this._outputData != null)
     {
         this._outputData.Add(x - origin.X, y - origin.Y);
     }
     return action.Apply(origin, x, y, args);
 }
Ejemplo n.º 9
0
 public override bool Perform(Point origin, GenAction action)
 {
     foreach (Point16 point16 in this._data.GetData())
     {
         if (!this.UnitApply(action, origin, (int)point16.X + origin.X, (int)point16.Y + origin.Y) && this._quitOnFail)
             return false;
     }
     return true;
 }
			public override bool Perform(Point origin, GenAction action)
			{
				foreach (Point16 current in this._data.GetData())
				{
					if (!base.UnitApply(action, origin, (int)current.X + origin.X, (int)current.Y + origin.Y, new object[0]) && this._quitOnFail)
					{
						return false;
					}
				}
				return true;
			}
Ejemplo n.º 11
0
 public override bool Perform(Point origin, GenAction action)
 {
     Queue<Point> points = new Queue<Point>();
     HashSet<Point16> point16s = new HashSet<Point16>();
     points.Enqueue(origin);
     int num = this._maximumActions;
     while (points.Count > 0)
     {
         if (num > 0)
         {
             Point point = points.Dequeue();
             if (point16s.Contains(new Point16(point.X, point.Y)) || !base.UnitApply(action, origin, point.X, point.Y, new object[0]))
             {
                 continue;
             }
             point16s.Add(new Point16(point));
             num--;
             if (point.X + 1 < Main.maxTilesX - 1)
             {
                 points.Enqueue(new Point(point.X + 1, point.Y));
             }
             if (point.X - 1 >= 1)
             {
                 points.Enqueue(new Point(point.X - 1, point.Y));
             }
             if (point.Y + 1 < Main.maxTilesY - 1)
             {
                 points.Enqueue(new Point(point.X, point.Y + 1));
             }
             if (point.Y - 1 < 1)
             {
                 continue;
             }
             points.Enqueue(new Point(point.X, point.Y - 1));
         }
         else
         {
             break;
         }
     }
     while (points.Count > 0)
     {
         Point point1 = points.Dequeue();
         if (point16s.Contains(new Point16(point1.X, point1.Y)))
         {
             continue;
         }
         points.Enqueue(point1);
         break;
     }
     return points.Count == 0;
 }
		public override bool Perform(Point origin, GenAction action)
		{
			Queue<Point> queue = new Queue<Point>();
			HashSet<Point16> hashSet = new HashSet<Point16>();
			queue.Enqueue(origin);
			int num = this._maximumActions;
			while (queue.Count > 0)
			{
				if (num <= 0)
				{
					break;
				}
				Point point = queue.Dequeue();
				if (!hashSet.Contains(new Point16(point.X, point.Y)))
				{
					bool flag = base.UnitApply(action, origin, point.X, point.Y, new object[0]);
					if (flag)
					{
						hashSet.Add(new Point16(point));
						num--;
						if (point.X + 1 < Main.maxTilesX - 1)
						{
							queue.Enqueue(new Point(point.X + 1, point.Y));
						}
						if (point.X - 1 >= 1)
						{
							queue.Enqueue(new Point(point.X - 1, point.Y));
						}
						if (point.Y + 1 < Main.maxTilesY - 1)
						{
							queue.Enqueue(new Point(point.X, point.Y + 1));
						}
						if (point.Y - 1 >= 1)
						{
							queue.Enqueue(new Point(point.X, point.Y - 1));
						}
					}
				}
			}
			while (queue.Count > 0)
			{
				Point item = queue.Dequeue();
				if (!hashSet.Contains(new Point16(item.X, item.Y)))
				{
					queue.Enqueue(item);
					break;
				}
			}
			return queue.Count == 0;
		}
Ejemplo n.º 13
0
 public override bool Perform(Point origin, GenAction action)
 {
     int num1 = (this._radius + 1) * (this._radius + 1);
     for (int y = origin.Y - this._radius; y <= origin.Y; ++y)
     {
         int num2 = Math.Min(this._radius, (int)Math.Sqrt((double)(num1 - (y - origin.Y) * (y - origin.Y))));
         for (int x = origin.X - num2; x <= origin.X + num2; ++x)
         {
             if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
                 return false;
         }
     }
     return true;
 }
		private bool PerformSegment(Point origin, GenAction action, Point start, Point end, int size)
		{
			size = Math.Max(1, size);
			for (int i = -(size >> 1); i < size - (size >> 1); i++)
			{
				for (int j = -(size >> 1); j < size - (size >> 1); j++)
				{
					if (!Utils.PlotLine(new Point(start.X + i, start.Y + j), end, (int tileX, int tileY) => this.UnitApply(action, origin, tileX, tileY, new object[0]) || !this._quitOnFail, false))
					{
						return false;
					}
				}
			}
			return true;
		}
Ejemplo n.º 15
0
 public override bool Perform(Point origin, GenAction action)
 {
     int num1 = (this._horizontalRadius + 1) * (this._horizontalRadius + 1);
     for (int y = origin.Y - this._verticalRadius; y <= origin.Y + this._verticalRadius; ++y)
     {
         float num2 = (float)this._horizontalRadius / (float)this._verticalRadius * (float)(y - origin.Y);
         int num3 = Math.Min(this._horizontalRadius, (int)Math.Sqrt((double)num1 - (double)num2 * (double)num2));
         for (int x = origin.X - num3; x <= origin.X + num3; ++x)
         {
             if (!this.UnitApply(action, origin, x, y) && this._quitOnFail)
                 return false;
         }
     }
     return true;
 }
Ejemplo n.º 16
0
 public override bool Perform(Point origin, GenAction action)
 {
     int num = (this._radius + 1) * (this._radius + 1);
     for (int i = origin.Y - this._radius; i <= origin.Y; i++)
     {
         int num1 = Math.Min(this._radius, (int)Math.Sqrt((double)(num - (i - origin.Y) * (i - origin.Y))));
         for (int j = origin.X - num1; j <= origin.X + num1; j++)
         {
             if (!base.UnitApply(action, origin, j, i, new object[0]) && this._quitOnFail)
             {
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 17
0
 public override bool Perform(Point origin, GenAction action)
 {
     int num = this._useDiagonals ? 16 : 8;
     foreach (Point16 point16 in this._data.GetData())
     {
         if (this._useInterior && !this.UnitApply(action, origin, (int)point16.X + origin.X, (int)point16.Y + origin.Y) && this._quitOnFail)
             return false;
         int index = 0;
         while (index < num)
         {
             if (!this._data.Contains((int)point16.X + ModShapes.OuterOutline.POINT_OFFSETS[index], (int)point16.Y + ModShapes.OuterOutline.POINT_OFFSETS[index + 1]) && !this.UnitApply(action, origin, origin.X + (int)point16.X + ModShapes.OuterOutline.POINT_OFFSETS[index], origin.Y + (int)point16.Y + ModShapes.OuterOutline.POINT_OFFSETS[index + 1]) && this._quitOnFail)
                 return false;
             index += 2;
         }
     }
     return true;
 }
Ejemplo n.º 18
0
 public override bool Perform(Point origin, GenAction action)
 {
     int num = (this._horizontalRadius + 1) * (this._horizontalRadius + 1);
     for (int i = origin.Y - this._verticalRadius; i <= origin.Y + this._verticalRadius; i++)
     {
         float y = (float)this._horizontalRadius / (float)this._verticalRadius * (float)(i - origin.Y);
         int num1 = Math.Min(this._horizontalRadius, (int)Math.Sqrt((double)((float)num - y * y)));
         for (int j = origin.X - num1; j <= origin.X + num1; j++)
         {
             if (!base.UnitApply(action, origin, j, i, new object[0]) && this._quitOnFail)
             {
                 return false;
             }
         }
     }
     return true;
 }
			public override bool Perform(Point origin, GenAction action)
			{
				int num = this._useDiagonals ? 16 : 8;
				foreach (Point16 current in this._data.GetData())
				{
					if (this._useInterior && !base.UnitApply(action, origin, (int)current.X + origin.X, (int)current.Y + origin.Y, new object[0]) && this._quitOnFail)
					{
						bool result = false;
						return result;
					}
					for (int i = 0; i < num; i += 2)
					{
						if (!this._data.Contains((int)current.X + ModShapes.OuterOutline.POINT_OFFSETS[i], (int)current.Y + ModShapes.OuterOutline.POINT_OFFSETS[i + 1]) && !base.UnitApply(action, origin, origin.X + (int)current.X + ModShapes.OuterOutline.POINT_OFFSETS[i], origin.Y + (int)current.Y + ModShapes.OuterOutline.POINT_OFFSETS[i + 1], new object[0]) && this._quitOnFail)
						{
							bool result = false;
							return result;
						}
					}
				}
				return true;
			}
Ejemplo n.º 20
0
 public override bool Place(Point origin, StructureMap structures)
 {
     Point y;
     if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y))
     {
         return false;
     }
     Searches.Down down = new Searches.Down(80);
     GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
     if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out y))
     {
         return false;
     }
     y.Y = y.Y + 2;
     Ref<int> @ref = new Ref<int>(0);
     Shapes.Circle circle = new Shapes.Circle(8);
     GenAction[] genActionArray = new GenAction[] { new Modifiers.IsSolid(), new Actions.Scanner(@ref) };
     WorldUtils.Gen(y, circle, Actions.Chain(genActionArray));
     if (@ref.Value < 20)
     {
         return false;
     }
     if (!structures.CanPlace(new Rectangle(y.X - 8, y.Y - 8, 16, 16), 0))
     {
         return false;
     }
     Shapes.Circle circle1 = new Shapes.Circle(8);
     GenAction[] radialDither = new GenAction[] { new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, true, true) };
     WorldUtils.Gen(y, circle1, Actions.Chain(radialDither));
     ShapeData shapeDatum = new ShapeData();
     Shapes.Circle circle2 = new Shapes.Circle(4, 3);
     GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(2, 0.3), new Modifiers.IsSolid(), new Actions.ClearTile(true), (new Modifiers.RectangleMask(-6, 6, 0, 3)).Output(shapeDatum), new Actions.SetLiquid(2, 255) };
     WorldUtils.Gen(y, circle2, Actions.Chain(blotch));
     Point point = new Point(y.X, y.Y + 1);
     ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true);
     GenAction[] isEmpty = new GenAction[] { new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, true, true) };
     WorldUtils.Gen(point, innerOutline, Actions.Chain(isEmpty));
     structures.AddStructure(new Rectangle(y.X - 8, y.Y - 8, 16, 16), 0);
     return true;
 }
		public override bool Perform(Point origin, GenAction action)
		{
			float num = (float)this._steps;
			float num2 = (float)this._steps;
			double num3 = (double)this._startStrength;
			Vector2 value = new Vector2((float)origin.X, (float)origin.Y);
			Vector2 vector = (this._startVelocity == Vector2.Zero) ? Utils.RandomVector2(GenBase._random, -1f, 1f) : this._startVelocity;
			while (num > 0f && num3 > 0.0)
			{
				num3 = (double)(this._startStrength * (num / num2));
				num -= 1f;
				int num4 = Math.Max(1, (int)((double)value.X - num3 * 0.5));
				int num5 = Math.Max(1, (int)((double)value.Y - num3 * 0.5));
				int num6 = Math.Min(GenBase._worldWidth, (int)((double)value.X + num3 * 0.5));
				int num7 = Math.Min(GenBase._worldHeight, (int)((double)value.Y + num3 * 0.5));
				for (int i = num4; i < num6; i++)
				{
					for (int j = num5; j < num7; j++)
					{
						if ((double)(Math.Abs((float)i - value.X) + Math.Abs((float)j - value.Y)) < num3 * 0.5 * (1.0 + (double)GenBase._random.Next(-10, 11) * 0.015))
						{
							base.UnitApply(action, origin, i, j, new object[0]);
						}
					}
				}
				int num8 = (int)(num3 / 50.0) + 1;
				num -= (float)num8;
				value += vector;
				for (int k = 0; k < num8; k++)
				{
					value += vector;
					vector += Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
				}
				vector += Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
				vector = Vector2.Clamp(vector, -Vector2.One, Vector2.One);
			}
			return true;
		}
Ejemplo n.º 22
0
 public override bool Perform(Point origin, GenAction action)
 {
     bool flag;
     int num = (this._useDiagonals ? 16 : 8);
     HashSet<Point16>.Enumerator enumerator = this._data.GetData().GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Point16 current = enumerator.Current;
             bool flag1 = false;
             int num1 = 0;
             while (num1 < num)
             {
                 if (this._data.Contains(current.X + ModShapes.InnerOutline.POINT_OFFSETS[num1], current.Y + ModShapes.InnerOutline.POINT_OFFSETS[num1 + 1]))
                 {
                     num1 = num1 + 2;
                 }
                 else
                 {
                     flag1 = true;
                     break;
                 }
             }
             if (!flag1 || base.UnitApply(action, origin, current.X + origin.X, current.Y + origin.Y, new object[0]) || !this._quitOnFail)
             {
                 continue;
             }
             flag = false;
             return flag;
         }
         return true;
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
 }
Ejemplo n.º 23
0
        public override bool Perform(Point origin, GenAction action)
        {
            float num1 = (float)_steps;
            float num2 = (float)_steps;
            double num3 = (double)_startStrength;
            Vector2 vector2_1 = new Vector2((float)origin.X, (float)origin.Y);
            Vector2 vector2_2 = _startVelocity == Vector2.Zero ? Utils.RandomVector2(GenBase._random, -1f, 1f) : _startVelocity;

            while (num1 > 0.0 && num3 > 0.0)
            {
                num3 = _startStrength * (num1 / num2);
                float num4 = num1 - 1f;
                int num5 = Math.Max(1, (int)(vector2_1.X - num3 * 0.5));
                int num6 = Math.Max(1, (int)(vector2_1.Y - num3 * 0.5));
                int num7 = Math.Min(GenBase._worldWidth, (int)(vector2_1.X + num3 * 0.5));
                int num8 = Math.Min(GenBase._worldHeight, (int)(vector2_1.Y + num3 * 0.5));
                for (int x = num5; x < num7; ++x)
                {
                    for (int y = num6; y < num8; ++y)
                    {
                        if ((double)Math.Abs((float)x - vector2_1.X) + Math.Abs((float)y - vector2_1.Y) < num3 * 0.5 * (1.0 + GenBase._random.Next(-10, 11) * 0.015))
                            UnitApply(action, origin, x, y);
                    }
                }

                int num9 = (int)(num3 / 50.0) + 1;
                num1 = num4 - (float)num9;
                vector2_1 += vector2_2;
                for (int index = 0; index < num9; ++index)
                {
                    vector2_1 += vector2_2;
                    vector2_2 += Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
                }

                vector2_2 = Vector2.Clamp(vector2_2 + Utils.RandomVector2(GenBase._random, -0.5f, 0.5f), -Vector2.One, Vector2.One);
            }
            return true;
        }
Ejemplo n.º 24
0
 public override bool Perform(Point origin, GenAction action)
 {
     float single = (float)this._steps;
     float single1 = (float)this._steps;
     double num = (double)this._startStrength;
     Vector2 vector2 = new Vector2((float)origin.X, (float)origin.Y);
     Vector2 vector21 = (this._startVelocity == Vector2.Zero ? Utils.RandomVector2(GenBase._random, -1f, 1f) : this._startVelocity);
     while (single > 0f && num > 0)
     {
         num = (double)(this._startStrength * (single / single1));
         single = single - 1f;
         int num1 = Math.Max(1, (int)((double)vector2.X - num * 0.5));
         int num2 = Math.Max(1, (int)((double)vector2.Y - num * 0.5));
         int num3 = Math.Min(GenBase._worldWidth, (int)((double)vector2.X + num * 0.5));
         int num4 = Math.Min(GenBase._worldHeight, (int)((double)vector2.Y + num * 0.5));
         for (int i = num1; i < num3; i++)
         {
             for (int j = num2; j < num4; j++)
             {
                 if ((double)(Math.Abs((float)i - vector2.X) + Math.Abs((float)j - vector2.Y)) < num * 0.5 * (1 + (double)GenBase._random.Next(-10, 11) * 0.015))
                 {
                     base.UnitApply(action, origin, i, j, new object[0]);
                 }
             }
         }
         int num5 = (int)(num / 50) + 1;
         single = single - (float)num5;
         vector2 = vector2 + vector21;
         for (int k = 0; k < num5; k++)
         {
             vector2 = vector2 + vector21;
             vector21 = vector21 + Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
         }
         vector21 = vector21 + Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
         vector21 = Vector2.Clamp(vector21, -Vector2.One, Vector2.One);
     }
     return true;
 }
Ejemplo n.º 25
0
 public override bool Perform(Point origin, GenAction action)
 {
     bool flag;
     HashSet<Point16>.Enumerator enumerator = this._data.GetData().GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Point16 current = enumerator.Current;
             if (base.UnitApply(action, origin, current.X + origin.X, current.Y + origin.Y, new object[0]) || !this._quitOnFail)
             {
                 continue;
             }
             flag = false;
             return flag;
         }
         return true;
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
 }
Ejemplo n.º 26
0
        public override bool Perform(Point origin, GenAction action)
        {
            Queue<Point> queue = new Queue<Point>();
            HashSet<Point16> hashSet = new HashSet<Point16>();
            queue.Enqueue(origin);

            int num = _maximumActions;
            while (queue.Count > 0 && num > 0)
            {
                Point point = queue.Dequeue();
                if (!hashSet.Contains(new Point16(point.X, point.Y)) && UnitApply(action, origin, point.X, point.Y))
                {
                    hashSet.Add(new Point16(point));
                    --num;
                    if (point.X + 1 < Main.maxTilesX - 1)
                        queue.Enqueue(new Point(point.X + 1, point.Y));
                    if (point.X - 1 >= 1)
                        queue.Enqueue(new Point(point.X - 1, point.Y));
                    if (point.Y + 1 < Main.maxTilesY - 1)
                        queue.Enqueue(new Point(point.X, point.Y + 1));
                    if (point.Y - 1 >= 1)
                        queue.Enqueue(new Point(point.X, point.Y - 1));
                }
            }

            while (queue.Count > 0)
            {
                Point point = queue.Dequeue();
                if (!hashSet.Contains(new Point16(point.X, point.Y)))
                {
                    queue.Enqueue(point);
                    break;
                }
            }

            return queue.Count == 0;
        }
Ejemplo n.º 27
0
 public static GenAction Continue(GenAction action)
 {
     return new Actions.ContinueWrapper(action);
 }
Ejemplo n.º 28
0
 public ContinueWrapper(GenAction action)
 {
     this._action = action;
 }
 public override bool Place(Point origin, StructureMap structures)
 {
     Point y;
     Point point;
     Dictionary<ushort, int> nums = new Dictionary<ushort, int>();
     Point point1 = new Point(origin.X - 25, origin.Y - 25);
     Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50);
     ushort[] numArray = new ushort[] { 0, 1 };
     WorldUtils.Gen(point1, rectangle, (new Actions.TileScanner(numArray)).Output(nums));
     if (nums[0] + nums[1] < 1250)
     {
         return false;
     }
     Searches.Up up = new Searches.Up(1000);
     GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(1, 50).Not() };
     bool flag = WorldUtils.Find(origin, Searches.Chain(up, genConditionArray), out y);
     Point point2 = origin;
     Searches.Up up1 = new Searches.Up(origin.Y - y.Y);
     GenCondition[] isTile = new GenCondition[1];
     ushort[] numArray1 = new ushort[] { 53 };
     isTile[0] = new Conditions.IsTile(numArray1);
     if (WorldUtils.Find(point2, Searches.Chain(up1, isTile), out point))
     {
         return false;
     }
     if (!flag)
     {
         return false;
     }
     y.Y = y.Y + 50;
     ShapeData shapeDatum = new ShapeData();
     ShapeData shapeDatum1 = new ShapeData();
     Point point3 = new Point(origin.X, origin.Y + 20);
     Point point4 = new Point(origin.X, origin.Y + 30);
     float single = 0.8f + GenBase._random.NextFloat() * 0.5f;
     if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 0))
     {
         return false;
     }
     if (!structures.CanPlace(new Rectangle(origin.X, y.Y + 10, 1, origin.Y - y.Y - 9), 2))
     {
         return false;
     }
     Shapes.Slime slime = new Shapes.Slime(20, single, 1f);
     GenAction[] blotch = new GenAction[] { new Modifiers.Blotches(2, 0.4), (new Actions.ClearTile(true)).Output(shapeDatum) };
     WorldUtils.Gen(point3, slime, Actions.Chain(blotch));
     Shapes.Mound mound = new Shapes.Mound(14, 14);
     GenAction[] genActionArray = new GenAction[] { new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0, false, true), (new Actions.SetFrames(true)).Output(shapeDatum1) };
     WorldUtils.Gen(point4, mound, Actions.Chain(genActionArray));
     shapeDatum.Subtract(shapeDatum1, point3, point4);
     ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true);
     GenAction[] setTile = new GenAction[] { new Actions.SetTile(2, false, true), new Actions.SetFrames(true) };
     WorldUtils.Gen(point3, innerOutline, Actions.Chain(setTile));
     ModShapes.All all = new ModShapes.All(shapeDatum);
     GenAction[] rectangleMask = new GenAction[] { new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid(0, 255) };
     WorldUtils.Gen(point3, all, Actions.Chain(rectangleMask));
     ModShapes.All all1 = new ModShapes.All(shapeDatum);
     GenAction[] placeWall = new GenAction[] { new Actions.PlaceWall(68, true), null, null, null };
     ushort[] numArray2 = new ushort[] { 2 };
     placeWall[1] = new Modifiers.OnlyTiles(numArray2);
     placeWall[2] = new Modifiers.Offset(0, 1);
     placeWall[3] = new ActionVines(3, 5, 52);
     WorldUtils.Gen(point3, all1, Actions.Chain(placeWall));
     ShapeData shapeDatum2 = new ShapeData();
     Point point5 = new Point(origin.X, y.Y + 10);
     Shapes.Rectangle rectangle1 = new Shapes.Rectangle(1, origin.Y - y.Y - 9);
     GenAction[] onlyTile = new GenAction[] { new Modifiers.Blotches(2, 0.2), (new Actions.ClearTile(false)).Output(shapeDatum2), new Modifiers.Expand(1), null, null };
     ushort[] numArray3 = new ushort[] { 53 };
     onlyTile[3] = new Modifiers.OnlyTiles(numArray3);
     onlyTile[4] = (new Actions.SetTile(397, false, true)).Output(shapeDatum2);
     WorldUtils.Gen(point5, rectangle1, Actions.Chain(onlyTile));
     WorldUtils.Gen(new Point(origin.X, y.Y + 10), new ModShapes.All(shapeDatum2), new Actions.SetFrames(true));
     if (GenBase._random.Next(3) != 0)
     {
         WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15);
     }
     else
     {
         WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17);
     }
     ModShapes.All all2 = new ModShapes.All(shapeDatum1);
     GenAction[] offset = new GenAction[] { new Modifiers.Offset(0, -1), null, null, null };
     ushort[] numArray4 = new ushort[] { 2 };
     offset[1] = new Modifiers.OnlyTiles(numArray4);
     offset[2] = new Modifiers.Offset(0, -1);
     offset[3] = new ActionGrass();
     WorldUtils.Gen(point4, all2, Actions.Chain(offset));
     structures.AddStructure(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 4);
     return true;
 }
 public override bool Place(Point origin, StructureMap structures)
 {
     Point point;
     if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
     {
         return false;
     }
     Searches.Down down = new Searches.Down(100);
     GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
     if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out origin))
     {
         return false;
     }
     Point point1 = new Point(origin.X - 4, origin.Y);
     Searches.Down down1 = new Searches.Down(5);
     GenCondition[] genConditionArray = new GenCondition[1];
     ushort[] numArray = new ushort[] { 25 };
     genConditionArray[0] = (new Conditions.IsTile(numArray)).AreaAnd(8, 1);
     if (!WorldUtils.Find(point1, Searches.Chain(down1, genConditionArray), out point))
     {
         return false;
     }
     ShapeData shapeDatum = new ShapeData();
     ShapeData shapeDatum1 = new ShapeData();
     ShapeData shapeDatum2 = new ShapeData();
     for (int i = 0; i < 6; i++)
     {
         Shapes.Circle circle = new Shapes.Circle(GenBase._random.Next(10, 12) + i);
         GenAction[] offset = new GenAction[] { new Modifiers.Offset(0, 5 * i + 5), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum) };
         WorldUtils.Gen(origin, circle, Actions.Chain(offset));
     }
     for (int j = 0; j < 6; j++)
     {
         Shapes.Circle circle1 = new Shapes.Circle(GenBase._random.Next(5, 7) + j);
         GenAction[] genActionArray = new GenAction[] { new Modifiers.Offset(0, 2 * j + 18), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum1) };
         WorldUtils.Gen(origin, circle1, Actions.Chain(genActionArray));
     }
     for (int k = 0; k < 6; k++)
     {
         Shapes.Circle circle2 = new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2);
         GenAction[] offset1 = new GenAction[] { new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum2) };
         WorldUtils.Gen(origin, circle2, Actions.Chain(offset1));
     }
     ShapeData shapeDatum3 = new ShapeData(shapeDatum1);
     shapeDatum1.Subtract(shapeDatum2, origin, origin);
     shapeDatum3.Subtract(shapeDatum1, origin, origin);
     ShapeData[] shapeDataArray = new ShapeData[] { shapeDatum, shapeDatum2 };
     Rectangle bounds = ShapeData.GetBounds(origin, shapeDataArray);
     if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
     {
         return false;
     }
     ModShapes.All all = new ModShapes.All(shapeDatum);
     GenAction[] setTile = new GenAction[] { new Actions.SetTile(25, true, true), new Actions.PlaceWall(3, true) };
     WorldUtils.Gen(origin, all, Actions.Chain(setTile));
     WorldUtils.Gen(origin, new ModShapes.All(shapeDatum1), new Actions.SetTile(0, true, true));
     WorldUtils.Gen(origin, new ModShapes.All(shapeDatum2), new Actions.ClearTile(true));
     ModShapes.All all1 = new ModShapes.All(shapeDatum1);
     GenAction[] isTouchingAir = new GenAction[] { new Modifiers.IsTouchingAir(true), null, null };
     ushort[] numArray1 = new ushort[] { 25 };
     isTouchingAir[1] = new Modifiers.NotTouching(false, numArray1);
     isTouchingAir[2] = new Actions.SetTile(23, true, true);
     WorldUtils.Gen(origin, all1, Actions.Chain(isTouchingAir));
     WorldUtils.Gen(origin, new ModShapes.All(shapeDatum3), new Actions.PlaceWall(69, true));
     structures.AddStructure(bounds, 2);
     return true;
 }
Ejemplo n.º 31
0
            public override bool Perform(Point origin, GenAction action)
            {
                Vector2 vector = new Vector2(origin.X << 4, origin.Y << 4);

                return(Utils.PlotTileTale(vector, vector + _endOffset, _width, (int x, int y) => UnitApply(action, origin, x, y) || !_quitOnFail));
            }
Ejemplo n.º 32
0
 // Token: 0x06000950 RID: 2384 RVA: 0x003B5B3C File Offset: 0x003B3D3C
 public static bool Gen(Point origin, GenShape shape, GenAction action)
 {
     return(shape.Perform(origin, action));
 }
Ejemplo n.º 33
0
 public ContinueWrapper(GenAction action)
 {
     _action = action;
 }
Ejemplo n.º 34
0
 public static GenAction Continue(GenAction action)
 {
     return(new ContinueWrapper(action));
 }
Ejemplo n.º 35
0
 public abstract bool Perform(Point origin, GenAction action);