Nez.Matcher.isInterested C# (CSharp) Method

isInterested() public method

public isInterested ( BitSet componentBits ) : bool
componentBits BitSet
return bool
		public bool isInterested( BitSet componentBits )
		{
			// Check if the entity possesses ALL of the components defined in the aspect.
			if( !allSet.isEmpty() )
			{
				for( int i = allSet.nextSetBit( 0 ); i >= 0; i = allSet.nextSetBit( i + 1 ) )
				{
					if( !componentBits.get( i ) )
					{
						return false;
					}
				}
			}

			// If we are STILL interested,
			// Check if the entity possesses ANY of the exclusion components, if it does then the system is not interested.
			if( !exclusionSet.isEmpty() && exclusionSet.intersects( componentBits ) )
			{
				return false;
			}

			// If we are STILL interested,
			// Check if the entity possesses ANY of the components in the oneSet. If so, the system is interested.
			if( !oneSet.isEmpty() && !oneSet.intersects( componentBits ) )
			{
				return false;
			}

			return true;
		}

Same methods

Matcher::isInterested ( System.Entity e ) : bool

Usage Example

        public virtual void onChange(Entity entity)
        {
            var contains = _entities.Contains(entity);
            var interest = _matcher.isInterested(entity);

            if (interest && !contains)
            {
                add(entity);
            }
            else if (!interest && contains)
            {
                remove(entity);
            }
        }