public void execute(GameSession gameSession, byte[] bytes)
        {
            var read = new CollectBoxRequest();

            read.readCommand(bytes);

            var player = gameSession.Player;

            var obj = player.Spacemap.Objects.Values.Where(x => x is Collectable collectable && collectable.Hash == read.hash).FirstOrDefault();

            if (obj != null)
            {
                (obj as Collectable).Collect(player);
            }
        }
        public void execute(GameSession gameSession, byte[] bytes)
        {
            var read = new CollectBoxRequest();

            read.readCommand(bytes);

            var player = gameSession.Player;

            foreach (var collectable in player.Spacemap.Collectables.Values)
            {
                if (collectable.Hash == read.itemHash)
                {
                    collectable.Collect(player);
                }
            }
        }
Exemplo n.º 3
0
        public void execute(GameSession gameSession, IByteBuffer buffer)
        {
            var    player = gameSession.Player;
            string hash   = "";

            Packet.Builder.LegacyModule(gameSession, "0|" + ServerCommands.SET_ATTRIBUTE + "|" + ServerCommands.ASSEMBLE_COLLECTION_BEAM_ACTIVE + "|0|" + player.Id + "|-1");
            if (player.UsingNewClient)
            {
                var cmd = new CollectBoxRequest();
                cmd.readCommand(buffer);
                hash = cmd.itemHash;
            }
            else
            {
                var cmd = new commands.old_client.requests.CollectBoxRequest();
                cmd.readCommand(buffer);
                hash = cmd.itemHash;
            }

            if (player.Spacemap.HashedObjects.ContainsKey(hash))
            {
                (player.Spacemap.HashedObjects[hash] as Collectable)?.Collect(player);
            }
        }