// Token: 0x060012D4 RID: 4820 RVA: 0x004195E0 File Offset: 0x004177E0 public static TileEntity Read(BinaryReader reader, bool networkSend = false) { TileEntity tileEntity = null; byte b = reader.ReadByte(); switch (b) { case 0: tileEntity = new TETrainingDummy(); break; case 1: tileEntity = new TEItemFrame(); break; case 2: tileEntity = new TELogicSensor(); break; } tileEntity.type = b; tileEntity.ReadInner(reader, networkSend); return(tileEntity); }
public static void ClearObjects(int x, int y, int x2, int y2) { ClearSigns(x, y, x2, y2, false); ClearChests(x, y, x2, y2, false); for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if (TEItemFrame.Find(i, j) != -1) { TEItemFrame.Kill(i, j); } if (TELogicSensor.Find(i, j) != -1) { TELogicSensor.Kill(i, j); } if (TETrainingDummy.Find(i, j) != -1) { TETrainingDummy.Kill(i, j); } } } }
public static void InitializeAll() { TETrainingDummy.Initialize(); TEItemFrame.Initialize(); TELogicSensor.Initialize(); }
public override void Execute() { if (!CanUseCommand()) { return; } Tools.PrepareUndo(x, y, x2, y2, plr); int noMsg = 0; #region Signs if ((_action == 255) || (_action == 0)) { int success = 0, failure = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if ((Main.tile[i, j].type == TileID.Signs || Main.tile[i, j].type == TileID.Tombstones || Main.tile[i, j].type == TileID.AnnouncementBox) && Main.tile[i, j].frameX % 36 == 0 && Main.tile[i, j].frameY == 0 && Sign.ReadSign(i, j, false) == -1) { int sign = Sign.ReadSign(i, j); if (sign == -1) { failure++; } else { success++; } } } } if (success > 0 || failure > 0) { plr.SendSuccessMessage("Activated signs. ({0}){1}", success, failure > 0 ? " Failed to activate signs. (" + failure + ")" : ""); } else { noMsg++; } } #endregion #region Chests if ((_action == 255) || (_action == 1)) { int success = 0, failure = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if ((Main.tile[i, j].type == TileID.Containers || Main.tile[i, j].type == TileID.Containers2 || Main.tile[i, j].type == TileID.Dressers) && Main.tile[i, j].frameX % 36 == 0 && Main.tile[i, j].frameY == 0 && Chest.FindChest(i, j) == -1) { int chest = Chest.CreateChest(i, j); if (chest == -1) { failure++; } else { success++; } } } } if (success > 0 || failure > 0) { plr.SendSuccessMessage("Activated chests. ({0}){1}", success, failure > 0 ? " Failed to activate chests. (" + failure + ")" : ""); } else { noMsg++; } } #endregion #region ItemFrames if ((_action == 255) || (_action == 2)) { int success = 0, failure = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if (Main.tile[i, j].type == TileID.ItemFrame && Main.tile[i, j].frameX % 36 == 0 && Main.tile[i, j].frameY == 0 && TEItemFrame.Find(i, j) == -1) { int frame = TEItemFrame.Place(i, j); if (frame == -1) { failure++; } else { success++; } } } } if (success > 0 || failure > 0) { plr.SendSuccessMessage("Activated item frames. ({0}){1}", success, failure > 0 ? " Failed to activate item frames. (" + failure + ")" : ""); } else { noMsg++; } } #endregion #region LogicSensors if ((_action == 255) || (_action == 3)) { int success = 0, failure = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if (Main.tile[i, j].type == TileID.LogicSensor && TELogicSensor.Find(i, j) == -1) { int sensor = TELogicSensor.Place(i, j); if (sensor == -1) { failure++; } else { ((TELogicSensor)TELogicSensor.ByID[sensor]).logicCheck = (TELogicSensor.LogicCheckType)((Main.tile[i, j].frameY / 18) + 1); success++; } } } } if (success > 0 || failure > 0) { plr.SendSuccessMessage("Activated logic sensors. ({0}){1}", success, failure > 0 ? " Failed to activate logic sensors. (" + failure + ")" : ""); } else { noMsg++; } } #endregion #region TargetDummies if ((_action == 255) || (_action == 4)) { int success = 0, failure = 0; for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { if (Main.tile[i, j].type == TileID.TargetDummy && Main.tile[i, j].frameX % 36 == 0 && Main.tile[i, j].frameY == 0 && TETrainingDummy.Find(i, j) == -1) { int dummy = TETrainingDummy.Place(i, j); if (dummy == -1) { failure++; } else { success++; } } } } if (success > 0 || failure > 0) { plr.SendSuccessMessage("Activated target dummies. ({0}){1}", success, failure > 0 ? " Failed to activate target dummies. (" + failure + ")" : ""); } else { noMsg++; } } #endregion if (noMsg == 5) { plr.SendSuccessMessage("There are no objects to activate in this area."); } ResetSection(); }
public override void Execute() { if (!CanUseCommand()) { return; } Tools.PrepareUndo(x, y, x2, y2, plr); int signs = 0, frames = 0, chests = 0, sensors = 0, dummies = 0; foreach (Sign sign in Main.sign) { if (sign == null) { continue; } ushort type = Main.tile[sign.x, sign.y].type; if (!Main.tile[sign.x, sign.y].active() || ((type != TileID.Signs) && (type != TileID.Tombstones) && (type != TileID.AnnouncementBox))) { Sign.KillSign(sign.x, sign.y); signs++; } } for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { int ID = TEItemFrame.Find(i, j); if (ID == -1) { continue; } if (!Main.tile[i, j].active() || (Main.tile[i, j].type != TileID.ItemFrame)) { TEItemFrame.Kill(i, j); frames++; } } } foreach (Chest chest in Main.chest) { if (chest == null) { continue; } ushort type = Main.tile[chest.x, chest.y].type; if (!Main.tile[chest.x, chest.y].active() || ((type != TileID.Containers) && (type != TileID.Containers2) && (type != TileID.Dressers))) { Chest.DestroyChest(chest.x, chest.y); chests++; } } for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { int ID = TELogicSensor.Find(i, j); if (ID == -1) { continue; } if (!Main.tile[i, j].active() || (Main.tile[i, j].type != TileID.LogicSensor)) { TELogicSensor.Kill(i, j); sensors++; } } } for (int i = x; i <= x2; i++) { for (int j = y; j <= y2; j++) { int ID = TETrainingDummy.Find(i, j); if (ID == -1) { continue; } if (!Main.tile[i, j].active() || (Main.tile[i, j].type != TileID.TargetDummy)) { TETrainingDummy.Kill(i, j); dummies++; } } } ResetSection(); List <string> ghosts = new List <string>(); if (signs > 0) { ghosts.Add($"signs ({signs})"); } if (frames > 0) { ghosts.Add($"item frames ({frames})"); } if (chests > 0) { ghosts.Add($"chests ({chests})"); } if (sensors > 0) { ghosts.Add($"logic sensors ({sensors})"); } if (dummies > 0) { ghosts.Add($"target dummies ({dummies})"); } if (ghosts.Count > 0) { plr.SendSuccessMessage($"Fixed ghost {string.Join(", ", ghosts)}."); } else { plr.SendSuccessMessage("There are no ghost objects in this area."); } }
public void ProcessTile(ITile tile, int x, int y) { Tiles[x, y] = new Tile(); if (tile != null) { Tiles[x, y].CopyFrom(tile); } if (!tile.active()) { return; } var actualX = x + X; var actualY = y + Y; switch (tile.type) { case TileID.Signs: case TileID.AnnouncementBox: case TileID.Tombstones: if (tile.frameX % 36 == 0 && tile.frameY == 0) { var id = Sign.ReadSign(actualX, actualY, false); if (id != -1) { Signs.Add(new SignData { Text = Main.sign[id].text, X = x, Y = y }); } } break; case TileID.ItemFrame: if (tile.frameX % 36 == 0 && tile.frameY == 0) { var id = TEItemFrame.Find(actualX, actualY); if (id != -1) { var frame = (TEItemFrame)TileEntity.ByID[id]; ItemFrames.Add(new ItemFrameData { Item = new NetItem(frame.item.netID, frame.item.stack, frame.item.prefix), X = x, Y = y }); } } break; case TileID.Containers: case TileID.Dressers: if (tile.frameX % 36 == 0 && tile.frameY == 0) { var id = Chest.FindChest(actualX, actualY); if (id != -1) { var chest = Main.chest[id]; if (chest.item != null) { var items = chest.item.Select(item => new NetItem(item.netID, item.stack, item.prefix)).ToArray(); Chests.Add(new ChestData { Items = items, X = x, Y = y }); } } } break; case TileID.LogicSensor: { var id = TELogicSensor.Find(actualX, actualY); if (id != -1) { var sensor = (TELogicSensor)TileEntity.ByID[id]; LogicSensors.Add(new LogicSensorData { X = x, Y = y, Type = sensor.logicCheck }); } break; } case TileID.TargetDummy: if (tile.frameX % 36 == 0 && tile.frameY == 0) { var id = TETrainingDummy.Find(actualX, actualY); if (id != -1) { TrainingDummies.Add(new TrainingDummyData() { X = x, Y = y }); } } break; } }
public static void LoadWorldSection(WorldSectionData Data, int?X = null, int?Y = null, bool Tiles = true) { int x = (X ?? Data.X), y = (Y ?? Data.Y); if (Tiles) { for (var i = 0; i < Data.Width; i++) { for (var j = 0; j < Data.Height; j++) { int _x = i + x, _y = j + y; if (!InMapBoundaries(_x, _y)) { continue; } Main.tile[_x, _y] = Data.Tiles[i, j]; Main.tile[_x, _y].skipLiquid(true); } } } ClearObjects(x, y, x + Data.Width, y + Data.Height); foreach (var sign in Data.Signs) { var id = Sign.ReadSign(sign.X + x, sign.Y + y); if ((id == -1) || !InMapBoundaries(sign.X, sign.Y)) { continue; } Sign.TextSign(id, sign.Text); } foreach (var itemFrame in Data.ItemFrames) { var id = TEItemFrame.Place(itemFrame.X + x, itemFrame.Y + y); if (id == -1) { continue; } var frame = (TEItemFrame)TileEntity.ByID[id]; if (!InMapBoundaries(frame.Position.X, frame.Position.Y)) { continue; } frame.item = new Item(); frame.item.netDefaults(itemFrame.Item.NetId); frame.item.stack = itemFrame.Item.Stack; frame.item.prefix = itemFrame.Item.PrefixId; } foreach (var chest in Data.Chests) { int chestX = chest.X + x, chestY = chest.Y + y; int id; if ((id = Chest.FindChest(chestX, chestY)) == -1 && (id = Chest.CreateChest(chestX, chestY)) == -1) { continue; } Chest _chest = Main.chest[id]; if (!InMapBoundaries(chest.X, chest.Y)) { continue; } for (var index = 0; index < chest.Items.Length; index++) { var netItem = chest.Items[index]; var item = new Item(); item.netDefaults(netItem.NetId); item.stack = netItem.Stack; item.prefix = netItem.PrefixId; Main.chest[id].item[index] = item; } } foreach (var logicSensor in Data.LogicSensors) { var id = TELogicSensor.Place(logicSensor.X + x, logicSensor.Y + y); if (id == -1) { continue; } var sensor = (TELogicSensor)TileEntity.ByID[id]; if (!InMapBoundaries(sensor.Position.X, sensor.Position.Y)) { continue; } sensor.logicCheck = logicSensor.Type; } foreach (var trainingDummy in Data.TrainingDummies) { var id = TETrainingDummy.Place(trainingDummy.X + x, trainingDummy.Y + y); if (id == -1) { continue; } var dummy = (TETrainingDummy)TileEntity.ByID[id]; if (!InMapBoundaries(dummy.Position.X, dummy.Position.Y)) { continue; } dummy.npc = -1; } ResetSection(x, y, x + Data.Width, y + Data.Height); }