Beispiel #1
0
        /// <summary>
        ///   Adds a component with the specified type to entity with the
        ///   specified id and initializes it with the values taken from
        ///   the passed attribute table.
        /// </summary>
        /// <param name="componentType">Type of the component to add.</param>
        /// <param name="entityId">Id of the entity to add the component to.</param>
        /// <param name="attributeTable">Attribute table to initialize the component with.</param>
        private void AddComponent(Type componentType, int entityId, IAttributeTable attributeTable)
        {
            // Create component.
            IEntityComponent component = (IEntityComponent)Activator.CreateInstance(componentType);

            // Init component.
            this.InitComponent(component, attributeTable);

            // Initialize component with the attribute table data.
            component.InitComponent(attributeTable);

            // Add component.
            this.AddComponent(entityId, component);
        }