public override void NetReceive(BinaryReader reader) { Coordinates = new Point16(reader.ReadInt16(), reader.ReadInt16()); }
public void saveCollectorLocation(Point16 location) { currentStockedEntityLocation = location; }
public override void NetReceive(BinaryReader reader, bool lightReceive) { Inactive = reader.ReadBoolean(); center = new Point16(reader.ReadInt16(), reader.ReadInt16()); }
public static Point16 Add(this Point16 point, int p1x, int p1y) => new Point16(point.X + p1x, point.Y + p1y);
public static bool CanPlace(int x, int y, int type, int style, int dir, out TileObject objectData, bool onlyCheck = false) { TileObjectData tileData1 = TileObjectData.GetTileData(type, style, 0); objectData = TileObject.Empty; if (tileData1 == null) { return(false); } int num1 = x - (int)tileData1.Origin.X; int num2 = y - (int)tileData1.Origin.Y; if (num1 < 0 || num1 + tileData1.Width >= Main.maxTilesX || (num2 < 0 || num2 + tileData1.Height >= Main.maxTilesY)) { return(false); } bool flag1 = tileData1.RandomStyleRange > 0; if (TileObjectPreviewData.placementCache == null) { TileObjectPreviewData.placementCache = new TileObjectPreviewData(); } TileObjectPreviewData.placementCache.Reset(); int num3 = 0; int num4 = 0; if (tileData1.AlternatesCount != 0) { num4 = tileData1.AlternatesCount; } float num5 = -1f; float num6 = -1f; int num7 = 0; TileObjectData tileObjectData = (TileObjectData)null; int alternate = num3 - 1; while (alternate < num4) { ++alternate; TileObjectData tileData2 = TileObjectData.GetTileData(type, style, alternate); if (tileData2.Direction == TileObjectDirection.None || (tileData2.Direction != TileObjectDirection.PlaceLeft || dir != 1) && (tileData2.Direction != TileObjectDirection.PlaceRight || dir != -1)) { int num8 = x - (int)tileData2.Origin.X; int num9 = y - (int)tileData2.Origin.Y; if (num8 < 5 || num8 + tileData2.Width > Main.maxTilesX - 5 || (num9 < 5 || num9 + tileData2.Height > Main.maxTilesY - 5)) { return(false); } Rectangle rectangle = new Rectangle(0, 0, tileData2.Width, tileData2.Height); int X = 0; int Y = 0; if (tileData2.AnchorTop.tileCount != 0) { if (rectangle.Y == 0) { rectangle.Y = -1; ++rectangle.Height; ++Y; } int num10 = tileData2.AnchorTop.checkStart; if (num10 < rectangle.X) { rectangle.Width += rectangle.X - num10; X += rectangle.X - num10; rectangle.X = num10; } int num11 = num10 + tileData2.AnchorTop.tileCount - 1; int num12 = rectangle.X + rectangle.Width - 1; if (num11 > num12) { rectangle.Width += num11 - num12; } } if (tileData2.AnchorBottom.tileCount != 0) { if (rectangle.Y + rectangle.Height == tileData2.Height) { ++rectangle.Height; } int num10 = tileData2.AnchorBottom.checkStart; if (num10 < rectangle.X) { rectangle.Width += rectangle.X - num10; X += rectangle.X - num10; rectangle.X = num10; } int num11 = num10 + tileData2.AnchorBottom.tileCount - 1; int num12 = rectangle.X + rectangle.Width - 1; if (num11 > num12) { rectangle.Width += num11 - num12; } } if (tileData2.AnchorLeft.tileCount != 0) { if (rectangle.X == 0) { rectangle.X = -1; ++rectangle.Width; ++X; } int num10 = tileData2.AnchorLeft.checkStart; if ((tileData2.AnchorLeft.type & AnchorType.Tree) == AnchorType.Tree) { --num10; } if (num10 < rectangle.Y) { rectangle.Width += rectangle.Y - num10; Y += rectangle.Y - num10; rectangle.Y = num10; } int num11 = num10 + tileData2.AnchorLeft.tileCount - 1; if ((tileData2.AnchorLeft.type & AnchorType.Tree) == AnchorType.Tree) { num11 += 2; } int num12 = rectangle.Y + rectangle.Height - 1; if (num11 > num12) { rectangle.Height += num11 - num12; } } if (tileData2.AnchorRight.tileCount != 0) { if (rectangle.X + rectangle.Width == tileData2.Width) { ++rectangle.Width; } int num10 = tileData2.AnchorLeft.checkStart; if ((tileData2.AnchorRight.type & AnchorType.Tree) == AnchorType.Tree) { --num10; } if (num10 < rectangle.Y) { rectangle.Width += rectangle.Y - num10; Y += rectangle.Y - num10; rectangle.Y = num10; } int num11 = num10 + tileData2.AnchorRight.tileCount - 1; if ((tileData2.AnchorRight.type & AnchorType.Tree) == AnchorType.Tree) { num11 += 2; } int num12 = rectangle.Y + rectangle.Height - 1; if (num11 > num12) { rectangle.Height += num11 - num12; } } if (onlyCheck) { TileObject.objectPreview.Reset(); TileObject.objectPreview.Active = true; TileObject.objectPreview.Type = (ushort)type; TileObject.objectPreview.Style = (short)style; TileObject.objectPreview.Alternate = alternate; TileObject.objectPreview.Size = new Point16(rectangle.Width, rectangle.Height); TileObject.objectPreview.ObjectStart = new Point16(X, Y); TileObject.objectPreview.Coordinates = new Point16(num8 - X, num9 - Y); } float num13 = 0.0f; float num14 = (float)(tileData2.Width * tileData2.Height); float num15 = 0.0f; float num16 = 0.0f; for (int index1 = 0; index1 < tileData2.Width; ++index1) { for (int index2 = 0; index2 < tileData2.Height; ++index2) { Tile tileSafely = Framing.GetTileSafely(num8 + index1, num9 + index2); bool flag2 = !tileData2.LiquidPlace(tileSafely); bool flag3 = false; if (tileData2.AnchorWall) { ++num16; if (!tileData2.isValidWallAnchor((int)tileSafely.wall)) { flag3 = true; } else { ++num15; } } bool flag4 = false; if (tileSafely.active() && !Main.tileCut[(int)tileSafely.type]) { flag4 = true; } if (flag4 || flag2 || flag3) { if (onlyCheck) { TileObject.objectPreview[index1 + X, index2 + Y] = 2; } } else { if (onlyCheck) { TileObject.objectPreview[index1 + X, index2 + Y] = 1; } ++num13; } } } AnchorData anchorBottom = tileData2.AnchorBottom; if (anchorBottom.tileCount != 0) { num16 += (float)anchorBottom.tileCount; int height = tileData2.Height; for (int index = 0; index < anchorBottom.tileCount; ++index) { int num10 = anchorBottom.checkStart + index; Tile tileSafely = Framing.GetTileSafely(num8 + num10, num9 + height); bool flag2 = false; if (tileSafely.nactive()) { if ((anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile && Main.tileSolid[(int)tileSafely.type] && (!Main.tileSolidTop[(int)tileSafely.type] && !Main.tileNoAttach[(int)tileSafely.type]) && (tileData2.FlattenAnchors || tileSafely.blockType() == 0)) { flag2 = tileData2.isValidTileAnchor((int)tileSafely.type); } if (!flag2 && ((anchorBottom.type & AnchorType.SolidWithTop) == AnchorType.SolidWithTop || (anchorBottom.type & AnchorType.Table) == AnchorType.Table)) { if ((int)tileSafely.type == 19) { int num11 = (int)tileSafely.frameX / TileObjectData.PlatformFrameWidth(); if (!tileSafely.halfBrick() && num11 >= 0 && num11 <= 7 || (num11 >= 12 && num11 <= 16 || num11 >= 25 && num11 <= 26)) { flag2 = true; } } else if (Main.tileSolid[(int)tileSafely.type] && Main.tileSolidTop[(int)tileSafely.type]) { flag2 = true; } } if (!flag2 && (anchorBottom.type & AnchorType.Table) == AnchorType.Table && ((int)tileSafely.type != 19 && Main.tileTable[(int)tileSafely.type]) && tileSafely.blockType() == 0) { flag2 = true; } if (!flag2 && (anchorBottom.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type])) { switch (tileSafely.blockType()) { case 4: case 5: flag2 = tileData2.isValidTileAnchor((int)tileSafely.type); break; } } if (!flag2 && (anchorBottom.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely.type)) { flag2 = true; } } else if (!flag2 && (anchorBottom.type & AnchorType.EmptyTile) == AnchorType.EmptyTile) { flag2 = true; } if (!flag2) { if (onlyCheck) { TileObject.objectPreview[num10 + X, height + Y] = 2; } } else { if (onlyCheck) { TileObject.objectPreview[num10 + X, height + Y] = 1; } ++num15; } } } AnchorData anchorTop = tileData2.AnchorTop; if (anchorTop.tileCount != 0) { num16 += (float)anchorTop.tileCount; int num10 = -1; for (int index = 0; index < anchorTop.tileCount; ++index) { int num11 = anchorTop.checkStart + index; Tile tileSafely = Framing.GetTileSafely(num8 + num11, num9 + num10); bool flag2 = false; if (tileSafely.nactive()) { if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && !Main.tileNoAttach[(int)tileSafely.type] && (tileData2.FlattenAnchors || tileSafely.blockType() == 0)) { flag2 = tileData2.isValidTileAnchor((int)tileSafely.type); } if (!flag2 && (anchorTop.type & AnchorType.SolidBottom) == AnchorType.SolidBottom && (Main.tileSolid[(int)tileSafely.type] && (!Main.tileSolidTop[(int)tileSafely.type] || (int)tileSafely.type == 19 && (tileSafely.halfBrick() || tileSafely.topSlope())) || (tileSafely.halfBrick() || tileSafely.topSlope())) && (!TileID.Sets.NotReallySolid[(int)tileSafely.type] && !tileSafely.bottomSlope())) { flag2 = tileData2.isValidTileAnchor((int)tileSafely.type); } if (!flag2 && (anchorTop.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type])) { switch (tileSafely.blockType()) { case 2: case 3: flag2 = tileData2.isValidTileAnchor((int)tileSafely.type); break; } } if (!flag2 && (anchorTop.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely.type)) { flag2 = true; } } else if (!flag2 && (anchorTop.type & AnchorType.EmptyTile) == AnchorType.EmptyTile) { flag2 = true; } if (!flag2) { if (onlyCheck) { TileObject.objectPreview[num11 + X, num10 + Y] = 2; } } else { if (onlyCheck) { TileObject.objectPreview[num11 + X, num10 + Y] = 1; } ++num15; } } } AnchorData anchorRight = tileData2.AnchorRight; if (anchorRight.tileCount != 0) { num16 += (float)anchorRight.tileCount; int width = tileData2.Width; for (int index = 0; index < anchorRight.tileCount; ++index) { int num10 = anchorRight.checkStart + index; Tile tileSafely1 = Framing.GetTileSafely(num8 + width, num9 + num10); bool flag2 = false; if (tileSafely1.nactive()) { if (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type] && !Main.tileNoAttach[(int)tileSafely1.type] && (tileData2.FlattenAnchors || tileSafely1.blockType() == 0)) { flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type); } if (!flag2 && (anchorRight.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type])) { switch (tileSafely1.blockType()) { case 2: case 4: flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type); break; } } if (!flag2 && (anchorRight.type & AnchorType.Tree) == AnchorType.Tree && (int)tileSafely1.type == 5) { flag2 = true; if (index == 0) { ++num16; Tile tileSafely2 = Framing.GetTileSafely(num8 + width, num9 + num10 - 1); if (tileSafely2.nactive() && (int)tileSafely2.type == 5) { ++num15; if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y - 1] = 1; } } else if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y - 1] = 2; } } if (index == anchorRight.tileCount - 1) { ++num16; Tile tileSafely2 = Framing.GetTileSafely(num8 + width, num9 + num10 + 1); if (tileSafely2.nactive() && (int)tileSafely2.type == 5) { ++num15; if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y + 1] = 1; } } else if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y + 1] = 2; } } } if (!flag2 && (anchorRight.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely1.type)) { flag2 = true; } } else if (!flag2 && (anchorRight.type & AnchorType.EmptyTile) == AnchorType.EmptyTile) { flag2 = true; } if (!flag2) { if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y] = 2; } } else { if (onlyCheck) { TileObject.objectPreview[width + X, num10 + Y] = 1; } ++num15; } } } AnchorData anchorLeft = tileData2.AnchorLeft; if (anchorLeft.tileCount != 0) { num16 += (float)anchorLeft.tileCount; int num10 = -1; for (int index = 0; index < anchorLeft.tileCount; ++index) { int num11 = anchorLeft.checkStart + index; Tile tileSafely1 = Framing.GetTileSafely(num8 + num10, num9 + num11); bool flag2 = false; if (tileSafely1.nactive()) { if (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type] && !Main.tileNoAttach[(int)tileSafely1.type] && (tileData2.FlattenAnchors || tileSafely1.blockType() == 0)) { flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type); } if (!flag2 && (anchorLeft.type & AnchorType.SolidSide) == AnchorType.SolidSide && (Main.tileSolid[(int)tileSafely1.type] && !Main.tileSolidTop[(int)tileSafely1.type])) { switch (tileSafely1.blockType()) { case 3: case 5: flag2 = tileData2.isValidTileAnchor((int)tileSafely1.type); break; } } if (!flag2 && (anchorLeft.type & AnchorType.Tree) == AnchorType.Tree && (int)tileSafely1.type == 5) { flag2 = true; if (index == 0) { ++num16; Tile tileSafely2 = Framing.GetTileSafely(num8 + num10, num9 + num11 - 1); if (tileSafely2.nactive() && (int)tileSafely2.type == 5) { ++num15; if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y - 1] = 1; } } else if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y - 1] = 2; } } if (index == anchorLeft.tileCount - 1) { ++num16; Tile tileSafely2 = Framing.GetTileSafely(num8 + num10, num9 + num11 + 1); if (tileSafely2.nactive() && (int)tileSafely2.type == 5) { ++num15; if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y + 1] = 1; } } else if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y + 1] = 2; } } } if (!flag2 && (anchorLeft.type & AnchorType.AlternateTile) == AnchorType.AlternateTile && tileData2.isValidAlternateAnchor((int)tileSafely1.type)) { flag2 = true; } } else if (!flag2 && (anchorLeft.type & AnchorType.EmptyTile) == AnchorType.EmptyTile) { flag2 = true; } if (!flag2) { if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y] = 2; } } else { if (onlyCheck) { TileObject.objectPreview[num10 + X, num11 + Y] = 1; } ++num15; } } } if (tileData2.HookCheck.hook != null) { if (tileData2.HookCheck.processedCoordinates) { int num10 = (int)tileData2.Origin.X; int num11 = (int)tileData2.Origin.Y; } if (tileData2.HookCheck.hook(x, y, type, style, dir) == tileData2.HookCheck.badReturn && tileData2.HookCheck.badResponse == 0) { num15 = 0.0f; num13 = 0.0f; TileObject.objectPreview.AllInvalid(); } } float num17 = num15 / num16; float num18 = num13 / num14; if ((double)num17 == 1.0 && (double)num18 == 1.0) { num5 = 1f; num6 = 1f; num7 = alternate; tileObjectData = tileData2; break; } if ((double)num17 > (double)num5 || (double)num17 == (double)num5 && (double)num18 > (double)num6) { TileObjectPreviewData.placementCache.CopyFrom(TileObject.objectPreview); num5 = num17; num6 = num18; tileObjectData = tileData2; num7 = alternate; } } } int num19 = -1; if (flag1) { if (TileObjectPreviewData.randomCache == null) { TileObjectPreviewData.randomCache = new TileObjectPreviewData(); } bool flag2 = false; if ((int)TileObjectPreviewData.randomCache.Type == type) { Point16 coordinates = TileObjectPreviewData.randomCache.Coordinates; Point16 objectStart = TileObjectPreviewData.randomCache.ObjectStart; int num8 = (int)coordinates.X + (int)objectStart.X; int num9 = (int)coordinates.Y + (int)objectStart.Y; int num10 = x - (int)tileData1.Origin.X; int num11 = y - (int)tileData1.Origin.Y; if (num8 != num10 || num9 != num11) { flag2 = true; } } else { flag2 = true; } num19 = !flag2 ? TileObjectPreviewData.randomCache.Random : Main.rand.Next(tileData1.RandomStyleRange); } if (onlyCheck) { if ((double)num5 != 1.0 || (double)num6 != 1.0) { TileObject.objectPreview.CopyFrom(TileObjectPreviewData.placementCache); alternate = num7; } TileObject.objectPreview.Random = num19; if (tileData1.RandomStyleRange > 0) { TileObjectPreviewData.randomCache.CopyFrom(TileObject.objectPreview); } } if (!onlyCheck) { objectData.xCoord = x - (int)tileObjectData.Origin.X; objectData.yCoord = y - (int)tileObjectData.Origin.Y; objectData.type = type; objectData.style = style; objectData.alternate = alternate; objectData.random = num19; } if ((double)num5 == 1.0) { return((double)num6 == 1.0); } return(false); }
public override void RightClick(int i, int j) { if (Main.tile[i, j].frameX % 36 == 18) { i--; } if (Main.tile[i, j].frameY % 36 == 18) { j--; } Player player = Main.player[Main.myPlayer]; if (GetHeart(i, j) == null) { player.tileInteractionHappened = true; Main.NewText("This access is not connected to a Storage Heart!"); return; } StoragePlayer modPlayer = player.GetModPlayer <StoragePlayer>(mod); player.tileInteractionHappened = true; Main.mouseRightRelease = false; if (player.sign > -1) { Main.PlaySound(11, -1, -1, 1); player.sign = -1; Main.editSign = false; Main.npcChatText = string.Empty; } if (Main.editChest) { Main.PlaySound(12, -1, -1, 1); Main.editChest = false; Main.npcChatText = string.Empty; } if (player.editedChestName) { NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0); player.editedChestName = false; } if (player.talkNPC > -1) { player.talkNPC = -1; Main.npcChatCornerItem = 0; Main.npcChatText = string.Empty; } bool hadChestOpen = player.chest != -1; player.chest = -1; Main.stackSplit = 600; Point16 toOpen = new Point16(i, j); Point16 prevOpen = modPlayer.ViewingStorage(); if (prevOpen == toOpen) { modPlayer.CloseStorage(); Main.PlaySound(11, -1, -1, 1); Recipe.FindRecipes(); } else { bool hadOtherOpen = prevOpen.X >= 0 && prevOpen.Y >= 0; modPlayer.OpenStorage(toOpen); modPlayer.timeSinceOpen = 0; Main.playerInventory = true; if (PlayerInput.GrappleAndInteractAreShared) { PlayerInput.Triggers.JustPressed.Grapple = false; } Main.recBigList = false; Main.PlaySound(hadChestOpen || hadOtherOpen ? 12 : 10, -1, -1, 1); Recipe.FindRecipes(); } }
public bool CanOpen(Point16 toOpen) { return(InRange(PlayerPosTiles, toOpen) || remoteAccess); }
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); }
// Token: 0x0600087C RID: 2172 RVA: 0x003AD110 File Offset: 0x003AB310 public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame) { if (!centerTile.active()) { return; } ushort num = TileID.Sets.GemsparkFramingTypes[(int)centerTile.type]; Framing.BlockStyle arg_28_0 = Framing.FindBlockStyle(centerTile); int num2 = 0; Framing.BlockStyle blockStyle = default(Framing.BlockStyle); if (arg_28_0.top) { Tile tileSafely = Framing.GetTileSafely(i, j - 1); if (tileSafely.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely.type] == num) { blockStyle = Framing.FindBlockStyle(tileSafely); if (blockStyle.bottom) { num2 |= 1; } else { blockStyle.Clear(); } } } Framing.BlockStyle blockStyle2 = default(Framing.BlockStyle); if (arg_28_0.left) { Tile tileSafely2 = Framing.GetTileSafely(i - 1, j); if (tileSafely2.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely2.type] == num) { blockStyle2 = Framing.FindBlockStyle(tileSafely2); if (blockStyle2.right) { num2 |= 2; } else { blockStyle2.Clear(); } } } Framing.BlockStyle blockStyle3 = default(Framing.BlockStyle); if (arg_28_0.right) { Tile tileSafely3 = Framing.GetTileSafely(i + 1, j); if (tileSafely3.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely3.type] == num) { blockStyle3 = Framing.FindBlockStyle(tileSafely3); if (blockStyle3.left) { num2 |= 4; } else { blockStyle3.Clear(); } } } Framing.BlockStyle blockStyle4 = default(Framing.BlockStyle); if (arg_28_0.bottom) { Tile tileSafely4 = Framing.GetTileSafely(i, j + 1); if (tileSafely4.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely4.type] == num) { blockStyle4 = Framing.FindBlockStyle(tileSafely4); if (blockStyle4.top) { num2 |= 8; } else { blockStyle4.Clear(); } } } if (blockStyle.left && blockStyle2.top) { Tile tileSafely5 = Framing.GetTileSafely(i - 1, j - 1); if (tileSafely5.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely5.type] == num) { Framing.BlockStyle blockStyle5 = Framing.FindBlockStyle(tileSafely5); if (blockStyle5.right && blockStyle5.bottom) { num2 |= 16; } } } if (blockStyle.right && blockStyle3.top) { Tile tileSafely6 = Framing.GetTileSafely(i + 1, j - 1); if (tileSafely6.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely6.type] == num) { Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely6); if (blockStyle6.left && blockStyle6.bottom) { num2 |= 32; } } } if (blockStyle4.left && blockStyle2.bottom) { Tile tileSafely7 = Framing.GetTileSafely(i - 1, j + 1); if (tileSafely7.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely7.type] == num) { Framing.BlockStyle blockStyle7 = Framing.FindBlockStyle(tileSafely7); if (blockStyle7.right && blockStyle7.top) { num2 |= 64; } } } if (blockStyle4.right && blockStyle3.bottom) { Tile tileSafely8 = Framing.GetTileSafely(i + 1, j + 1); if (tileSafely8.active() && TileID.Sets.GemsparkFramingTypes[(int)tileSafely8.type] == num) { Framing.BlockStyle blockStyle8 = Framing.FindBlockStyle(tileSafely8); if (blockStyle8.left && blockStyle8.top) { num2 |= 128; } } } if (resetFrame) { centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3)); } Point16 point = Framing.selfFrame8WayLookup[num2][(int)centerTile.frameNumber()]; centerTile.frameX = point.X; centerTile.frameY = point.Y; }
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; }
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; }
public static void WallFrame(int i, int j, bool resetFrame = false) { if (i <= 0 || j <= 0 || i >= Main.maxTilesX - 1 || j >= Main.maxTilesY - 1 || Main.tile[i, j] == null) { return; } WorldGen.UpdateMapTile(i, j, true); Tile tile = Main.tile[i, j]; if (tile.wall == WallID.None) { tile.wallColor(0); return; } int num = 0; Tile tile1 = Main.tile[i, j - 1]; if (tile1 != null && (tile1.wall > 0 || tile1.active() && tile1.type == 54)) { num = 1; } tile1 = Main.tile[i - 1, j]; if (tile1 != null && (tile1.wall > 0 || tile1.active() && tile1.type == 54)) { num = num | 2; } tile1 = Main.tile[i + 1, j]; if (tile1 != null && (tile1.wall > 0 || tile1.active() && tile1.type == 54)) { num = num | 4; } tile1 = Main.tile[i, j + 1]; if (tile1 != null && (tile1.wall > 0 || tile1.active() && tile1.type == 54)) { num = num | 8; } int num1 = 0; if (Main.wallLargeFrames[tile.wall] == 1) { num1 = Framing.phlebasTileFrameNumberLookup[j % 4][i % 3] - 1; tile.wallFrameNumber((byte)num1); } else if (Main.wallLargeFrames[tile.wall] == 2) { num1 = Framing.lazureTileFrameNumberLookup[i % 2][j % 2] - 1; tile.wallFrameNumber((byte)num1); } else if (!resetFrame) { num1 = tile.wallFrameNumber(); } else { num1 = WorldGen.genRand.Next(0, 3); tile.wallFrameNumber((byte)num1); } if (num == 15) { num = num + Framing.centerWallFrameLookup[i % 3][j % 3]; } Point16 point16 = Framing.wallFrameLookup[num][num1]; tile.wallFrameX(point16.X); tile.wallFrameY(point16.Y); }
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; }
public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame) { if (!centerTile.active()) { return; } ushort num = centerTile.type; Framing.BlockStyle blockStyle = Framing.FindBlockStyle(centerTile); int num1 = 0; Framing.BlockStyle blockStyle1 = new Framing.BlockStyle(); if (blockStyle.top) { Tile tileSafely = Framing.GetTileSafely(i, j - 1); if (tileSafely.active() && tileSafely.type == num) { blockStyle1 = Framing.FindBlockStyle(tileSafely); if (!blockStyle1.bottom) { blockStyle1.Clear(); } else { num1 = num1 | 1; } } } Framing.BlockStyle blockStyle2 = new Framing.BlockStyle(); if (blockStyle.left) { Tile tile = Framing.GetTileSafely(i - 1, j); if (tile.active() && tile.type == num) { blockStyle2 = Framing.FindBlockStyle(tile); if (!blockStyle2.right) { blockStyle2.Clear(); } else { num1 = num1 | 2; } } } Framing.BlockStyle blockStyle3 = new Framing.BlockStyle(); if (blockStyle.right) { Tile tileSafely1 = Framing.GetTileSafely(i + 1, j); if (tileSafely1.active() && tileSafely1.type == num) { blockStyle3 = Framing.FindBlockStyle(tileSafely1); if (!blockStyle3.left) { blockStyle3.Clear(); } else { num1 = num1 | 4; } } } Framing.BlockStyle blockStyle4 = new Framing.BlockStyle(); if (blockStyle.bottom) { Tile tile1 = Framing.GetTileSafely(i, j + 1); if (tile1.active() && tile1.type == num) { blockStyle4 = Framing.FindBlockStyle(tile1); if (!blockStyle4.top) { blockStyle4.Clear(); } else { num1 = num1 | 8; } } } if (blockStyle1.left && blockStyle2.top) { Tile tileSafely2 = Framing.GetTileSafely(i - 1, j - 1); if (tileSafely2.active() && tileSafely2.type == num) { Framing.BlockStyle blockStyle5 = Framing.FindBlockStyle(tileSafely2); if (blockStyle5.right && blockStyle5.bottom) { num1 = num1 | 16; } } } if (blockStyle1.right && blockStyle3.top) { Tile tile2 = Framing.GetTileSafely(i + 1, j - 1); if (tile2.active() && tile2.type == num) { Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tile2); if (blockStyle6.left && blockStyle6.bottom) { num1 = num1 | 32; } } } if (blockStyle4.left && blockStyle2.bottom) { Tile tileSafely3 = Framing.GetTileSafely(i - 1, j + 1); if (tileSafely3.active() && tileSafely3.type == num) { Framing.BlockStyle blockStyle7 = Framing.FindBlockStyle(tileSafely3); if (blockStyle7.right && blockStyle7.top) { num1 = num1 | 64; } } } if (blockStyle4.right && blockStyle3.bottom) { Tile tile3 = Framing.GetTileSafely(i + 1, j + 1); if (tile3.active() && tile3.type == num) { Framing.BlockStyle blockStyle8 = Framing.FindBlockStyle(tile3); if (blockStyle8.left && blockStyle8.top) { num1 = num1 | 128; } } } if (resetFrame) { centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3)); } Point16 point16 = Framing.selfFrame8WayLookup[num1][centerTile.frameNumber()]; centerTile.frameX = point16.X; centerTile.frameY = point16.Y; }
public static void SelfFrame8Way(int i, int j, Tile centerTile, bool resetFrame) { if (!centerTile.active()) { return; } ushort type = centerTile.type; Framing.BlockStyle blockStyle = Framing.FindBlockStyle(centerTile); int num = 0; Framing.BlockStyle blockStyle2 = default(Framing.BlockStyle); if (blockStyle.top) { Tile tileSafely = Framing.GetTileSafely(i, j - 1); if (tileSafely.active() && tileSafely.type == type) { blockStyle2 = Framing.FindBlockStyle(tileSafely); if (blockStyle2.bottom) { num |= 1; } else { blockStyle2.Clear(); } } } Framing.BlockStyle blockStyle3 = default(Framing.BlockStyle); if (blockStyle.left) { Tile tileSafely2 = Framing.GetTileSafely(i - 1, j); if (tileSafely2.active() && tileSafely2.type == type) { blockStyle3 = Framing.FindBlockStyle(tileSafely2); if (blockStyle3.right) { num |= 2; } else { blockStyle3.Clear(); } } } Framing.BlockStyle blockStyle4 = default(Framing.BlockStyle); if (blockStyle.right) { Tile tileSafely3 = Framing.GetTileSafely(i + 1, j); if (tileSafely3.active() && tileSafely3.type == type) { blockStyle4 = Framing.FindBlockStyle(tileSafely3); if (blockStyle4.left) { num |= 4; } else { blockStyle4.Clear(); } } } Framing.BlockStyle blockStyle5 = default(Framing.BlockStyle); if (blockStyle.bottom) { Tile tileSafely4 = Framing.GetTileSafely(i, j + 1); if (tileSafely4.active() && tileSafely4.type == type) { blockStyle5 = Framing.FindBlockStyle(tileSafely4); if (blockStyle5.top) { num |= 8; } else { blockStyle5.Clear(); } } } if (blockStyle2.left && blockStyle3.top) { Tile tileSafely5 = Framing.GetTileSafely(i - 1, j - 1); if (tileSafely5.active() && tileSafely5.type == type) { Framing.BlockStyle blockStyle6 = Framing.FindBlockStyle(tileSafely5); if (blockStyle6.right && blockStyle6.bottom) { num |= 16; } } } if (blockStyle2.right && blockStyle4.top) { Tile tileSafely6 = Framing.GetTileSafely(i + 1, j - 1); if (tileSafely6.active() && tileSafely6.type == type) { Framing.BlockStyle blockStyle7 = Framing.FindBlockStyle(tileSafely6); if (blockStyle7.left && blockStyle7.bottom) { num |= 32; } } } if (blockStyle5.left && blockStyle3.bottom) { Tile tileSafely7 = Framing.GetTileSafely(i - 1, j + 1); if (tileSafely7.active() && tileSafely7.type == type) { Framing.BlockStyle blockStyle8 = Framing.FindBlockStyle(tileSafely7); if (blockStyle8.right && blockStyle8.top) { num |= 64; } } } if (blockStyle5.right && blockStyle4.bottom) { Tile tileSafely8 = Framing.GetTileSafely(i + 1, j + 1); if (tileSafely8.active() && tileSafely8.type == type) { Framing.BlockStyle blockStyle9 = Framing.FindBlockStyle(tileSafely8); if (blockStyle9.left && blockStyle9.top) { num |= 128; } } } if (resetFrame) { centerTile.frameNumber((byte)WorldGen.genRand.Next(0, 3)); } Point16 point = Framing.selfFrame8WayLookup[num][(int)centerTile.frameNumber()]; centerTile.frameX = point.x; centerTile.frameY = point.y; }
// Token: 0x0600087D RID: 2173 RVA: 0x003AD438 File Offset: 0x003AB638 public static void WallFrame(int i, int j, bool resetFrame = false) { if (i <= 0 || j <= 0 || i >= Main.maxTilesX - 1 || j >= Main.maxTilesY - 1 || Main.tile[i, j] == null) { return; } WorldGen.UpdateMapTile(i, j, true); Tile tile = Main.tile[i, j]; if (tile.wall == 0) { tile.wallColor(0); return; } int num = 0; Tile tile2 = Main.tile[i, j - 1]; if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54))) { num = 1; } tile2 = Main.tile[i - 1, j]; if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54))) { num |= 2; } tile2 = Main.tile[i + 1, j]; if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54))) { num |= 4; } tile2 = Main.tile[i, j + 1]; if (tile2 != null && (tile2.wall > 0 || (tile2.active() && tile2.type == 54))) { num |= 8; } int num2; if (Main.wallLargeFrames[(int)tile.wall] == 1) { num2 = Framing.phlebasTileFrameNumberLookup[j % 4][i % 3] - 1; tile.wallFrameNumber((byte)num2); } else if (Main.wallLargeFrames[(int)tile.wall] == 2) { num2 = Framing.lazureTileFrameNumberLookup[i % 2][j % 2] - 1; tile.wallFrameNumber((byte)num2); } else if (resetFrame) { num2 = WorldGen.genRand.Next(0, 3); tile.wallFrameNumber((byte)num2); } else { num2 = (int)tile.wallFrameNumber(); } if (num == 15) { num += Framing.centerWallFrameLookup[i % 3][j % 3]; } Point16 point = Framing.wallFrameLookup[num][num2]; tile.wallFrameX((int)point.X); tile.wallFrameY((int)point.Y); }
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[6]; Framing.blockStyleLookup[0] = new Framing.BlockStyle(true, true, true, true); Framing.blockStyleLookup[1] = new Framing.BlockStyle(false, true, true, true); Framing.blockStyleLookup[2] = new Framing.BlockStyle(false, true, true, false); Framing.blockStyleLookup[3] = new Framing.BlockStyle(false, true, false, true); Framing.blockStyleLookup[4] = new Framing.BlockStyle(true, false, true, false); Framing.blockStyleLookup[5] = new Framing.BlockStyle(true, false, false, true); Framing.largeTileFrameNumberLookup = new int[][] { new int[] { 2, 4, 2 }, new int[] { 1, 3, 1 }, new int[] { 2, 2, 4 }, new int[] { 1, 1, 3 } }; int[][] array = new int[3][]; int[][] arg_36F_0 = array; int arg_36F_1 = 0; int[] array2 = new int[3]; array2[0] = 2; arg_36F_0[arg_36F_1] = array2; array[1] = new int[] { 0, 1, 4 }; int[][] arg_394_0 = array; int arg_394_1 = 2; int[] array3 = new int[3]; array3[1] = 3; arg_394_0[arg_394_1] = array3; Framing.centerWallFrameLookup = array; 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, 0, 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); }
// Token: 0x06000880 RID: 2176 RVA: 0x003AD648 File Offset: 0x003AB848 public static Tile GetTileSafely(Point16 pt) { return(Framing.GetTileSafely((int)pt.X, (int)pt.Y)); }
/// <summary> /// Is the <see cref="Point16"/> made of non-negative elements /// </summary> public static bool N0(this Point16 point) => point.X >= 0 && point.Y >= 0;
private static void ReceiveSearchAndRefresh(BinaryReader reader) { Point16 point = new Point16(reader.ReadInt16(), reader.ReadInt16()); TEStorageComponent.SearchAndRefreshNetwork(point); }
internal static void UpdatePingDespawn() { List <Ping> toRemove = new List <Ping>(); List <Ping> toRemoveAndSync = new List <Ping>(); foreach (var ping in Pings) { bool decayed = ping.DoDecay(); if (decayed) { toRemove.Add(ping); continue; } bool remove = false; bool removeAndSync = false; switch (ping.PingType) { //Tiles might be problematic to check in MP like that because they can be null or not active //Here check that they can only be despawned if not null, and not active (Framing.GetTileSafely always returns not null so its not applicable) case PingType.SingleTile: case PingType.MultiTile: Tile tile = Main.tile[ping.TileLocation.X, ping.TileLocation.Y]; remove = tile != null && !tile.active(); break; case PingType.ClusterTile: if (Main.netMode != NetmodeID.MultiplayerClient) { //Only server knows all tile locations so it can decide about its state properly Point16 topLeft = ping.TileLocation; Point16 size = ping.TileSize; int totalCount = ping.TileCount; int threshold = (int)(totalCount * 0.5f); int leftCount = 0; bool b = false; for (int i = topLeft.X; i < topLeft.X + size.X; i++) { if (b) { break; } for (int j = topLeft.Y; j < topLeft.Y + size.Y; j++) { if (b) { break; } if (!WorldGen.InWorld(i, j)) { continue; } Tile checkTile = Framing.GetTileSafely(i, j); if (checkTile.active() && checkTile.type == ping.Type) { leftCount++; if (leftCount >= threshold) { //No point checking further b = true; } } } } if (b) { break; } //If not breaked, remove removeAndSync = true; } break; case PingType.SelfPlayer: remove = !Main.player[ping.WhoAmI].active; break; case PingType.NPC: remove = !Main.npc[ping.WhoAmI].active || Main.npc[ping.WhoAmI].type != ping.Type; break; case PingType.Item: remove = !Main.item[ping.WhoAmI].active || Main.item[ping.WhoAmI].type != ping.Type; break; default: break; } if (remove) { toRemove.Add(ping); } if (removeAndSync) { toRemoveAndSync.Add(ping); } } foreach (var ping in toRemove) { Pings.Remove(ping); } if (Main.netMode != NetmodeID.MultiplayerClient) { foreach (var ping in toRemoveAndSync) { new PingPacket(ping).Send(); Pings.Remove(ping); } } }
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { //Essentially a copy of ItemPumpTile, but for fluids Point16 pos = new Point16(i, j); NetworkCollection.HasFluidPipeAt(pos, out FluidNetwork net); //Uh oh if (net is null || !net.pumpTimers.TryGetValue(pos, out Timer pumpTimer)) { return; } int timer = pumpTimer.value; /* Graph: Cosine Sine * _|_ | ___ * .' | `. '. | .' `. * _______/___|___\_______ __\_________|/_______\___ * / | \ \ /| \ * '-__-' | '-__-' '-___-' | '- */ const float max = 34f; //Get the value on the graph for this sinusoidal movement float time = (timer - max / 4) / (max / 2); float radians = MathHelper.Pi * time; float sin = (float)Math.Sin(radians); //Move it up to above the X-axis sin += 1; //Then stretch it to fit the entire movement of the pump sin *= 8f / 2f; //Find the direction the offset needs to sway in Vector2 dir; int tileFrame = Framing.GetTileSafely(i, j).frameX / 18; switch (tileFrame) { case 0: dir = new Vector2(0, -1); break; case 1: dir = new Vector2(-1, 0); break; case 2: dir = new Vector2(0, 1); break; case 3: dir = new Vector2(1, 0); break; default: throw new Exception($"Inner TerraScience error -- Unexpected pump tile frame (ID: {tileFrame})"); } Texture2D tileTexture = Main.tileTexture[Type]; Texture2D texture = ModContent.GetTexture("TerraScience/Content/Tiles/Effect_FluidPumpTile_bar"); Rectangle tileSource = tileTexture.Frame(4, 1, tileFrame, 0); Rectangle frame = texture.Frame(4, 1, tileFrame, 0); frame.Width -= 2; frame.Height -= 2; Vector2 offset = MiscUtils.GetLightingDrawOffset(); Vector2 tilePos = pos.ToVector2() * 16 - Main.screenPosition + offset; Vector2 drawPos = tilePos + dir * sin; var color = Lighting.GetColor(i, j); spriteBatch.Draw(tileTexture, tilePos, tileSource, color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); spriteBatch.Draw(texture, drawPos, frame, color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); }
public override bool HandleMouse(Point16 pos) => TileUtils.HandleMouse <ScienceWorkbenchEntity>(this, pos, () => true);
public TileNode(Point16 position) => this.position = position;
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 override void NetRecieve(BinaryReader reader) { location = new Point16(reader.ReadInt16(), reader.ReadInt16()); }
public static void QuickSetFurniture(this ModTile tile, int width, int height, int dustType, int soundType, bool tallBottom, Color mapColor, bool solidTop = false, bool solid = false, string mapName = "", AnchorData bottomAnchor = default, AnchorData topAnchor = default, int[] anchorTiles = null, Point16 Origin = default) { Main.tileLavaDeath[tile.Type] = false; Main.tileFrameImportant[tile.Type] = true; Main.tileSolidTop[tile.Type] = solidTop; Main.tileSolid[tile.Type] = solid; TileObjectData.newTile.Width = width; TileObjectData.newTile.Height = height; TileObjectData.newTile.CoordinateHeights = new int[height]; for (int k = 0; k < height; k++) { TileObjectData.newTile.CoordinateHeights[k] = 16; } if (tallBottom) //this breaks for some tiles: the two leads are multitiles and tiles with random styles { TileObjectData.newTile.CoordinateHeights[height - 1] = 18; } TileObjectData.newTile.UsesCustomCanPlace = true; TileObjectData.newTile.CoordinateWidth = 16; TileObjectData.newTile.CoordinatePadding = 2; TileObjectData.newTile.Origin = Origin == default(Point16) ? new Point16(width / 2, height - 1) : Origin; if (bottomAnchor != default) { TileObjectData.newTile.AnchorBottom = bottomAnchor; } /*else * TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);*/ if (topAnchor != default) { TileObjectData.newTile.AnchorTop = topAnchor; } if (anchorTiles != null) { TileObjectData.newTile.AnchorAlternateTiles = anchorTiles; } TileObjectData.addTile(tile.Type); ModTranslation name = tile.CreateMapEntryName(); name.SetDefault(mapName); tile.AddMapEntry(mapColor, name); tile.dustType = dustType; tile.soundType = soundType; tile.disableSmartCursor = true; }
public override void Load(TagCompound tag) { location = new Point16(tag.GetShort("X"), tag.GetShort("Y")); }
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { tilePoint = new Point16(i - 4, j - 4); // it finds the bottom right while we want top left }
public override bool CanUseItem(Player player) { var tileClicked = new Point16(Player.tileTargetX, Player.tileTargetY); return(WirelessUtils.DoesPlayerReach(player) && (WirelessUtils.IsTransmitter(tileClicked) || WirelessUtils.IsReceiver(tileClicked))); }