public override void Update() { TEStorageHeart heart = GetHeart(); if (heart != null && !heart.remoteAccesses.Contains(Position)) { heart.remoteAccesses.Add(Position); } }
public void ResetAndSearch() { List <Point16> oldStorageUnits = new List <Point16>(storageUnits); storageUnits.Clear(); HashSet <Point16> hashStorageUnits = new HashSet <Point16>(); HashSet <Point16> explored = new HashSet <Point16>(); explored.Add(Position); Queue <Point16> toExplore = new Queue <Point16>(); foreach (Point16 point in AdjacentComponents()) { toExplore.Enqueue(point); } bool changed = false; while (toExplore.Count > 0) { Point16 explore = toExplore.Dequeue(); if (!explored.Contains(explore) && explore != StorageComponent.killTile) { explored.Add(explore); if (TileEntity.ByPosition.ContainsKey(explore) && TileEntity.ByPosition[explore] is TEAbstractStorageUnit) { TEAbstractStorageUnit storageUnit = (TEAbstractStorageUnit)TileEntity.ByPosition[explore]; if (storageUnit.Link(Position)) { NetHelper.SendTEUpdate(storageUnit.ID, storageUnit.Position); changed = true; } storageUnits.Add(explore); hashStorageUnits.Add(explore); } foreach (Point16 point in AdjacentComponents(explore)) { toExplore.Enqueue(point); } } } foreach (Point16 oldStorageUnit in oldStorageUnits) { if (!hashStorageUnits.Contains(oldStorageUnit)) { if (TileEntity.ByPosition.ContainsKey(oldStorageUnit) && TileEntity.ByPosition[oldStorageUnit] is TEAbstractStorageUnit) { TileEntity storageUnit = TileEntity.ByPosition[oldStorageUnit]; ((TEAbstractStorageUnit)storageUnit).Unlink(); NetHelper.SendTEUpdate(storageUnit.ID, storageUnit.Position); } changed = true; } } if (changed) { TEStorageHeart heart = GetHeart(); if (heart != null) { heart.ResetCompactStage(); } NetHelper.SendTEUpdate(ID, Position); } }
private bool TryUpgrade(int i, int j) { Player player = Main.player[Main.myPlayer]; Item item = player.inventory[player.selectedItem]; int style = Main.tile[i, j].frameY / 36; bool success = false; if (style == 0 && item.type == mod.ItemType("UpgradeDemonite")) { SetStyle(i, j, 1); success = true; } else if (style == 0 && item.type == mod.ItemType("UpgradeCrimtane")) { SetStyle(i, j, 2); success = true; } else if ((style == 1 || style == 2) && item.type == mod.ItemType("UpgradeHellstone")) { SetStyle(i, j, 3); success = true; } else if (style == 3 && item.type == mod.ItemType("UpgradeHallowed")) { SetStyle(i, j, 4); success = true; } else if (style == 4 && item.type == mod.ItemType("UpgradeBlueChlorophyte")) { SetStyle(i, j, 5); success = true; } else if (style == 5 && item.type == mod.ItemType("UpgradeLuminite")) { SetStyle(i, j, 6); success = true; } else if (style == 6 && item.type == mod.ItemType("UpgradeTerra")) { SetStyle(i, j, 7); success = true; } if (success) { TEStorageUnit storageUnit = (TEStorageUnit)TileEntity.ByPosition[new Point16(i, j)]; storageUnit.UpdateTileFrame(); NetMessage.SendTileRange(Main.myPlayer, i, j, 2, 2); TEStorageHeart heart = storageUnit.GetHeart(); if (heart != null) { if (Main.netMode == 0) { heart.ResetCompactStage(); } else if (Main.netMode == 1) { NetHelper.SendResetCompactStage(heart.ID); } } item.stack--; if (item.stack <= 0) { item.SetDefaults(0); } if (player.selectedItem == 58) { Main.mouseItem = item.Clone(); } } return(success); }