Beispiel #1
0
 public void CopyFrom(TileObjectPreviewData copy)
 {
     _type         = copy._type;
     _style        = copy._style;
     _alternate    = copy._alternate;
     _random       = copy._random;
     _active       = copy._active;
     _size         = copy._size;
     _coordinates  = copy._coordinates;
     _objectStart  = copy._objectStart;
     _percentValid = copy._percentValid;
     if (_data == null)
     {
         _data     = new int[copy._dataSize.X, copy._dataSize.Y];
         _dataSize = copy._dataSize;
     }
     else
     {
         Array.Clear(_data, 0, _data.Length);
     }
     if (_dataSize.X < copy._dataSize.X || _dataSize.Y < copy._dataSize.Y)
     {
         int num  = (copy._dataSize.X > _dataSize.X) ? copy._dataSize.X : _dataSize.X;
         int num2 = (copy._dataSize.Y > _dataSize.Y) ? copy._dataSize.Y : _dataSize.Y;
         _data     = new int[num, num2];
         _dataSize = new Point16(num, num2);
     }
     for (int i = 0; i < copy._dataSize.X; i++)
     {
         for (int j = 0; j < copy._dataSize.Y; j++)
         {
             _data[i, j] = copy._data[i, j];
         }
     }
 }
Beispiel #2
0
 public void CopyFrom(TileObjectPreviewData copy)
 {
     this._type         = copy._type;
     this._style        = copy._style;
     this._alternate    = copy._alternate;
     this._random       = copy._random;
     this._active       = copy._active;
     this._size         = copy._size;
     this._coordinates  = copy._coordinates;
     this._objectStart  = copy._objectStart;
     this._percentValid = copy._percentValid;
     if (this._data == null)
     {
         this._data     = new int[(int)copy._dataSize.X, (int)copy._dataSize.Y];
         this._dataSize = copy._dataSize;
     }
     else
     {
         Array.Clear((Array)this._data, 0, this._data.Length);
     }
     if ((int)this._dataSize.X < (int)copy._dataSize.X || (int)this._dataSize.Y < (int)copy._dataSize.Y)
     {
         int X = (int)copy._dataSize.X > (int)this._dataSize.X ? (int)copy._dataSize.X : (int)this._dataSize.X;
         int Y = (int)copy._dataSize.Y > (int)this._dataSize.Y ? (int)copy._dataSize.Y : (int)this._dataSize.Y;
         this._data     = new int[X, Y];
         this._dataSize = new Point16(X, Y);
     }
     for (int index1 = 0; index1 < (int)copy._dataSize.X; ++index1)
     {
         for (int index2 = 0; index2 < (int)copy._dataSize.Y; ++index2)
         {
             this._data[index1, index2] = copy._data[index1, index2];
         }
     }
 }
 // Token: 0x060012DC RID: 4828 RVA: 0x00419750 File Offset: 0x00417950
 public void CopyFrom(TileObjectPreviewData copy)
 {
     this._type         = copy._type;
     this._style        = copy._style;
     this._alternate    = copy._alternate;
     this._random       = copy._random;
     this._active       = copy._active;
     this._size         = copy._size;
     this._coordinates  = copy._coordinates;
     this._objectStart  = copy._objectStart;
     this._percentValid = copy._percentValid;
     if (this._data == null)
     {
         this._data     = new int[(int)copy._dataSize.X, (int)copy._dataSize.Y];
         this._dataSize = copy._dataSize;
     }
     else
     {
         Array.Clear(this._data, 0, this._data.Length);
     }
     if (this._dataSize.X < copy._dataSize.X || this._dataSize.Y < copy._dataSize.Y)
     {
         int num  = (int)((copy._dataSize.X > this._dataSize.X) ? copy._dataSize.X : this._dataSize.X);
         int num2 = (int)((copy._dataSize.Y > this._dataSize.Y) ? copy._dataSize.Y : this._dataSize.Y);
         this._data     = new int[num, num2];
         this._dataSize = new Point16(num, num2);
     }
     for (int i = 0; i < (int)copy._dataSize.X; i++)
     {
         for (int j = 0; j < (int)copy._dataSize.Y; j++)
         {
             this._data[i, j] = copy._data[i, j];
         }
     }
 }
 public void CopyFrom(TileObjectPreviewData copy)
 {
     this._type = copy._type;
     this._style = copy._style;
     this._alternate = copy._alternate;
     this._random = copy._random;
     this._active = copy._active;
     this._size = copy._size;
     this._coordinates = copy._coordinates;
     this._objectStart = copy._objectStart;
     this._percentValid = copy._percentValid;
     if (this._data != null)
     {
         Array.Clear(this._data, 0, this._data.Length);
     }
     else
     {
         this._data = new int[copy._dataSize.X, copy._dataSize.Y];
         this._dataSize = copy._dataSize;
     }
     if (this._dataSize.X < copy._dataSize.X || this._dataSize.Y < copy._dataSize.Y)
     {
         int num = (copy._dataSize.X > this._dataSize.X ? (int)copy._dataSize.X : (int)this._dataSize.X);
         int num1 = (copy._dataSize.Y > this._dataSize.Y ? (int)copy._dataSize.Y : (int)this._dataSize.Y);
         this._data = new int[num, num1];
         this._dataSize = new Point16(num, num1);
     }
     for (int i = 0; i < copy._dataSize.X; i++)
     {
         for (int j = 0; j < copy._dataSize.Y; j++)
         {
             this._data[i, j] = copy._data[i, j];
         }
     }
 }
