Ejemplo n.º 1
0
        public bool HasTags(EntityID entity, TagMask mask)
        {
            bool has;

            entitiesLock.Enter(READ_LOCK_MODE);
            {
                has = entities[entity].Has(mask);
            }
            entitiesLock.Exit();
            return(has);
        }
Ejemplo n.º 2
0
 public void RemoveTags(EntityID entity, TagMask mask)
 {
     entitiesLock.Enter(WRITE_LOCK_MODE);
     {
         //Locks this particular entity for modification.
         lock (entityWriteLocks[entity])
         {
             entities[entity].Remove(mask);
         }
     }
     entitiesLock.Exit();
 }
Ejemplo n.º 3
0
        public EntityTagContainer()
        {
            entities         = new TagMask[EntityID.MaxValue];
            entityWriteLocks = new object[EntityID.MaxValue];
            entitiesLock     = new ModeLock();

            //Create a tag-mask and a lock object for each entity
            for (EntityID entity = 0; entity < EntityID.MaxValue; entity++)
            {
                entities[entity]         = new TagMask();
                entityWriteLocks[entity] = new object();
            }
        }
Ejemplo n.º 4
0
        public void Query(TagMask requiredTags, TagMask illegalTags, EntitySet outputSet)
        {
            outputSet.Clear();
            bool noIllegalComps = illegalTags.IsEmpty;

            entitiesLock.Enter(READ_LOCK_MODE);
            {
                for (EntityID entity = 0; entity < EntityID.MaxValue; entity++)
                {
                    if (entities[entity].Has(requiredTags) && (noIllegalComps || entities[entity].NotHas(illegalTags)))
                    {
                        outputSet.Add(entity);
                    }
                }
            }
            entitiesLock.Exit();
        }
Ejemplo n.º 5
0
        public int Query(TagMask requiredTags, TagMask illegalTags)
        {
            int  count          = 0;
            bool noIllegalComps = illegalTags.IsEmpty;

            entitiesLock.Enter(READ_LOCK_MODE);
            {
                for (EntityID entity = 0; entity < EntityID.MaxValue; entity++)
                {
                    if (entities[entity].Has(requiredTags) && (noIllegalComps || entities[entity].NotHas(illegalTags)))
                    {
                        count++;
                    }
                }
            }
            entitiesLock.Exit();
            return(count);
        }
Ejemplo n.º 6
0
 public TagMask Remove(TagMask other)
 {
     val &= ~other.val;
     return(this);
 }
Ejemplo n.º 7
0
 public TagMask Add(TagMask other)
 {
     val |= other.val;
     return(this);
 }
Ejemplo n.º 8
0
 public bool NotHas(TagMask other) => (other.val & val) == 0;
Ejemplo n.º 9
0
 public bool Has(TagMask other) => (other.val & val) == other.val;
Ejemplo n.º 10
0
 public bool HasTags(EntityID entity, TagMask mask) => tagContainer.HasTags(entity, mask);
Ejemplo n.º 11
0
 public int GetEntityCount(TagMask requiredTags, TagMask illegalTags)
 => tagContainer.Query(requiredTags, illegalTags);
Ejemplo n.º 12
0
 public void GetEntities(TagMask requiredTags, TagMask illegalTags, EntitySet outputSet)
 => tagContainer.Query(requiredTags, illegalTags, outputSet);