public static void Recycle <TComponent>(IList <TComponent> list) where TComponent : class, IComponentBase { for (int i = 0; i < list.Count; ++i) { PoolComponents.Recycle(list[i], list[i].GetType()); } list.Clear(); }
public static void Recycle <TComponent>(HashSet <TComponent> list) where TComponent : class, IComponentBase { foreach (var item in list) { PoolComponents.Recycle(item); } list.Clear(); }
public static void Recycle <TComponent>(ref TComponent[] list) where TComponent : class, IComponentBase { for (int i = 0; i < list.Length; ++i) { PoolComponents.Recycle(list[i]); } PoolArray <TComponent> .Recycle(ref list); }
public static void Recycle <TComponent>(ME.ECS.Collections.ListCopyable <TComponent> list) where TComponent : class, IComponentBase { for (int i = 0; i < list.Count; ++i) { PoolComponents.Recycle(list[i], list[i].GetType()); } list.Clear(); }
/// <summary> /// Add component for current entity only (create component data) /// </summary> /// <param name="entity"></param> /// <typeparam name="TEntity"></typeparam> /// <typeparam name="TComponent"></typeparam> /// <typeparam name="TComponentType"></typeparam> public TComponent AddComponent <TComponent, TComponentType>(Entity entity) where TComponentType : class, IComponent where TComponent : class, TComponentType, IComponent, new() { TComponent data; data = PoolComponents.Spawn <TComponent>(); return((TComponent)this.AddComponent <TComponentType>(entity, data)); }
public void RemoveAll(Entity entity) { List <IComponent <TState, TEntity> > list; if (this.dic.TryGetValue(entity.id, out list) == true) { PoolComponents.Recycle(list); list.Clear(); } }
public static T Spawn <T>() where T : class, IComponentBase, new() { var key = WorldUtilities.GetKey <T>(); var obj = (T)PoolComponents.Spawn_INTERNAL(key); if (obj != null) { return(obj); } return(PoolInternalBase.Create <T>()); }
void IPoolableRecycle.OnRecycle() { foreach (var item in this.dic) { PoolComponents.Recycle(item.Value); PoolList <IComponent <TState, TEntity> > .Recycle(item.Value); } PoolDictionary <EntityId, List <IComponent <TState, TEntity> > > .Recycle(ref this.dic); this.freeze = false; this.capacity = 0; }
public static object Spawn(System.Type type) { var key = WorldUtilities.GetKey(type); var instance = PoolComponents.Spawn_INTERNAL(type, key, out var pool); if (instance == null) { instance = (IComponent)System.Activator.CreateInstance(type); PoolInternalBase.CallOnSpawn(instance, pool); } return(instance); }
public void RemoveAll <TComponent>() where TComponent : class, IComponentBase { foreach (var item in this.dic) { var list = item.Value; for (int i = 0; i < list.Count; ++i) { var listItem = list[i]; if (listItem is TComponent listItemComponent) { PoolComponents.Recycle(listItemComponent); list.RemoveAt(i); --i; } } } }
public static void Recycle <T>(T system, System.Type type) where T : class, IComponentBase { var key = WorldUtilities.GetKey(type); PoolComponents.Recycle_INTERNAL(key, system); }
public static void Recycle(object system) { var key = WorldUtilities.GetKey(system.GetType()); PoolComponents.Recycle_INTERNAL(key, system); }
public static void Recycle <T>(ref T system) where T : class, IComponentBase { PoolComponents.Recycle(system); system = null; }
public static object Spawn(System.Type type) { var key = WorldUtilities.GetKey(type); return(PoolComponents.Spawn_INTERNAL(key)); }
public static void Recycle <T>(T system) where T : class, IComponentBase { var key = WorldUtilities.GetKey <T>(); PoolComponents.Recycle_INTERNAL(typeof(T), key, system); }