public TileObjectCoordinatesModule(TileObjectCoordinatesModule copyFrom = null, int[] drawHeight = null)
 {
     if (copyFrom == null)
     {
         width = 0;
         padding = 0;
         paddingFix = Point16.Zero;
         styleWidth = 0;
         styleHeight = 0;
         calculated = false;
         heights = drawHeight;
     }
     else
     {
         width = copyFrom.width;
         padding = copyFrom.padding;
         paddingFix = copyFrom.paddingFix;
         styleWidth = copyFrom.styleWidth;
         styleHeight = copyFrom.styleHeight;
         calculated = copyFrom.calculated;
         if (drawHeight == null)
         {
             if (copyFrom.heights == null)
                 heights = null;
             else
             {
                 heights = new int[copyFrom.heights.Length];
                 Array.Copy(copyFrom.heights, heights, heights.Length);
             }
         }
         else
             heights = drawHeight;
     }
 }
		public TileObjectCoordinatesModule(TileObjectCoordinatesModule copyFrom = null, int[] drawHeight = null)
		{
			if (copyFrom == null)
			{
				this.width = 0;
				this.padding = 0;
				this.paddingFix = Point16.Zero;
				this.styleWidth = 0;
				this.styleHeight = 0;
				this.calculated = false;
				this.heights = drawHeight;
				return;
			}
			this.width = copyFrom.width;
			this.padding = copyFrom.padding;
			this.paddingFix = copyFrom.paddingFix;
			this.styleWidth = copyFrom.styleWidth;
			this.styleHeight = copyFrom.styleHeight;
			this.calculated = copyFrom.calculated;
			if (drawHeight != null)
			{
				this.heights = drawHeight;
				return;
			}
			if (copyFrom.heights == null)
			{
				this.heights = null;
				return;
			}
			this.heights = new int[(int)copyFrom.heights.Length];
			Array.Copy(copyFrom.heights, this.heights, (int)this.heights.Length);
		}
Esempio n. 3
0
 public static int AfterPlacement_Hook(int x, int y, int type = 21, int style = 0, int direction = 1)
 {
     Point16 point16 = new Point16(x, y);
     TileObjectData.OriginToTopLeft(type, style, ref point16);
     int num = Chest.FindEmptyChest(point16.X, point16.Y, 21, 0, 1);
     if (num == -1)
     {
         return -1;
     }
     if (Main.netMode != 1)
     {
         Chest chest = new Chest(false)
         {
             x = point16.X,
             y = point16.Y
         };
         for (int i = 0; i < 40; i++)
         {
             chest.item[i] = new Item();
         }
         Main.chest[num] = chest;
     }
     else if (type != 21)
     {
         NetMessage.SendData((int)PacketTypes.TileKill, -1, -1, "", 2, (float)x, (float)y, (float)style, 0, 0, 0);
     }
     else
     {
         NetMessage.SendData((int)PacketTypes.TileKill, -1, -1, "", 0, (float)x, (float)y, (float)style, 0, 0, 0);
     }
     return num;
 }
Esempio n. 4
0
 private static void RemoveTemporaryAnimation(short x, short y)
 {
     Point16 key = new Point16(x, y);
     if (!_temporaryAnimations.ContainsKey(key))
         return;
     _awaitingRemoval.Add(key);
 }
		private static void RemoveTemporaryAnimation(short x, short y)
		{
			Point16 point = new Point16(x, y);
			if (Animation._temporaryAnimations.ContainsKey(point))
			{
				Animation._awaitingRemoval.Add(point);
			}
		}
Esempio n. 6
0
 public static bool GetTemporaryFrame(int x, int y, out int frameData)
 {
     Animation animation;
     Point16 point16 = new Point16(x, y);
     if (!Animation._temporaryAnimations.TryGetValue(point16, out animation))
     {
         frameData = 0;
         return false;
     }
     frameData = animation._frameData[animation._frame];
     return true;
 }
