Beispiel #1
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            ModMessageID msg = (ModMessageID)reader.ReadByte();

            int id = reader.ReadInt32();

            TileEntity TE;

            if (!TileEntity.ByID.TryGetValue(id, out TE))
            {
                GetModWorld <TPTrackerWorld>().teleporters.RemoveAll(x => x.ID == id);
                return;
            }

            TEWirelessTeleporter TEw = (TEWirelessTeleporter)TE;

            if (Main.netMode == 2)
            {
                switch (msg)
                {
                case ModMessageID.RequestLock:
                    TEw.Connect();
                    break;

                case ModMessageID.RequestUnlock:
                    TEw.Disconnect();
                    break;

                case ModMessageID.RequestPush:
                    TEw.PushDown();
                    break;
                }
            }
            else if (Main.netMode == 1 && msg == ModMessageID.ShareTeleporterData)
            {
                TEw.NetReceive(reader, false);
            }
        }
        private bool TryGetTarget(out TEWirelessTeleporter TE)
        {
            WirelessTeleporterTile tile = mod.GetTile <WirelessTeleporterTile>();

            return(tile.TryGetTE(Player.tileTargetX, Player.tileTargetY, out TE));
        }