public void RefreshState()
        {
            if (gameController.Area.CurrentArea == null /*|| !EntitiesStack.CanRead */ || entityCollectSettingsContainer.NeedUpdate || !Player.IsValid)
            {
                return;
            }
            //   var entities = EntitiesStack.Read();
            while (Simple.Count > 0)
            {
                var entity = Simple.Pop();
                if (entity == null)
                {
                    DebugWindow.LogError($"{nameof(EntityListWrapper)}.{nameof(RefreshState)} entity is null. (Very strange).");
                    continue;
                }

                var entityId = entity.Id;
                if (entityCache.TryGetValue(entityId, out _))
                {
                    continue;
                }
                if (entityId >= Int32.MaxValue && !_settings.ParseServerEntities)
                {
                    continue;
                }

                if (/*!entity.IsValid ||*/ entity.Type == EntityType.Error)
                {
                    continue;
                }

                /*if (entity.Type == EntityType.Monster && (entity.GetComponent<Life>() == null ||
                 *                                        entity.GetComponent<ObjectMagicProperties>() == null))
                 * {
                 *  entity.IsValid = false;
                 *  continue;
                 * }*/

                if (entity.League == LeagueType.Legion)
                {
                    if (entity.Stats == null)
                    {
                        continue;
                    }
                }

                EntityAddedAny?.Invoke(entity);
                if ((int)entity.Type >= 100)
                {
                    EntityAdded?.Invoke(entity);
                }

                entityCache[entityId] = entity;
            }

            UpdateEntityCollections();
            entityCollectSettingsContainer.NeedUpdate = true;
        }
        public void RefreshState()
        {
            if (gameController.Area.CurrentArea == null)
            {
                return;
            }
            if (entityCollectSettingsContainer.NeedUpdate)
            {
                return;
            }
            if (Player == null || !Player.IsValid)
            {
                return;
            }

            while (Simple.Count > 0)
            {
                var entity = Simple.Pop();

                if (entity == null)
                {
                    DebugWindow.LogError($"{nameof(EntityListWrapper)}.{nameof(RefreshState)} entity is null. (Very strange).");
                    continue;
                }

                var entityId = entity.Id;
                if (entityCache.TryGetValue(entityId, out _))
                {
                    continue;
                }

                if (entityId >= int.MaxValue && !_settings.ParseServerEntities)
                {
                    continue;
                }

                if (entity.Type == EntityType.Error)
                {
                    continue;
                }

                EntityAddedAny?.Invoke(entity);
                if ((int)entity.Type >= 100)
                {
                    EntityAdded?.Invoke(entity);
                }

                entityCache[entityId] = entity;
            }

            UpdateEntityCollections();
            entityCollectSettingsContainer.NeedUpdate = true;
        }