Esempio n. 7
0
 public static void NewTemporaryAnimation(int type, ushort tileType, int x, int y)
 {
     Point16 point16 = new Point16(x, y);
     if (x < 0 || x >= Main.maxTilesX || (y < 0 || y >= Main.maxTilesY))
         return;
     Animation animation = new Animation();
     animation.SetDefaults(type);
     animation._tileType = tileType;
     animation._coordinates = point16;
     animation._temporary = true;
     _awaitingAddition.Add(animation);
     if (Main.netMode != 2)
         return;
     NetMessage.SendTemporaryAnimation(-1, type, tileType, x, y);
 }
 public TileObjectBaseModule(TileObjectBaseModule copyFrom = null)
 {
     if (copyFrom == null)
     {
         this.width = 1;
         this.height = 1;
         this.origin = Point16.Zero;
         this.direction = TileObjectDirection.None;
         this.randomRange = 0;
         this.flattenAnchors = false;
         return;
     }
     this.width = copyFrom.width;
     this.height = copyFrom.height;
     this.origin = copyFrom.origin;
     this.direction = copyFrom.direction;
     this.randomRange = copyFrom.randomRange;
     this.flattenAnchors = copyFrom.flattenAnchors;
 }
Esempio n. 9
0
 public TileObjectBaseModule(TileObjectBaseModule copyFrom = null)
 {
     if (copyFrom == null)
     {
         width = 1;
         height = 1;
         origin = Point16.Zero;
         direction = TileObjectDirection.None;
         randomRange = 0;
         flattenAnchors = false;
     }
     else
     {
         width = copyFrom.width;
         height = copyFrom.height;
         origin = copyFrom.origin;
         direction = copyFrom.direction;
         randomRange = copyFrom.randomRange;
         flattenAnchors = copyFrom.flattenAnchors;
     }
 }
Esempio n. 10
0
        public override bool Equals(object obj)
        {
            Point16 point = (Point16)obj;

            return(this.x == point.x && this.y == point.y);
        }
		public Point16 Max(Point16 compareTo)
		{
			return new Point16((this.X > compareTo.X) ? this.X : compareTo.X, (this.Y > compareTo.Y) ? this.Y : compareTo.Y);
		}
Esempio n. 12
0
        static void LoadTileData(BinBuffer bb, int v)
        {
            if (v < 4)
                return;

            TileDataEntryFlags fl;
            while ((fl = (TileDataEntryFlags)bb.ReadByte()) != TileDataEntryFlags.Finished)
            {
                var x = bb.ReadInt16();
                var y = bb.ReadInt16();
                var p = new Point16(x, y);
                var t = Main.tile[x, y].type;

                var bs = TileHooks.CreateBHandler(p);

                if ((fl & TileDataEntryFlags.Tile) != 0)
                {
                    var bh = bs.Item1;

                    foreach (var b in bh.behaviours)
                    {
                        b.HasTile  = true;
                        b.Position = p;
                    }

                    bh.Load(bb);
                }
                if ((fl & TileDataEntryFlags.Type) != 0)
                {
                    var bh = bs.Item2;

                    foreach (var b in bh.behaviours)
                    {
                        b.HasTile = true;
                        b.Position = p;
                    }

                    bh.Load(bb);
                }
            }
        }
Esempio n. 13
0
 private static void LoadSigns(BinaryReader reader)
 {
     short num = reader.ReadInt16();
     int i;
     for (i = 0; i < (int)num; i++)
     {
         string text = reader.ReadString();
         int num2 = reader.ReadInt32();
         int num3 = reader.ReadInt32();
         Tile tile = Main.tile[num2, num3];
         Sign sign;
         if (tile.active() && (tile.type == 55 || tile.type == 85))
         {
             sign = new Sign();
             sign.text = text;
             sign.x = num2;
             sign.y = num3;
         }
         else
         {
             sign = null;
         }
         Main.sign[i] = sign;
     }
     List<Point16> list = new List<Point16>();
     for (int j = 0; j < 1000; j++)
     {
         if (Main.sign[j] != null)
         {
             Point16 item = new Point16(Main.sign[j].x, Main.sign[j].y);
             if (list.Contains(item))
             {
                 Main.sign[j] = null;
             }
             else
             {
                 list.Add(item);
             }
         }
     }
     while (i < 1000)
     {
         Main.sign[i] = null;
         i++;
     }
 }
 public void Reset()
 {
     this._active = false;
     this._size = Point16.Zero;
     this._coordinates = Point16.Zero;
     this._objectStart = Point16.Zero;
     this._percentValid = 0f;
     this._type = 0;
     this._style = 0;
     this._alternate = -1;
     this._random = -1;
     if (this._data != null)
     {
         Array.Clear(this._data, 0, this._dataSize.X * this._dataSize.Y);
     }
 }
