/** * Add all items into this bag. * @param added */ public void AddAll(Bag <E> items) { for (int i = 0, j = items.Size(); j > i; i++) { Add(items.Get(i)); } }
/** * After adding all systems to the world, you must initialize them all. */ public void InitializeAll() { for (int i = 0, j = mergedBag.Size(); i < j; i++) { mergedBag.Get(i).Initialize(); } }
void UpdatebagSync(Bag <EntitySystem> temp) { for (int i = 0, j = temp.Size(); i < j; i++) { temp.Get(i).Process(); } }
void UpdatebagASSync(Bag <EntitySystem> temp) { tasks.Clear(); for (int i = 0, j = temp.Size(); i < j; i++) { EntitySystem es = temp.Get(i); #if WINDOWS tasks.Add(factory.StartNew( #else tasks.Add(Parallel.Start( #endif () => { es.Process(); } )); } #if WINDOWS Task.WaitAll(tasks.ToArray()); #else foreach (var item in tasks) { item.Wait(); } #endif }
private void RemoveComponentsOfEntity(Entity e) { int entityId = e.GetId(); for (int a = 0, b = componentsByType.Size(); b > a; a++) { Bag <Component> components = componentsByType.Get(a); if (components != null && entityId < components.Size()) { if (RemovedComponentEvent != null) { RemovedComponentEvent(e, components.Get(entityId)); } components.Set(entityId, null); } } }
protected override void ProcessEntities(Dictionary <int, Entity> entities) { Bag <Entity> groupedEntities = this.world.GetGroupManager().getEntities(group); for (int i = 0, j = groupedEntities.Size(); i < j; i++) { Process(groupedEntities.Get(i)); } }
public void Refresh(Entity e) { SystemManager systemManager = world.GetSystemManager(); Bag <EntitySystem> systems = systemManager.GetSystems(); for (int i = 0, s = systems.Size(); s > i; i++) { systems.Get(i).Change(e); } }
public Dictionary <Entity, Bag <Component> > GetCurrentState() { Bag <Entity> entities = entityManager.GetActiveEntities(); Dictionary <Entity, Bag <Component> > currentState = new Dictionary <Entity, Bag <Component> >(); for (int i = 0, j = entities.Size(); i < j; i++) { Entity e = entities.Get(i); Bag <Component> components = e.GetComponents(); currentState.Add(e, components); } return(currentState); }
void UpdatebagASSync(Bag <EntitySystem> temp) { tasks.Clear(); for (int i = 0, j = temp.Size(); i < j; i++) { EntitySystem es = temp.Get(i); tasks.Add(factory.StartNew( () => { es.Process(); } )); } Task.WaitAll(tasks.ToArray()); }
public Bag <Component> GetComponents(Entity e) { entityComponents.Clear(); int entityId = e.GetId(); for (int a = 0, b = componentsByType.Size(); b > a; a++) { Bag <Component> components = componentsByType.Get(a); if (components != null && entityId < components.Size()) { Component component = components.Get(entityId); if (component != null) { entityComponents.Add(component); } } } return(entityComponents); }
public void LoadEntityState(String tag, String groupName, Bag <Component> components) { Entity e; if (tag != null) { e = this.CreateEntity(tag); } else { e = this.CreateEntity(); } if (groupName != null) { this.groupManager.Set(groupName, e); } for (int i = 0, j = components.Size(); i < j; i++) { e.AddComponent(components.Get(i)); } }
public void LoopStart() { if (!refreshed.IsEmpty()) { for (int i = 0, j = refreshed.Size(); j > i; i++) { entityManager.Refresh(refreshed.Get(i)); } refreshed.Clear(); } if (!deleted.IsEmpty()) { for (int i = 0, j = deleted.Size(); j > i; i++) { Entity e = deleted.Get(i); entityManager.Remove(e); } deleted.Clear(); } }
/** * Removes from this Bag all of its elements that are contained in the * specified Bag. * * @param bag * Bag containing elements to be removed from this Bag * @return {@code true} if this Bag changed as a result of the call */ public bool RemoveAll(Bag <E> bag) { bool modified = false; for (int i = 0, bagSize = bag.Size(); i < bagSize; i++) { Object o1 = bag.Get(i); for (int j = 0; j < size; j++) { Object o2 = data[j]; if (o1 == o2) { Remove(j); j--; modified = true; break; } } } return(modified); }