Exemplo n.º 1
0
 public void EntityRemoved(AntEntity aEntity)
 {
     if (_entities.ContainsKey(aEntity))
     {
         RemoveEntity(aEntity);
     }
 }
Exemplo n.º 2
0
 public void ComponentRemoved(AntEntity aEntity, Type aComponentType)
 {
     if (_entities.ContainsKey(aEntity) && _components.ContainsKey(aComponentType))
     {
         RemoveEntity(aEntity);
     }
 }
Exemplo n.º 3
0
 public void EntityAdded(AntEntity aEntity)
 {
     if (!_entities.ContainsKey(aEntity))
     {
         AddEntity(aEntity);
     }
 }
Exemplo n.º 4
0
 public void ComponentAdded(AntEntity aEntity, Type aComponentType)
 {
     if (!_entities.ContainsKey(aEntity))
     {
         AddEntity(aEntity);
     }
 }
Exemplo n.º 5
0
 private void OnComponentRemoved(AntEntity aEntity, Type aComponent)
 {
     foreach (var pair in _families)
     {
         pair.Value.ComponentRemoved(aEntity, aComponent);
     }
 }
Exemplo n.º 6
0
        private void RemoveEntity(AntEntity aEntity)
        {
            var node = _entities[aEntity];

            _pool.Add(node);
            _entities.Remove(aEntity);
            _nodes.Remove(node);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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);
                    }
                }
            }
        }
Exemplo n.º 10
0
        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);
        }