Esempio n. 15
0
 static Point16()
 {
     Point16.Zero = new Point16(0, 0);
     Point16.NegativeOne = new Point16(-1, -1);
 }
Esempio n. 16
0
 public DrillBeam()
 {
     this.curTileTarget = Point16.NegativeOne;
     this.cooldown = 0;
 }
Esempio n. 17
0
 public static void Add8WayLookup(int lookup, short point1X, short point1Y, short point2X, short point2Y, short point3X, short point3Y)
 {
     Point16[] point16 = new Point16[] { new Point16((int)(point1X * Framing.frameSize8Way.X), (int)(point1Y * Framing.frameSize8Way.Y)), new Point16((int)(point2X * Framing.frameSize8Way.X), (int)(point2Y * Framing.frameSize8Way.Y)), new Point16((int)(point3X * Framing.frameSize8Way.X), (int)(point3Y * Framing.frameSize8Way.Y)) };
     Framing.selfFrame8WayLookup[lookup] = point16;
 }
Esempio n. 18
0
 public static void Add8WayLookup(int lookup, short x, short y)
 {
     Point16[] point16 = new Point16[] { new Point16((int)(x * Framing.frameSize8Way.X), (int)(y * Framing.frameSize8Way.Y)), new Point16((int)(x * Framing.frameSize8Way.X), (int)(y * Framing.frameSize8Way.Y)), new Point16((int)(x * Framing.frameSize8Way.X), (int)(y * Framing.frameSize8Way.Y)) };
     Framing.selfFrame8WayLookup[lookup] = point16;
 }
Esempio n. 19
0
 public Point16 Max(Point16 compareTo)
 {
     return(new Point16((int)this.X > (int)compareTo.X ? this.X : compareTo.X, (int)this.Y > (int)compareTo.Y ? this.Y : compareTo.Y));
 }
Esempio n. 20
0
        public override bool Equals(object obj)
        {
            Point16 point16 = (Point16)obj;

            return((int)this.X == (int)point16.X && (int)this.Y == (int)point16.Y);
        }
Esempio n. 21
0
 public Point16 Max(Point16 compareTo)
 {
     return(new Point16((this.X > compareTo.X ? this.X : compareTo.X), (this.Y > compareTo.Y ? this.Y : compareTo.Y)));
 }
Esempio n. 22
0
 public Point16 Max(Point16 compareTo)
 {
     return(new Point16((int)X > (int)compareTo.X ? X : compareTo.X,
                        (int)Y > (int)compareTo.Y ? Y : compareTo.Y));
 }
Esempio n. 23
0
        static void SaveTileData(BinBuffer bb)
        {
            for (int y = 0; y < Main.maxTilesY; y++)
                for (int x = 0; x < Main.maxTilesX; x++)
                {
                    var p = new Point16(x, y);
                    var t = Main.tile[x, y].type;

                    var fl = TileDataEntryFlags.Finished;

                    if (TileHooks.TileSpecificHandlers.ContainsKey(p))
                        fl |= TileDataEntryFlags.Tile;
                    if (TileHooks.TypeSpecificHandlers.ContainsKey(t))
                        fl |= TileDataEntryFlags.Type;

                    if (fl == TileDataEntryFlags.Finished)
                        continue;

                    bb.Write((byte)fl);
                    bb.Write(p.X);
                    bb.Write(p.Y);

                    if ((fl & TileDataEntryFlags.Tile) != 0)
                    {
                        var bh = TileHooks.TileSpecificHandlers[p];

                        bh.Save(bb);
                    }
                    if ((fl & TileDataEntryFlags.Type) != 0)
                    {
                        var bh = TileHooks.TypeSpecificHandlers[t];

                        foreach (var b in bh.behaviours)
                            b.Position = p;

                        bh.Save(bb);
                    }
                }

            bb.Write(0);
        }
