Example #1
0
        /// <summary>
        /// Filters out objects from the networkable list
        /// </summary>
        /// <param name="i"></param>
        /// <param name="isLocalPlayer"></param>
        private void FilterNetworkableObject(int i, bool isLocalPlayer)
        {
            try
            {
                var gameObjectAddress = GetNetworkableObjectAddress(i);
                var gameObject        = new GameObjectBase((long)gameObjectAddress, false, false, true);

                /* LocalPlayer */
                if (_localPlayer == null && isLocalPlayer && gameObject.Tag == 6)
                {
                    _localPlayer = new GameObjectBase((long)GetLocalPlayerAddress(), false, false, true);
                    UpdateLocalPlayerPosition(_localPlayer);
                    return;
                }

                /* Networkable players */
                else if (!isLocalPlayer && gameObject.Tag == 6)
                {
                    if (_isCollectingPlayers)
                    {
                        Players.AddOrUpdate(gameObject.SteamID, gameObject, (old, newer) => gameObject);
                    }
                }

                /* Animals */
                else if (gameObject.Layer == 11)
                {
                    if (_isCollectingAnimals && HasPreferredAnimalName(gameObject.EntityName))
                    {
                        Animals.AddOrUpdate(gameObject.InitialAddress, gameObject, (old, newer) => gameObject);
                    }
                }

                /* Everything networkable that is not a tree */
                else if (gameObject.Layer != 30)
                {
                    CollectGameObject(gameObject);
                }
            }
            catch (Exception ex)
            {
                /* Suppress */
            }
        }