Beispiel #1
0
        /// <summary>
        /// Creates a factory that provides ECS funcitonality.
        /// </summary>
        /// <param name="entityCapacity">The total of amount of entities supported by this factory.</param>
        /// <param name="componentCapacity">The total of amount of unique <see cref="IComponent"/> types supported by this factory.</param>
        /// <param name="systemCapacity">The total of amount of unique <see cref="MorroSystem"/> types supported by this factory.</param>
        public MorroFactory(uint entityCapacity, uint componentCapacity, uint systemCapacity)
        {
            EntityCapacity    = entityCapacity;
            ComponentCapacity = componentCapacity;
            SystemCapacity    = systemCapacity;

            componentAddition    = new Queue <Tuple <uint, IComponent[]> >((int)EntityCapacity);
            componentSubtraction = new Queue <Tuple <uint, Type[]> >((int)EntityCapacity);
            entityRemovalQueue   = new SparseSet(EntityCapacity);

            // System Setup
            systems      = new MorroSystem[SystemCapacity];
            systemLookup = new Dictionary <Type, uint>((int)SystemCapacity);

            // Component Setup
            componentData   = new IComponent[ComponentCapacity][];
            componentLookup = new Dictionary <Type, uint>((int)ComponentCapacity);

            for (int i = 0; i < ComponentCapacity; i++)
            {
                componentData[i] = new IComponent[EntityCapacity];
            }

            // Entity Setup
            attachedComponents = new SparseSet[EntityCapacity];
            attachedSystems    = new SparseSet[EntityCapacity];
            vacancies          = new Queue <uint>((int)EntityCapacity);

            for (int i = 0; i < EntityCapacity; i++)
            {
                attachedComponents[i] = new SparseSet(ComponentCapacity);
                attachedSystems[i]    = new SparseSet(SystemCapacity);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Creates an object which stores an array of <see cref="MorroSystem"/>'s, and provides functionality to execute said systems.
 /// </summary>
 /// <param name="capacity">The total amount of systems allowed in this group.</param>
 public SystemGroup(int capacity)
 {
     Systems   = new MorroSystem[capacity];
     Execution = SystemExecutionType.Synchronous;
 }