public void EntityRemoved(AntEntity aEntity) { if (_entities.ContainsKey(aEntity)) { RemoveEntity(aEntity); } }
public void ComponentRemoved(AntEntity aEntity, Type aComponentType) { if (_entities.ContainsKey(aEntity) && _components.ContainsKey(aComponentType)) { RemoveEntity(aEntity); } }
public void EntityAdded(AntEntity aEntity) { if (!_entities.ContainsKey(aEntity)) { AddEntity(aEntity); } }
public void ComponentAdded(AntEntity aEntity, Type aComponentType) { if (!_entities.ContainsKey(aEntity)) { AddEntity(aEntity); } }
private void OnComponentRemoved(AntEntity aEntity, Type aComponent) { foreach (var pair in _families) { pair.Value.ComponentRemoved(aEntity, aComponent); } }
private void RemoveEntity(AntEntity aEntity) { var node = _entities[aEntity]; _pool.Add(node); _entities.Remove(aEntity); _nodes.Remove(node); }
public void RemoveEntity(AntEntity aEntity) { foreach (var pair in _families) { pair.Value.EntityRemoved(aEntity); } aEntity.EventComponentAdded -= OnComponentAdded; aEntity.EventComponentRemoved -= OnComponentRemoved; _entities.Remove(aEntity); aEntity.OnRemovedFromEngine(); }
public void AddEntity(AntEntity aEntity) { foreach (var pair in _families) { pair.Value.EntityAdded(aEntity); } aEntity.EventComponentAdded += OnComponentAdded; aEntity.EventComponentRemoved += OnComponentRemoved; _entities.Add(aEntity); aEntity.OnAddedToEngine(); }
public void AddEntity(Transform aTransform, bool aIncludeChildren = false) { AntEntity entity = aTransform.GetComponent <AntEntity>(); if (entity != null) { AddEntity(entity); if (aIncludeChildren && aTransform.childCount > 0) { for (int i = 0, n = aTransform.childCount; i < n; i++) { AddEntity(aTransform.GetChild(i), aIncludeChildren); } } } }
private void AddEntity(AntEntity aEntity) { foreach (var pair in _components) { if (!aEntity.Has(pair.Key)) { return; } } var node = _pool.Get(); _entities[aEntity] = node; foreach (var pair in _components) { pair.Value.SetValue(node, aEntity.Get(pair.Key), null); } _nodes.Add(node); }