Пример #1
0
        /// <summary>
        /// Creates fully initialized ECS Manager
        /// </summary>
        /// <returns></returns>
        public static ECSManager CreateECSManager()
        {
            if (!_assembliesScanned)
            {
                throw new Exception($"Unable to create ECS Manager. Call method '{nameof(ScanAssemblies)}' before creating ECS Manager");
            }

            ECSManager result = new ECSManager();

            // initialize ecs manager with available scanned systems
            result.Initialize(AvailableSystems, AvailableTemplates);

            return(result);
        }
        internal void PreInitialize(ECSManager sourceECSManager)
        {
            ComponentSystemAttribute systemAttribute = (ComponentSystemAttribute)this.GetType().GetCustomAttribute(typeof(ComponentSystemAttribute));

            if (systemAttribute == null)
            {
                throw new Exception($"Component System of type {GetType().Name} does not have attribute {nameof(ComponentSystemAttribute)}");
            }

            SystemType     = systemAttribute.SystemProcessingType;
            Order          = systemAttribute.Order;
            ComponentTypes = systemAttribute.Components;

            ECSManager = sourceECSManager;
        }