using System; using System.Collections.Generic; namespace AllocsFixes.LiveData { public abstract class EntityFilterList where T : Entity { public void Get (List _list) { _list.Clear (); try { List entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < entities.Count; i++) { Entity entity = entities [i]; T element = predicate (entity); if (element != null) { _list.Add (element); } } } catch (Exception e) { Log.Exception (e); } } public int GetCount () { int count = 0; try { List entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < entities.Count; i++) { Entity entity = entities [i]; if (predicate (entity) != null) { count++; } } } catch (Exception e) { Log.Exception (e); } return count; } protected abstract T predicate (Entity _e); } }