예제 #1
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
 public void EntityRemoved(AntEntity aEntity)
 {
     if (_entities.ContainsKey(aEntity))
     {
         RemoveEntity(aEntity);
     }
 }
예제 #2
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
 public void ComponentRemoved(AntEntity aEntity, Type aComponentType)
 {
     if (_entities.ContainsKey(aEntity) && _components.ContainsKey(aComponentType))
     {
         RemoveEntity(aEntity);
     }
 }
예제 #3
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
 public void EntityAdded(AntEntity aEntity)
 {
     if (!_entities.ContainsKey(aEntity))
     {
         AddEntity(aEntity);
     }
 }
예제 #4
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
 public void ComponentAdded(AntEntity aEntity, Type aComponentType)
 {
     if (!_entities.ContainsKey(aEntity))
     {
         AddEntity(aEntity);
     }
 }
예제 #5
0
 private void OnComponentRemoved(AntEntity aEntity, Type aComponent)
 {
     foreach (var pair in _families)
     {
         pair.Value.ComponentRemoved(aEntity, aComponent);
     }
 }
예제 #6
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
        private void RemoveEntity(AntEntity aEntity)
        {
            var node = _entities[aEntity];

            _pool.Add(node);
            _entities.Remove(aEntity);
            _nodes.Remove(node);
        }
예제 #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();
        }
예제 #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();
        }
예제 #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);
                    }
                }
            }
        }
예제 #10
0
파일: AntFamily.cs 프로젝트: gkjolin/GOAP-1
        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);
        }