internal void deregisterAllComponents() { for (var i = 0; i < _components.length; i++) { var component = _components.buffer[i]; // deal with renderLayer list if necessary if (component is RenderableComponent) { _entity.scene.renderableComponents.remove(component as RenderableComponent); } // deal with IUpdatable if (component is IUpdatable) { _updatableComponents.remove(component as IUpdatable); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType()), false); _entity.scene.entityProcessors.onComponentRemoved(_entity); } } }
void handleRemove(Component component) { // deal with renderLayer list if necessary if (component is RenderableComponent) { _entity.scene.renderableComponents.remove(component as RenderableComponent); } // deal with IUpdatable if (component is IUpdatable) { _updatableComponents.remove(component as IUpdatable); } if (component is INetworkComponent) { _networkingComponents.Value.remove(component as INetworkComponent); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType()), false); _entity.scene.entityProcessors.onComponentRemoved(_entity); } component.onRemovedFromEntity(); component.entity = null; }
internal void registerAllComponents() { for (var i = 0; i < _components.length; i++) { var component = _components.buffer[i]; if (component is RenderableComponent) { _entity.scene.renderableComponents.add(component as RenderableComponent); } if (component is IUpdatable) { _updatableComponents.add(component as IUpdatable); } if (component is INetworkComponent) { _networkingComponents.Value.add(component as INetworkComponent); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType())); _entity.scene.entityProcessors.onComponentAdded(_entity); } } }
public Matcher one(params Type[] types) { foreach (var type in types) { oneSet.set(ComponentTypeManager.getIndexFor(type)); } return(this); }
/// <summary> /// handles any Components that need to be removed or added /// </summary> void updateLists() { // handle removals if (_componentsToRemove.Count > 0) { for (int i = 0, count = _componentsToRemove.Count; i < count; i++) { handleRemove(_componentsToRemove[i]); _components.remove(_componentsToRemove[i]); } _componentsToRemove.Clear(); } // handle additions if (_componentsToAdd.Count > 0) { for (int i = 0, count = _componentsToAdd.Count; i < count; i++) { var component = _componentsToAdd[i]; if (component is RenderableComponent) { _entity.scene.renderableComponents.add(component as RenderableComponent); } if (component is IUpdatable) { _updatableComponents.add(component as IUpdatable); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType())); _entity.scene.entityProcessors.onComponentAdded(_entity); } _components.add(component); _tempBufferList.Add(component); } // clear before calling onAddedToEntity in case more Components are added then _componentsToAdd.Clear(); _isComponentListUnsorted = true; // now that all components are added to the scene, we loop through again and call onAddedToEntity/onEnabled for (var i = 0; i < _tempBufferList.Count; i++) { var component = _tempBufferList[i]; component.onAddedToEntity(); // component.enabled checks both the Entity and the Component if (component.enabled) { component.onEnabled(); } } _tempBufferList.Clear(); } if (_isComponentListUnsorted) { _updatableComponents.sort(compareUpdatableOrder); _isComponentListUnsorted = false; } }
public void updateLists() { // handle removals if (_componentsToRemove.Count > 0) { for (var i = 0; i < _componentsToRemove.Count; i++) { var component = _componentsToRemove[i]; // deal with renderLayer list if necessary if (component is RenderableComponent) { _entity.scene.renderableComponents.remove(component as RenderableComponent); } // deal with IUpdatable if (component is IUpdatable) { _updatableComponents.Remove(component as IUpdatable); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType()), false); _entity.scene.entityProcessors.onComponentRemoved(_entity); } _components.Remove(component); component.onRemovedFromEntity(); component.entity = null; } _componentsToRemove.Clear(); } // handle additions if (_componentsToAdd.Count > 0) { for (var i = 0; i < _componentsToAdd.Count; i++) { var component = _componentsToAdd[i]; if (component is RenderableComponent) { _entity.scene.renderableComponents.add(component as RenderableComponent); } if (component is IUpdatable) { _updatableComponents.Add(component as IUpdatable); } if (Core.entitySystemsEnabled) { _entity.componentBits.set(ComponentTypeManager.getIndexFor(component.GetType())); _entity.scene.entityProcessors.onComponentAdded(_entity); } _components.Add(component); _tempBufferList.Add(component); } // clear before calling onAddedToEntity in case more Components are added then _componentsToAdd.Clear(); _isComponentListUnsorted = true; // now that all components are added to the scene, we loop through again and call onAddedToEntity/onEnabled for (var i = 0; i < _tempBufferList.Count; i++) { var component = _tempBufferList[i]; component.onAddedToEntity(); if (_entity.enabled && component.enabled) { component.onEnabled(); } } _tempBufferList.Clear(); } if (_isComponentListUnsorted) { _updatableComponents.Sort(compareUpdatableOrder); _isComponentListUnsorted = false; } }