Esempio n. 24
0
 private void ReadInner(BinaryReader reader)
 {
     ID = reader.ReadInt32();
     Position = new Point16(reader.ReadInt16(), reader.ReadInt16());
     ReadExtraData(reader);
 }
Esempio n. 25
0
 static Point16()
 {
     Point16.Zero        = new Point16(0, 0);
     Point16.NegativeOne = new Point16(-1, -1);
 }
Esempio n. 26
0
 public static void OriginToTopLeft(int type, int style, ref Point16 baseCoords)
 {
     TileObjectData tileData = TileObjectData.GetTileData(type, style, 0);
     if (tileData == null)
     {
         return;
     }
     baseCoords = new Point16((int)(baseCoords.X - tileData.Origin.X), (int)(baseCoords.Y - tileData.Origin.Y));
 }
Esempio n. 27
0
 public static void Initialize()
 {
     Framing.selfFrame8WayLookup = new Point16[256][];
     Framing.frameSize8Way = new Point16(18, 18);
     Framing.Add8WayLookup(0, 9, 3, 10, 3, 11, 3);
     Framing.Add8WayLookup(1, 6, 3, 7, 3, 8, 3);
     Framing.Add8WayLookup(2, 12, 0, 12, 1, 12, 2);
     Framing.Add8WayLookup(3, 15, 2);
     Framing.Add8WayLookup(4, 9, 0, 9, 1, 9, 2);
     Framing.Add8WayLookup(5, 13, 2);
     Framing.Add8WayLookup(6, 6, 4, 7, 4, 8, 4);
     Framing.Add8WayLookup(7, 14, 2);
     Framing.Add8WayLookup(8, 6, 0, 7, 0, 8, 0);
     Framing.Add8WayLookup(9, 5, 0, 5, 1, 5, 2);
     Framing.Add8WayLookup(10, 15, 0);
     Framing.Add8WayLookup(11, 15, 1);
     Framing.Add8WayLookup(12, 13, 0);
     Framing.Add8WayLookup(13, 13, 1);
     Framing.Add8WayLookup(14, 14, 0);
     Framing.Add8WayLookup(15, 14, 1);
     Framing.Add8WayLookup(19, 1, 4, 3, 4, 5, 4);
     Framing.Add8WayLookup(23, 16, 3);
     Framing.Add8WayLookup(27, 17, 0);
     Framing.Add8WayLookup(31, 13, 4);
     Framing.Add8WayLookup(37, 0, 4, 2, 4, 4, 4);
     Framing.Add8WayLookup(39, 17, 3);
     Framing.Add8WayLookup(45, 16, 0);
     Framing.Add8WayLookup(47, 12, 4);
     Framing.Add8WayLookup(55, 1, 2, 2, 2, 3, 2);
     Framing.Add8WayLookup(63, 6, 2, 7, 2, 8, 2);
     Framing.Add8WayLookup(74, 1, 3, 3, 3, 5, 3);
     Framing.Add8WayLookup(75, 17, 1);
     Framing.Add8WayLookup(78, 16, 2);
     Framing.Add8WayLookup(79, 13, 3);
     Framing.Add8WayLookup(91, 4, 0, 4, 1, 4, 2);
     Framing.Add8WayLookup(95, 11, 0, 11, 1, 11, 2);
     Framing.Add8WayLookup(111, 17, 4);
     Framing.Add8WayLookup(127, 14, 3);
     Framing.Add8WayLookup(140, 0, 3, 2, 3, 4, 3);
     Framing.Add8WayLookup(141, 16, 1);
     Framing.Add8WayLookup(142, 17, 2);
     Framing.Add8WayLookup(143, 12, 3);
     Framing.Add8WayLookup(159, 16, 4);
     Framing.Add8WayLookup(173, 0, 0, 0, 1, 0, 2);
     Framing.Add8WayLookup(175, 10, 0, 10, 1, 10, 2);
     Framing.Add8WayLookup(191, 15, 3);
     Framing.Add8WayLookup(206, 1, 0, 2, 0, 3, 0);
     Framing.Add8WayLookup(207, 6, 1, 7, 1, 8, 1);
     Framing.Add8WayLookup(223, 14, 4);
     Framing.Add8WayLookup(239, 15, 4);
     Framing.Add8WayLookup(255, 1, 1, 2, 1, 3, 1);
     Framing.blockStyleLookup = new Framing.BlockStyle[] { new Framing.BlockStyle(true, true, true, true), new Framing.BlockStyle(false, true, true, true), new Framing.BlockStyle(false, true, true, false), new Framing.BlockStyle(false, true, false, true), new Framing.BlockStyle(true, false, true, false), new Framing.BlockStyle(true, false, false, true) };
     int[][] numArray = new int[][] { new int[] { 2, 4, 2 }, new int[] { 1, 3, 1 }, new int[] { 2, 2, 4 }, new int[] { 1, 1, 3 } };
     Framing.phlebasTileFrameNumberLookup = numArray;
     int[][] numArray1 = new int[][] { new int[] { 1, 2 }, new int[] { 3, 4 } };
     Framing.lazureTileFrameNumberLookup = numArray1;
     int[][] numArray2 = new int[3][];
     int[] numArray3 = new int[] { 2, 0, 0 };
     numArray2[0] = numArray3;
     int[] numArray4 = new int[] { 0, 1, 4 };
     numArray2[1] = numArray4;
     int[] numArray5 = new int[] { 0, 3, 0 };
     numArray2[2] = numArray5;
     Framing.centerWallFrameLookup = numArray2;
     Framing.wallFrameLookup = new Point16[20][];
     Framing.wallFrameSize = new Point16(36, 36);
     Framing.AddWallFrameLookup(0, 9, 3, 10, 3, 11, 3, 6, 6);
     Framing.AddWallFrameLookup(1, 6, 3, 7, 3, 8, 3, 4, 6);
     Framing.AddWallFrameLookup(2, 12, 0, 12, 1, 12, 2, 12, 5);
     Framing.AddWallFrameLookup(3, 1, 4, 3, 4, 5, 4, 3, 6);
     Framing.AddWallFrameLookup(4, 9, 0, 9, 1, 9, 2, 9, 5);
     Framing.AddWallFrameLookup(5, 0, 4, 2, 4, 4, 4, 2, 6);
     Framing.AddWallFrameLookup(6, 6, 4, 7, 4, 8, 4, 5, 6);
     Framing.AddWallFrameLookup(7, 1, 2, 2, 2, 3, 2, 3, 5);
     Framing.AddWallFrameLookup(8, 6, 0, 7, 0, 8, 0, 6, 5);
     Framing.AddWallFrameLookup(9, 5, 0, 5, 1, 5, 2, 5, 5);
     Framing.AddWallFrameLookup(10, 1, 3, 3, 3, 5, 3, 1, 6);
     Framing.AddWallFrameLookup(11, 4, 0, 4, 1, 4, 2, 4, 5);
     Framing.AddWallFrameLookup(12, 0, 3, 2, 3, 4, 3, 0, 6);
     Framing.AddWallFrameLookup(13, 0, 0, 0, 1, 0, 2, 0, 5);
     Framing.AddWallFrameLookup(14, 1, 0, 2, 0, 3, 0, 1, 6);
     Framing.AddWallFrameLookup(15, 1, 1, 2, 1, 3, 1, 2, 5);
     Framing.AddWallFrameLookup(16, 6, 1, 7, 1, 8, 1, 7, 5);
     Framing.AddWallFrameLookup(17, 6, 2, 7, 2, 8, 2, 8, 5);
     Framing.AddWallFrameLookup(18, 10, 0, 10, 1, 10, 2, 10, 5);
     Framing.AddWallFrameLookup(19, 11, 0, 11, 1, 11, 2, 11, 5);
 }
