public static int Place(int x, int y) { TETeleportationPylon tETeleportationPylon = new TETeleportationPylon(); tETeleportationPylon.Position = new Point16(x, y); tETeleportationPylon.ID = TileEntity.AssignNewID(); tETeleportationPylon.type = _myEntityID; TileEntity.ByID[tETeleportationPylon.ID] = tETeleportationPylon; TileEntity.ByPosition[tETeleportationPylon.Position] = tETeleportationPylon; Main.PylonSystem.RequestImmediateUpdate(); return(tETeleportationPylon.ID); }
public static int PlacementPreviewHook_CheckIfCanPlace( int x, int y, int type = 597, int style = 0, int direction = 1, int alternate = 0) { TeleportPylonType fromPylonTileStyle = TETeleportationPylon.GetPylonTypeFromPylonTileStyle(style); return(Main.PylonSystem.HasPylonOfType(fromPylonTileStyle) ? 1 : 0); }
public static void Framing_CheckTile(int callX, int callY) { if (WorldGen.destroyObject) { return; } int num1 = callX; int num2 = callY; Tile tileSafely = Framing.GetTileSafely(callX, callY); int num3 = num1 - (int)tileSafely.frameX / 18 % 3; int y = num2 - (int)tileSafely.frameY / 18 % 4; int pylonStyleFromTile = TETeleportationPylon.GetPylonStyleFromTile(tileSafely); bool flag = false; for (int index1 = num3; index1 < num3 + 3; ++index1) { for (int index2 = y; index2 < y + 4; ++index2) { Tile tile = Main.tile[index1, index2]; if (!tile.active() || tile.type != (ushort)597) { flag = true; } } } if (!WorldGen.SolidTileAllowBottomSlope(num3, y + 4) || !WorldGen.SolidTileAllowBottomSlope(num3 + 1, y + 4) || !WorldGen.SolidTileAllowBottomSlope(num3 + 2, y + 4)) { flag = true; } if (!flag) { return; } TETeleportationPylon.Kill(num3, y); int typeFromTileStyle = TETeleportationPylon.GetPylonItemTypeFromTileStyle(pylonStyleFromTile); Item.NewItem(num3 * 16, y * 16, 48, 64, typeFromTileStyle, 1, false, 0, false, false); WorldGen.destroyObject = true; for (int i = num3; i < num3 + 3; ++i) { for (int j = y; j < y + 4; ++j) { if (Main.tile[i, j].active() && Main.tile[i, j].type == (ushort)597) { WorldGen.KillTile(i, j, false, false, false); } } } WorldGen.destroyObject = false; }
private bool TryGetPylonTypeFromTileCoords(int x, int y, out TeleportPylonType pylonType) { pylonType = TeleportPylonType.SurfacePurity; Tile tile = Main.tile[x, y]; if (tile == null || !tile.active() || tile.type != (ushort)597) { return(false); } int pylonStyle = (int)tile.frameX / 54; pylonType = TETeleportationPylon.GetPylonTypeFromPylonTileStyle(pylonStyle); return(true); }
public static int PlacementPreviewHook_AfterPlacement( int x, int y, int type = 597, int style = 0, int direction = 1, int alternate = 0) { if (Main.netMode != 1) { return(TETeleportationPylon.Place(x - 1, y - 3)); } NetMessage.SendTileSquare(Main.myPlayer, x, y - 1, 5, TileChangeType.None); NetMessage.SendData(87, -1, -1, (NetworkText)null, x - 1, (float)(y - 3), (float)TETeleportationPylon._myEntityID, 0.0f, 0, 0, 0); return(-1); }
public override void NetPlaceEntityAttempt(int x, int y) { TeleportPylonType pylonType; if (!this.TryGetPylonTypeFromTileCoords(x, y, out pylonType)) { TETeleportationPylon.RejectPlacementFromNet(x, y); } else if (Main.PylonSystem.HasPylonOfType(pylonType)) { TETeleportationPylon.RejectPlacementFromNet(x, y); } else { NetMessage.SendData(86, -1, -1, (NetworkText)null, TETeleportationPylon.Place(x, y), (float)x, (float)y, 0.0f, 0, 0, 0); } }