Exemplo n.º 1
0
        public World()
        {
            EntityMasks = new BitSet[MaxEntities];

            HealthComponents = new HealthComponent[MaxEntities];
            RegenerationComponents = new RegenerationComponent[MaxEntities];
            SpatialComponents = new SpatialComponent[MaxEntities];
            FlammableComponents = new FlammableComponent[MaxEntities];
            ConsoleRendererComponents = new ConsoleRendererComponent[MaxEntities];

            _healthSubsystem = new HealthSubsystem(this);
            _consoleDisplaySubsystem = new ConsoleDisplaySubsystem(this);
            _statusEffectsSubsystem = new StatusEffectsSubsystem(this);

            for (int entity = 0; entity < MaxEntities; entity++)
            {
                EntityMasks[entity] = new BitSet();
                EntityMasks[entity].SetBit(ComponentType.NoComponents);

                HealthComponents[entity] = new HealthComponent();
                RegenerationComponents[entity] = new RegenerationComponent();
                SpatialComponents[entity] = new SpatialComponent();
                FlammableComponents[entity] = new FlammableComponent();
                ConsoleRendererComponents[entity] = new ConsoleRendererComponent();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether all of the bits in this instance are also set in the given bitset.
        /// </summary>
        /// <param name="other">The bitset to check.</param>
        /// <returns><c>true</c> if all of the bits in this instance are set in <paramref name="other"/>; otherwise, <c>false</c>.</returns>
        public bool IsSubsetOf(BitSet other)
        {
            if (other == null)
                throw new ArgumentNullException("other");

            var otherBits = other.bits;
            int count = Math.Min(bits.Length, otherBits.Length);
            for (int i = 0; i < count; i++)
            {
                uint bit = bits[i];
                if ((bit & otherBits[i]) != bit)
                    return false;
            }

            // handle extra bits on our side that might just be all zero
            int extra = bits.Length - count;
            for (int i = count; i < extra; i++)
            {
                if (bits[i] != 0)
                    return false;
            }

            return true;
        }