InfiniteSigns.Sign.Nearby C# (CSharp) Method

Nearby() public static method

public static Nearby ( int X, int Y ) : bool
X int
Y int
return bool
        public static bool Nearby(int X, int Y)
        {
            return SignOn(X, Y) || SignOn(X - 1, Y) || SignOn(X + 1, Y) || SignOn(X, Y - 1) || SignOn(X, Y + 1);
        }

Usage Example

コード例 #1
0
        void OnGetData(GetDataEventArgs e)
        {
            if (!e.Handled)
            {
                using (var reader = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
                {
                    switch (e.MsgID)
                    {
                    case PacketTypes.SignNew:
                    {
                        reader.ReadInt16();
                        int    x    = reader.ReadInt16();
                        int    y    = reader.ReadInt16();
                        string text = reader.ReadString();
                        Task.Factory.StartNew(() => ModSign(x, y, e.Msg.whoAmI, text));
                        e.Handled = true;
                    }
                    break;

                    case PacketTypes.SignRead:
                    {
                        int x = reader.ReadInt16();
                        int y = reader.ReadInt16();
                        Task.Factory.StartNew(() => GetSign(x, y, e.Msg.whoAmI));
                        e.Handled = true;
                    }
                    break;

                    case PacketTypes.Tile:
                    {
                        byte   action = reader.ReadByte();
                        int    x      = reader.ReadInt16();
                        int    y      = reader.ReadInt16();
                        ushort type   = reader.ReadUInt16();

                        if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY)
                        {
                            return;
                        }

                        if (action == 0 && type == 0)
                        {
                            if (Sign.Nearby(x, y))
                            {
                                Task.Factory.StartNew(() => KillSign(x, y, e.Msg.whoAmI));
                                e.Handled = true;
                            }
                        }
                        else if (action == 1 && (type == 55 || type == 85))
                        {
                            if (TShock.Regions.CanBuild(x, y, TShock.Players[e.Msg.whoAmI]))
                            {
                                WorldGen.PlaceSign(x, y, type);
                                NetMessage.SendData(17, -1, e.Msg.whoAmI, "", 1, x, y, type);
                                if (Main.tile[x, y].frameY != 0)
                                {
                                    y--;
                                }
                                if (Main.tile[x, y].frameX % 36 != 0)
                                {
                                    x--;
                                }
                                Task.Factory.StartNew(() => PlaceSign(x, y, e.Msg.whoAmI));
                                e.Handled = true;
                            }
                        }
                    }
                    break;
                    }
                }
            }
        }
All Usage Examples Of InfiniteSigns.Sign::Nearby