public override bool?UseItem(Player player) { var tileClicked = new Point16(Player.tileTargetX, Player.tileTargetY); if (Main.tile[Player.tileTargetX, Player.tileTargetY].TileType == ModContent.TileType <Tiles.WirelessTransceiver>()) { if (tileClicked == Coordinates) { Main.NewText(Language.GetTextValue("Mods.Wireless.LinkToItself"), Color.Red); return(true); } } bool successLink = false; if (WirelessUtils.IsTransmitter(tileClicked) && WirelessUtils.IsReceiver(Coordinates)) { ModContent.GetInstance <Wireless>().SyncAddLink(tileClicked, Coordinates); successLink = true; } if (WirelessUtils.IsTransmitter(Coordinates) && WirelessUtils.IsReceiver(tileClicked)) { ModContent.GetInstance <Wireless>().SyncAddLink(Coordinates, tileClicked); successLink = true; } if (successLink) { Coordinates = Point16.NegativeOne; Main.NewText(Language.GetTextValue("Mods.Wireless.SuccessLink"), Colors.RarityLime); } else { Coordinates = tileClicked; Main.NewText(Language.GetTextValue("Mods.Wireless.StartLink"), Colors.RarityYellow); } return(true); }
public override bool CanUseItem(Player player) { var tileClicked = new Point16(Player.tileTargetX, Player.tileTargetY); return(WirelessUtils.DoesPlayerReach(player) && (WirelessUtils.IsTransmitter(tileClicked) || WirelessUtils.IsReceiver(tileClicked))); }