Beispiel #5
0
 public static void DrawPreview(SpriteBatch sb, TileObjectPreviewData op, Vector2 position)
 {
     Point16 coordinates = op.Coordinates;
     Texture2D texture = Main.tileTexture[(int)op.Type];
     TileObjectData tileData = TileObjectData.GetTileData((int)op.Type, (int)op.Style, op.Alternate);
     int num1 = tileData.CalculatePlacementStyle((int)op.Style, op.Alternate, op.Random);
     int num2 = 0;
     int drawYoffset = tileData.DrawYOffset;
     if (tileData.StyleWrapLimit > 0)
     {
         num2 = num1 / tileData.StyleWrapLimit;
         num1 %= tileData.StyleWrapLimit;
     }
     int num3;
     int num4;
     if (tileData.StyleHorizontal)
     {
         num3 = tileData.CoordinateFullWidth * num1;
         num4 = tileData.CoordinateFullHeight * num2;
     }
     else
     {
         num3 = tileData.CoordinateFullWidth * num2;
         num4 = tileData.CoordinateFullHeight * num1;
     }
     for (int index1 = 0; index1 < (int)op.Size.X; ++index1)
     {
         int x = num3 + (index1 - (int)op.ObjectStart.X) * (tileData.CoordinateWidth + tileData.CoordinatePadding);
         int y = num4;
         for (int index2 = 0; index2 < (int)op.Size.Y; ++index2)
         {
             int i = (int)coordinates.X + index1;
             int num5 = (int)coordinates.Y + index2;
             if (index2 == 0 && tileData.DrawStepDown != 0 && WorldGen.SolidTile(Framing.GetTileSafely(i, num5 - 1)))
                 drawYoffset += tileData.DrawStepDown;
             Color color1;
             switch (op[index1, index2])
             {
                 case 1:
                     color1 = Color.White;
                     break;
                 case 2:
                     color1 = Color.Red * 0.7f;
                     break;
                 default:
                     goto default;
             }
             Color color2 = color1 * 0.5f;
             if (index1 >= (int)op.ObjectStart.X && index1 < (int)op.ObjectStart.X + tileData.Width && (index2 >= (int)op.ObjectStart.Y && index2 < (int)op.ObjectStart.Y + tileData.Height))
             {
                 SpriteEffects effects = SpriteEffects.None;
                 if (tileData.DrawFlipHorizontal && index1 % 2 == 1)
                     effects |= SpriteEffects.FlipHorizontally;
                 if (tileData.DrawFlipVertical && index2 % 2 == 1)
                     effects |= SpriteEffects.FlipVertically;
                 Rectangle rectangle = new Rectangle(x, y, tileData.CoordinateWidth, tileData.CoordinateHeights[index2 - (int)op.ObjectStart.Y]);
                 sb.Draw(texture, new Vector2((float)(i * 16 - (int)((double)position.X + (double)(tileData.CoordinateWidth - 16) / 2.0)), (float)(num5 * 16 - (int)position.Y + drawYoffset)), new Rectangle?(rectangle), color2, 0.0f, Vector2.Zero, 1f, effects, 0.0f);
                 y += tileData.CoordinateHeights[index2 - (int)op.ObjectStart.Y] + tileData.CoordinatePadding;
             }
         }
     }
 }
		public static void DrawPreview(SpriteBatch sb, TileObjectPreviewData op, Vector2 position)
		{
			Point16 coordinates = op.Coordinates;
			Texture2D texture = Main.tileTexture[(int)op.Type];
			TileObjectData tileData = TileObjectData.GetTileData((int)op.Type, (int)op.Style, op.Alternate);
			int num = tileData.CalculatePlacementStyle((int)op.Style, op.Alternate, op.Random);
			int num2 = 0;
			int num3 = tileData.DrawYOffset;
			if (tileData.StyleWrapLimit > 0)
			{
				num2 = num / tileData.StyleWrapLimit;
				num %= tileData.StyleWrapLimit;
			}
			int num4;
			int num5;
			if (tileData.StyleHorizontal)
			{
				num4 = tileData.CoordinateFullWidth * num;
				num5 = tileData.CoordinateFullHeight * num2;
			}
			else
			{
				num4 = tileData.CoordinateFullWidth * num2;
				num5 = tileData.CoordinateFullHeight * num;
			}
			for (int i = 0; i < (int)op.Size.X; i++)
			{
				int x = num4 + (i - (int)op.ObjectStart.X) * (tileData.CoordinateWidth + tileData.CoordinatePadding);
				int num6 = num5;
				int j = 0;
				while (j < (int)op.Size.Y)
				{
					int num7 = (int)coordinates.X + i;
					int num8 = (int)coordinates.Y + j;
					if (j == 0 && tileData.DrawStepDown != 0)
					{
						Tile tileSafely = Framing.GetTileSafely(num7, num8 - 1);
						if (WorldGen.SolidTile(tileSafely))
						{
							num3 += tileData.DrawStepDown;
						}
					}
					Color color;
					switch (op[i, j])
					{
					case 1:
						color = Color.White;
						goto IL_15E;
					case 2:
						color = Color.Red * 0.7f;
						goto IL_15E;
					}
					IL_293:
					j++;
					continue;
					IL_15E:
					color *= 0.5f;
					if (i >= (int)op.ObjectStart.X && i < (int)op.ObjectStart.X + tileData.Width && j >= (int)op.ObjectStart.Y && j < (int)op.ObjectStart.Y + tileData.Height)
					{
						SpriteEffects spriteEffects = SpriteEffects.None;
						if (tileData.DrawFlipHorizontal && i % 2 == 1)
						{
							spriteEffects |= SpriteEffects.FlipHorizontally;
						}
						if (tileData.DrawFlipVertical && j % 2 == 1)
						{
							spriteEffects |= SpriteEffects.FlipVertically;
						}
						Rectangle value = new Rectangle(x, num6, tileData.CoordinateWidth, tileData.CoordinateHeights[j - (int)op.ObjectStart.Y]);
						sb.Draw(texture, new Vector2((float)(num7 * 16 - (int)(position.X + (float)(tileData.CoordinateWidth - 16) / 2f)), (float)(num8 * 16 - (int)position.Y + num3)), new Rectangle?(value), color, 0f, Vector2.Zero, 1f, spriteEffects, 0f);
						num6 += tileData.CoordinateHeights[j - (int)op.ObjectStart.Y] + tileData.CoordinatePadding;
						goto IL_293;
					}
					goto IL_293;
				}
			}
		}
 public static void DrawPreview(TileObjectPreviewData op, Vector2 position)
 {
 }
 static TileObject()
 {
     TileObject.Empty = new TileObject();
     TileObject.objectPreview = new TileObjectPreviewData();
 }
        public void CopyFrom(TileObjectPreviewData copy)
        {
            _type = copy._type;
            _style = copy._style;
            _alternate = copy._alternate;
            _random = copy._random;
            _active = copy._active;
            _size = copy._size;
            _coordinates = copy._coordinates;
            _objectStart = copy._objectStart;
            _percentValid = copy._percentValid;

            if (_data == null)
            {
                _data = new int[(int)copy._dataSize.X, (int)copy._dataSize.Y];
                _dataSize = copy._dataSize;
            }
            else
                Array.Clear(_data, 0, _data.Length);

            if ((int)_dataSize.X < (int)copy._dataSize.X || (int)_dataSize.Y < (int)copy._dataSize.Y)
            {
                int X = (int)copy._dataSize.X > (int)_dataSize.X ? (int)copy._dataSize.X : (int)_dataSize.X;
                int Y = (int)copy._dataSize.Y > (int)_dataSize.Y ? (int)copy._dataSize.Y : (int)_dataSize.Y;
                _data = new int[X, Y];
                _dataSize = new Point16(X, Y);
            }

            for (int index1 = 0; index1 < (int)copy._dataSize.X; ++index1)
            {
                for (int index2 = 0; index2 < (int)copy._dataSize.Y; ++index2)
                    _data[index1, index2] = copy._data[index1, index2];
            }
        }