public override bool CanUseItem(Player player) { if (WirelessUtils.DoesPlayerReach(player) && WirelessUtils.IsReceiver(new Point16(Player.tileTargetX, Player.tileTargetY))) { Item.UseSound = SoundID.Item1; Item.useStyle = ItemUseStyleID.Swing; return(true); } if (Coordinates != Point16.NegativeOne) { Item.UseSound = SoundID.Mech; Item.useStyle = ItemUseStyleID.HoldUp; return(true); } return(false); }
public override bool?UseItem(Player player) { var tileClicked = new Point16(Player.tileTargetX, Player.tileTargetY); if (WirelessUtils.IsReceiver(tileClicked)) { Coordinates = tileClicked; Main.NewText(Language.GetTextValue("Mods.Wireless.SuccessLink"), Colors.RarityLime); return(true); } if (WirelessUtils.IsReceiver(Coordinates)) { ModContent.GetInstance <Wireless>().SyncActivate(Coordinates); return(true); } return(false); }
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))); }
public override void HitWire(int i, int j) { if (WirelessSystem.Links.ContainsKey(new Point16(i, j))) { var coord = WirelessSystem.Links[new Point16(i, j)]; if (WirelessUtils.IsReceiver(coord)) { //Code below is copied and adapted from Wiring.HitWire() for (int side = 0; side < 4; side++) { int nextI; int nextJ; switch (side) { case 0: nextI = coord.X; nextJ = coord.Y + 1; break; case 1: nextI = coord.X; nextJ = coord.Y - 1; break; case 2: nextI = coord.X + 1; nextJ = coord.Y; break; case 3: nextI = coord.X - 1; nextJ = coord.Y; break; default: nextI = coord.X; nextJ = coord.Y + 1; break; } if (nextI >= 2 && nextI < Main.maxTilesX - 2 && nextJ >= 2 && nextJ < Main.maxTilesY - 2) { var tile = Main.tile[nextI, nextJ]; if (tile.HasTile) { var receiverTile = Main.tile[coord.X, coord.Y]; if (receiverTile.HasTile) { byte b = 4; if (tile.TileType == TileID.WirePipe || tile.TileType == TileID.PixelBox) { b = 0; } // if (receivertile.TileType == TileID.WirePipe) // { // switch (receivertile.TileFrameX / 18) // { // case 0: // if (side != wireDirection) // { // goto IL_315; // } // break; // case 1: // if ((wireDirection != 0 || side != 3) && (wireDirection != 3 || side != 0) && (wireDirection != 1 || side != 2)) // { // if (wireDirection != 2) // { // goto IL_315; // } // if (side != 1) // { // goto IL_315; // } // } // break; // case 2: // if ((wireDirection != 0 || side != 2) && (wireDirection != 2 || side != 0) && (wireDirection != 1 || side != 3) && (wireDirection != 3 || side != 1)) // { // goto IL_315; // } // break; // } // } // if (receivertile.TileType == TileID.PixelBox) // { // if (side != wireDirection) // { // goto IL_315; // } // if (Wiring._PixelBoxTriggers.ContainsKey(point2)) // { // Dictionary<Point16, byte> pixelBoxTriggers; // Point16 key; // (pixelBoxTriggers = Wiring._PixelBoxTriggers)[key = point2] = (pixelBoxTriggers[key] | ((side == 0 | side == 1) ? 2 : 1)); // } // else // { // Wiring._PixelBoxTriggers[point2] = ((side == 0 | side == 1) ? 2 : 1); // } // } bool flag; switch (Wiring._currentWireColor) { case 1: flag = tile.RedWire; // Tile.Wire() break; case 2: flag = tile.BlueWire; break; case 3: flag = tile.GreenWire; break; case 4: flag = tile.YellowWire; break; default: flag = false; break; } if (flag) { var point3 = new Point16(nextI, nextJ); byte b2; if (Wiring._toProcess.TryGetValue(point3, out b2)) { b2 -= 1; if (b2 == 0) { Wiring._toProcess.Remove(point3); } else { Wiring._toProcess[point3] = b2; } } else { Wiring._wireList.PushBack(point3); Wiring._wireDirectionList.PushBack((byte)side); if (b > 0) { Wiring._toProcess.Add(point3, b); } } } } } } } } } }