public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
      {
         int cursor = StartIndex;

         if ((UserCommandType)Buffer[cursor] != CommandType)
            throw new Exception(ERRORWRONGTYPEBYTE);
         else
         {
            cursor++;
            ClientPreferences = new PreferencesFlags(Buffer, cursor);
            cursor += TypeSizes.INT;
         }

         return cursor - StartIndex;
      }
        /// <summary>
        /// Constructor
        /// </summary>
        public DataController()
        {          
            // create lists
            roomObjects = new RoomObjectList(300);
            roomObjectsFiltered = new RoomObjectListFiltered(roomObjects);
            projectiles = new ProjectileList(50);
            onlinePlayers = new OnlinePlayerList(200);
            inventoryObjects = new InventoryObjectList(100);
            avatarCondition = new StatNumericList(5);
            avatarAttributes = new StatNumericList(10);
            avatarSkills = new SkillList(100);
            avatarSpells = new SkillList(100);
            avatarQuests = new SkillList(100);
            roomBuffs = new ObjectBaseList<ObjectBase>(30);
            avatarBuffs = new ObjectBaseList<ObjectBase>(30);
            spellObjects = new SpellObjectList(100);
            backgroundOverlays = new BackgroundOverlayList(5);
            playerOverlays = new ObjectBaseList<PlayerOverlay>(10);            
            chatMessages = new BaseList<ServerString>(101);
            gameMessageLog = new BaseList<GameMessage>(100);
            visitedTargets = new List<RoomObject>(50);
            clickedTargets = new List<uint>(50);
            actionButtons = new ActionButtonList();
            ignoreList = new List<string>(20);
            chatCommandHistory = new List<string>(20);

            // attach some listeners
            RoomObjects.ListChanged += OnRoomObjectsListChanged;
            Projectiles.ListChanged += OnProjectilesListChanged;
            ChatMessages.ListChanged += OnChatMessagesListChanged;

            // make some lists sorted
            OnlinePlayers.SortByName();
            AvatarSkills.SortByResourceName();
            AvatarSpells.SortByResourceName();
            SpellObjects.SortByName();
            
            // create single data objects
            roomInformation = new RoomInfo();
            lightShading = new LightShading(0, new SpherePosition(0, 0));
            backgroundMusic = new PlayMusic();
            guildInfo = new GuildInfo();
            guildShieldInfo = new GuildShieldInfo();
            guildAskData = new GuildAskData();
            diplomacyInfo = new DiplomacyInfo();
            adminInfo = new AdminInfo();
            tradeInfo = new TradeInfo();
            buyInfo = new BuyInfo();
            welcomeInfo = new WelcomeInfo();
            charCreationInfo = new CharCreationInfo();
            statChangeInfo = new StatChangeInfo();
            newsGroup = new NewsGroup();
            objectContents = new ObjectContents();
            effects = new Effects();
            lookPlayer = new PlayerInfo();
            lookObject = new ObjectInfo();
            clientPreferences = new PreferencesFlags();

            // some values
            ChatMessagesMaximum = 100;
            ChatCommandHistoryMaximum = 20;
            ChatCommandHistoryIndex = -1;
            AvatarObject = null;
            IsResting = false;
            SelfTarget = false;
            IsNextAttackApplyCastOnHighlightedObject = false;
            AvatarID = UInt32.MaxValue;
            TargetID = UInt32.MaxValue;
            ViewerPosition = V3.ZERO;
            UIMode = UIMode.None;
        }
 public UserCommandSendPreferences(PreferencesFlags ClientPreferences)
 {
    this.ClientPreferences = ClientPreferences;
 }
 public UserCommandReceivePreferences(PreferencesFlags ClientPreferences)
 {
    this.ClientPreferences = ClientPreferences;
 }