Esempio n. 28
0
 private Point16 DrillSmartCursor(Player mountedPlayer, Mount.DrillMountData data)
 {
     Vector2 vector2;
     vector2 = (mountedPlayer.whoAmI != Main.myPlayer ? data.crosshairPosition : Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY));
     Vector2 center = mountedPlayer.Center;
     Vector2 vector21 = vector2 - center;
     float single = vector21.Length();
     if (single > 224f)
     {
         single = 224f;
     }
     single = single + 32f;
     vector21.Normalize();
     Vector2 vector22 = center;
     Vector2 vector23 = center + (vector21 * single);
     Point16 point16 = new Point16(-1, -1);
     if (!Utils.PlotTileLine(vector22, vector23, 65.6f, (int x, int y) => {
         point16 = new Point16(x, y);
         for (int i = 0; i < (int)data.beams.Length; i++)
         {
             if (data.beams[i].curTileTarget == point16)
             {
                 return true;
             }
         }
         if (!WorldGen.CanKillTile(x, y))
         {
             return true;
         }
         if (Main.tile[x, y] != null && !Main.tile[x, y].inActive() && Main.tile[x, y].active())
         {
             return false;
         }
         return true;
     }))
     {
         return point16;
     }
     return new Point16(-1, -1);
 }
Esempio n. 29
0
 public static void SkipWire(Point16 point)
 {
     Wiring._wireSkip[point] = true;
 }
