Exemple #1
0
        private void AreaChanged(AreaInstance area)
        {
            try
            {
                entityCollectSettingsContainer.Break = true;
                var dataLocalPlayer = gameController.Game.IngameState.Data.LocalPlayer;

                if (Player == null)
                {
                    if (dataLocalPlayer.Path.StartsWith("Meta"))
                    {
                        Player         = dataLocalPlayer;
                        Player.IsValid = true;
                        PlayerUpdate?.Invoke(this, Player);
                    }
                }
                else
                {
                    if (Player.Address != dataLocalPlayer.Address)
                    {
                        if (dataLocalPlayer.Path.StartsWith("Meta"))
                        {
                            Player         = dataLocalPlayer;
                            Player.IsValid = true;
                            PlayerUpdate?.Invoke(this, Player);
                        }
                    }
                }

                entityCache.Clear();
                OnlyValidEntities.Clear();
                NotOnlyValidEntities.Clear();

                foreach (var e in ValidEntitiesByType)
                {
                    e.Value.Clear();
                }

                //  foreach (var e in NotValidEntitiesByType) e.Value.Clear();
            }
            catch (Exception e)
            {
                DebugWindow.LogError($"{nameof(EntityListWrapper)} -> {e}");
            }
        }
Exemple #2
0
        private void UpdateEntityCollections()
        {
            OnlyValidEntities.Clear();
            NotOnlyValidEntities.Clear();
            NotValidDict.Clear();

            foreach (var e in ValidEntitiesByType)
            {
                e.Value.Clear();
            }

            while (keysForDelete.Count > 0)
            {
                var key = keysForDelete.Dequeue();

                if (entityCache.TryGetValue(key, out var entity))
                {
                    EntityRemoved?.Invoke(entity);
                    entityCache.Remove(key);
                }
            }

            foreach (var entity in entityCache)
            {
                var entityValue = entity.Value;

                if (entityValue.IsValid)
                {
                    OnlyValidEntities.Add(entityValue);
                    ValidEntitiesByType[entityValue.Type].Add(entityValue);
                }
                else
                {
                    NotOnlyValidEntities.Add(entityValue);
                    NotValidDict[entityValue.Id] = entityValue;
                }
            }
        }
Exemple #3
0
        //  public Dictionary<EntityType, List<Entity>> NotValidEntitiesByType { get; }

        private void UpdateEntityCollections()
        {
            OnlyValidEntities.Clear();
            NotOnlyValidEntities.Clear();
            NotValidDict.Clear();

            foreach (var e in ValidEntitiesByType)
            {
                e.Value.Clear();
            }

            //  foreach (var e in NotValidEntitiesByType) e.Value.Clear();
            while (keysForDelete.Count > 0)
            {
                var key = keysForDelete.Dequeue();

                if (entityCache.TryGetValue(key, out var entity))
                {
                    EntityRemoved?.Invoke(entity);
                    entityCache.Remove(key);
                }
            }

            foreach (var entity in entityCache)
            {
                var entityValue = entity.Value;

                if (entityValue.IsValid)
                {
                    OnlyValidEntities.Add(entityValue);
                    ValidEntitiesByType[entityValue.Type].Add(entityValue);
                }
                else
                {
                    NotOnlyValidEntities.Add(entityValue);
                    NotValidDict[entityValue.Id] = entityValue;

                    // NotValidEntitiesByType[entityValue.Type].Add(entityValue);
                }
            }

            /*foreach (var entity in entityCache)
             * {
             *  var entityValue = entity.Value;
             *  var diff = _entitiesVersion - entityValue.Version;
             *  if (diff > 1)
             *  {
             *      entityValue.IsValid = false;
             *      NotOnlyValidEntities.Add(entityValue);
             *      NotValidEntitiesByType[entityValue.Type].Add(entityValue);
             *      /*if (diff > RemoveValue)
             *      {
             *          if ((int)entityValue.Type <100 || entityValue.Id >= Int32.MaxValue)
             *          {
             *              keysForDelete.Enqueue(entity.Key);
             *          }
             *      }#1#
             *  }
             *  else
             *  {
             *      OnlyValidEntities.Add(entityValue);
             *      ValidEntitiesByType[entityValue.Type].Add(entityValue);
             *      entityValue.IsValid = true;
             *      /*if (entityValue.Type == EntityType.Monster && !entityValue.IsAlive && !entityValue.IsLegion)
             *      {
             *          keysForDelete.Enqueue(entity.Key);
             *      }#1#
             *  }
             * }*/
        }