Example #1
0
 public Aspect(params Type[] types)
 {
     Mask = new BigInteger(0);
     foreach (Type element in types)
     {
         Mask += ComponentTypeManager.GetBitFor(element);
     }
 }
Example #2
0
 public void AddComponent <T>(int id, T component) where T : IComponent
 {
     if (_assignedComponents.ContainsKey(id) && !_assignedComponents[id].ContainsKey(typeof(T)))
     {
         _assignedComponents[id].Add(typeof(T), component);
         _entityMasks[id].Mask += ComponentTypeManager.GetBitFor <T>();
     }
 }
Example #3
0
 private void AddComponent(int id, Type t, IComponent comp)
 {
     if (_assignedComponents.ContainsKey(id) && !_assignedComponents[id].ContainsKey(t))
     {
         _assignedComponents[id].Add(t, comp);
         _entityMasks[id].Mask += ComponentTypeManager.GetBitFor(t);
     }
 }
Example #4
0
        public void CleanComponents()
        {
            foreach (Tuple <int, IComponent> compTuple in _componentsToRemove)
            {
                if (_activeEntities.Contains(compTuple.Item1))
                {
                    _entityMasks[compTuple.Item1].Mask -= ComponentTypeManager.GetBitFor(compTuple.Item2.GetType());
                    _world.UpdateEntity(compTuple.Item1, _entityMasks[compTuple.Item1]);
                }
            }

            _componentsToRemove.Clear();
        }
Example #5
0
        private void RemoveAllComponents(int entity)
        {
            if (!_activeEntities.Contains(entity))
            {
                return;
            }

            foreach (KeyValuePair <Type, IComponent> compPair in _assignedComponents[entity])
            {
                _entityMasks[entity].Mask -= ComponentTypeManager.GetBitFor(compPair.Key);
            }
            _world.UpdateEntity(entity, _entityMasks[entity]);

            _assignedComponents[entity].Clear();
        }