Esempio n. 30
0
 private static void LoadChests(BinaryReader reader)
 {
     int num = (int)reader.ReadInt16();
     int num2 = (int)reader.ReadInt16();
     int num3;
     int num4;
     if (num2 < 40)
     {
         num3 = num2;
         num4 = 0;
     }
     else
     {
         num3 = 40;
         num4 = num2 - 40;
     }
     int i;
     for (i = 0; i < num; i++)
     {
         Chest chest = new Chest(false);
         chest.x = reader.ReadInt32();
         chest.y = reader.ReadInt32();
         chest.name = reader.ReadString();
         for (int j = 0; j < num3; j++)
         {
             short num5 = reader.ReadInt16();
             Item item = new Item();
             if (num5 > 0)
             {
                 item.netDefaults(reader.ReadInt32());
                 item.stack = (int)num5;
                 item.Prefix((int)reader.ReadByte());
             }
             else if (num5 < 0)
             {
                 item.netDefaults(reader.ReadInt32());
                 item.Prefix((int)reader.ReadByte());
                 item.stack = 1;
             }
             chest.item[j] = item;
         }
         for (int j = 0; j < num4; j++)
         {
             short num5 = reader.ReadInt16();
             if (num5 > 0)
             {
                 reader.ReadInt32();
                 reader.ReadByte();
             }
         }
         Main.chest[i] = chest;
     }
     List<Point16> list = new List<Point16>();
     for (int k = 0; k < i; k++)
     {
         if (Main.chest[k] != null)
         {
             Point16 item2 = new Point16(Main.chest[k].x, Main.chest[k].y);
             if (list.Contains(item2))
             {
                 Main.chest[k] = null;
             }
             else
             {
                 list.Add(item2);
             }
         }
     }
     while (i < 1000)
     {
         Main.chest[i] = null;
         i++;
     }
     if (WorldFile.versionNumber < 115)
     {
         WorldFile.FixDresserChests();
     }
 }
