Exemplo n.º 1
0
        public bool Matches(EntityBits myOtherArray)
        {
            bool ORResult      = false;
            bool ANDResult     = false;
            bool NOTResult     = true;
            bool HasAtLeastOne = false;

            if (myOrArray.IsValueCreated)
            {
                EntityBits OrArray = myOrArray.Value.Get();
                ORResult      = OrArray.OrTest(myOtherArray);
                HasAtLeastOne = true;
            }
            if (myAndArray.IsValueCreated)
            {
                EntityBits AndArray = myAndArray.Value.Get();
                ANDResult     = AndArray.AndTest(myOtherArray);
                HasAtLeastOne = true;
            }
            if (myNotArray.IsValueCreated)
            {
                EntityBits NotArray = myNotArray.Value.Get(); //TODO: Cache Get()?
                NOTResult     = !NotArray.AndTest(myOtherArray);
                HasAtLeastOne = true;
            }
            return((ANDResult || ORResult) && NOTResult);
        }
Exemplo n.º 2
0
 public void AddToAndSet(EntityBits myArray2)
 {
     myAndArray.Value.Add(myArray2);
     if (hasConflict(myAndArray, myNotArray))
     {
         throw new Exception("And Array and Not Array conflicted!");
     }
 }
        public void RemoveComponent <T>(T myNewComponent) where T : Component
        {
            if (Destroyed)
            {
                throw new InvalidEntityException();
            }
            EntityBits Result = myEntityManager.GetEntityEntityBits(this);

            myComponentManager.RemoveComponent <T>(this, myNewComponent);
            myEntityManager.UpdateEntityEntityBits(this, Result);
        }
 protected virtual void ProcessEntityChange(Entity myEntity, EntityBits ComponentBits)
 {
     if (InternalMatcher.Matches(ComponentBits))
     {
         myEntitySet.Add(myEntity);
     }
     else
     {
         myEntitySet.Remove(myEntity);
     }
 }
        public T AddComponent <T>() where T : Component, new()
        {
            if (Destroyed)
            {
                throw new InvalidEntityException();
            }
            T          Component = null;
            EntityBits Result    = myEntityManager?.GetEntityEntityBits(this);

            Component = myComponentManager?.AddComponent <T>(this);
            return(Component);
        }
 private void EntityComponentAdded(Entity arg1, EntityBits arg2)
 {
     ComponentChanged.Enqueue(new Tuple <Entity, EntityBits>(arg1, arg2));
 }
 internal bool Matches(EntityBits componentBits)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public EntityBits(EntityBits myOther)
 {
     uint[] myInts = new uint[Vector <uint> .Count];
     myOther.myParallelType.CopyTo(myInts);
     myParallelType = new Vector <uint>(myInts);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Checks NOT condition between two EntityBits and tests to see if the incoming Entity passes.
        /// {1,0,0} -> {0,1,1} | {#,#,#}
        /// </summary>
        /// <param name="AnotherEntity"></param>
        /// <returns>True if none of AnotherEntities bits overlaps the NOT operation</returns>
        public bool NotTest(EntityBits AnotherEntity)
        {
            var Return = (~myParallelType) & AnotherEntity.myParallelType;

            return(Return == Vector <uint> .Zero);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Checks OR condition between two EntityBits and tests to see if the incoming Entity passes.
        /// </summary>
        /// <param name="AnotherEntity"></param>
        /// <returns></returns>
        public bool OrTest(EntityBits AnotherEntity)
        {
            var Return = myParallelType & AnotherEntity.myParallelType;

            return(Return != Vector <uint> .Zero);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Checks AND condition between two EntityBits and tests to see if the incoming Entity passes.
        /// </summary>
        /// <param name="AnotherEntity"></param>
        /// <returns></returns>
        public bool AndTest(EntityBits AnotherEntity)
        {
            var Return = myParallelType & AnotherEntity.myParallelType;

            return(Return == myParallelType);
        }