Esempio n. 31
0
 private static void TripWire(int left, int top, int width, int height)
 {
     Point16 point16;
     if (Main.netMode == 1)
     {
         return;
     }
     Wiring.running = true;
     if (Wiring._wireList.Count != 0)
     {
         Wiring._wireList.Clear(true);
     }
     for (int i = left; i < left + width; i++)
     {
         for (int j = top; j < top + height; j++)
         {
             point16 = new Point16(i, j);
             Tile tile = Main.tile[i, j];
             if (tile != null && tile.wire())
             {
                 Wiring._wireList.PushBack(point16);
             }
         }
     }
     Vector2[] vector2Array = new Vector2[6];
     Wiring._teleport[0].X = -1f;
     Wiring._teleport[0].Y = -1f;
     Wiring._teleport[1].X = -1f;
     Wiring._teleport[1].Y = -1f;
     if (Wiring._wireList.Count > 0)
     {
         Wiring._numInPump = 0;
         Wiring._numOutPump = 0;
         Wiring.HitWire(Wiring._wireList, 1);
         if (Wiring._numInPump > 0 && Wiring._numOutPump > 0)
         {
             Wiring.XferWater();
         }
     }
     for (int k = left; k < left + width; k++)
     {
         for (int l = top; l < top + height; l++)
         {
             point16 = new Point16(k, l);
             Tile tile1 = Main.tile[k, l];
             if (tile1 != null && tile1.wire2())
             {
                 Wiring._wireList.PushBack(point16);
             }
         }
     }
     vector2Array[0] = Wiring._teleport[0];
     vector2Array[1] = Wiring._teleport[1];
     Wiring._teleport[0].X = -1f;
     Wiring._teleport[0].Y = -1f;
     Wiring._teleport[1].X = -1f;
     Wiring._teleport[1].Y = -1f;
     if (Wiring._wireList.Count > 0)
     {
         Wiring._numInPump = 0;
         Wiring._numOutPump = 0;
         Wiring.HitWire(Wiring._wireList, 2);
         if (Wiring._numInPump > 0 && Wiring._numOutPump > 0)
         {
             Wiring.XferWater();
         }
     }
     vector2Array[2] = Wiring._teleport[0];
     vector2Array[3] = Wiring._teleport[1];
     Wiring._teleport[0].X = -1f;
     Wiring._teleport[0].Y = -1f;
     Wiring._teleport[1].X = -1f;
     Wiring._teleport[1].Y = -1f;
     for (int m = left; m < left + width; m++)
     {
         for (int n = top; n < top + height; n++)
         {
             point16 = new Point16(m, n);
             Tile tile2 = Main.tile[m, n];
             if (tile2 != null && tile2.wire3())
             {
                 Wiring._wireList.PushBack(point16);
             }
         }
     }
     if (Wiring._wireList.Count > 0)
     {
         Wiring._numInPump = 0;
         Wiring._numOutPump = 0;
         Wiring.HitWire(Wiring._wireList, 3);
         if (Wiring._numInPump > 0 && Wiring._numOutPump > 0)
         {
             Wiring.XferWater();
         }
     }
     vector2Array[4] = Wiring._teleport[0];
     vector2Array[5] = Wiring._teleport[1];
     for (int o = 0; o < 5; o = o + 2)
     {
         Wiring._teleport[0] = vector2Array[o];
         Wiring._teleport[1] = vector2Array[o + 1];
         if (Wiring._teleport[0].X >= 0f && Wiring._teleport[1].X >= 0f)
         {
             Wiring.Teleport();
         }
     }
 }
 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];
         }
     }
 }
Esempio n. 33
0
 private static void HitWire(DoubleStack<Point16> next, int wireType)
 {
     int num;
     int num1;
     bool flag;
     byte num2;
     for (int i = 0; i < next.Count; i++)
     {
         Point16 point16 = next.PopFront();
         Wiring.SkipWire(point16);
         Wiring._toProcess.Add(point16, 4);
         next.PushBack(point16);
     }
     while (next.Count > 0)
     {
         Point16 point161 = next.PopFront();
         int x = point161.X;
         int y = point161.Y;
         if (!Wiring._wireSkip.ContainsKey(point161))
         {
             Wiring.HitWireSingle(x, y);
         }
         for (int j = 0; j < 4; j++)
         {
             switch (j)
             {
                 case 0:
                 {
                     num = x;
                     num1 = y + 1;
                     break;
                 }
                 case 1:
                 {
                     num = x;
                     num1 = y - 1;
                     break;
                 }
                 case 2:
                 {
                     num = x + 1;
                     num1 = y;
                     break;
                 }
                 case 3:
                 {
                     num = x - 1;
                     num1 = y;
                     break;
                 }
                 default:
                 {
                     num = x;
                     num1 = y + 1;
                     break;
                 }
             }
             if (num >= 2 && num < Main.maxTilesX - 2 && num1 >= 2 && num1 < Main.maxTilesY - 2)
             {
                 Tile tile = Main.tile[num, num1];
                 if (tile != null)
                 {
                     switch (wireType)
                     {
                         case 1:
                         {
                             flag = tile.wire();
                             break;
                         }
                         case 2:
                         {
                             flag = tile.wire2();
                             break;
                         }
                         case 3:
                         {
                             flag = tile.wire3();
                             break;
                         }
                         default:
                         {
                             flag = false;
                             break;
                         }
                     }
                     if (flag)
                     {
                         Point16 point162 = new Point16(num, num1);
                         if (!Wiring._toProcess.TryGetValue(point162, out num2))
                         {
                             next.PushBack(point162);
                             Wiring._toProcess.Add(point162, 3);
                         }
                         else
                         {
                             num2 = (byte)(num2 - 1);
                             if (num2 != 0)
                             {
                                 Wiring._toProcess[point162] = num2;
                             }
                             else
                             {
                                 Wiring._toProcess.Remove(point162);
                             }
                         }
                     }
                 }
             }
         }
     }
     Wiring._wireSkip.Clear();
     Wiring._toProcess.Clear();
     Wiring.running = false;
 }
Esempio n. 34
0
 public static void AddLight(int i, int j, float R, float G, float B)
 {
     if (Main.gamePaused || Main.netMode == 2 || (i - Lighting.firstTileX + Lighting.offScreenTiles < 0 || i - Lighting.firstTileX + Lighting.offScreenTiles >= Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10) || (j - Lighting.firstTileY + Lighting.offScreenTiles < 0 || j - Lighting.firstTileY + Lighting.offScreenTiles >= Main.screenHeight / 16 + Lighting.offScreenTiles * 2 + 10 || Lighting.tempLights.Count == Lighting.maxTempLights))
         return;
     Point16 key = new Point16(i, j);
     Lighting.ColorTriplet colorTriplet;
     if (Lighting.tempLights.TryGetValue(key, out colorTriplet))
     {
         if (Lighting.RGB)
         {
             if ((double)colorTriplet.r < (double)R)
                 colorTriplet.r = R;
             if ((double)colorTriplet.g < (double)G)
                 colorTriplet.g = G;
             if ((double)colorTriplet.b < (double)B)
                 colorTriplet.b = B;
             Lighting.tempLights[key] = colorTriplet;
         }
         else
         {
             float averageColor = (float)(((double)R + (double)G + (double)B) / 3.0);
             if ((double)colorTriplet.r >= (double)averageColor)
                 return;
             Lighting.tempLights[key] = new Lighting.ColorTriplet(averageColor);
         }
     }
     else
     {
         colorTriplet = !Lighting.RGB ? new Lighting.ColorTriplet((float)(((double)R + (double)G + (double)B) / 3.0)) : new Lighting.ColorTriplet(R, G, B);
         Lighting.tempLights.Add(key, colorTriplet);
     }
 }
Esempio n. 35
0
 private void ReadInner(BinaryReader reader)
 {
     ID       = reader.ReadInt32();
     Position = new Point16(reader.ReadInt16(), reader.ReadInt16());
     ReadExtraData(reader);
 }
Esempio n. 36
0
 public static void AddWallFrameLookup(int lookup, short point1X, short point1Y, short point2X, short point2Y, short point3X, short point3Y, short point4X, short point4Y)
 {
     Point16[] point16 = new Point16[] { new Point16((int)(point1X * Framing.wallFrameSize.X), (int)(point1Y * Framing.wallFrameSize.Y)), new Point16((int)(point2X * Framing.wallFrameSize.X), (int)(point2Y * Framing.wallFrameSize.Y)), new Point16((int)(point3X * Framing.wallFrameSize.X), (int)(point3Y * Framing.wallFrameSize.Y)), new Point16((int)(point4X * Framing.wallFrameSize.X), (int)(point4Y * Framing.wallFrameSize.Y)) };
     Framing.wallFrameLookup[lookup] = point16;
 }
Esempio n. 37
0
 public Point16 Max(Point16 compareTo)
 {
     return new Point16((int)X > (int)compareTo.X ? X : compareTo.X, (int)Y > (int)compareTo.Y ? Y : compareTo.Y);
 }