示例#1
0
        private void RegisterSystem(EntitySystem system)
        {
            Type type = system.GetType();
            ArtemisEntitySystem attribute = (ArtemisEntitySystem)type.GetCustomAttributes(typeof(ArtemisEntitySystem), true)[0];

            _world.SystemManager.SetSystem(system, attribute.GameLoopType, attribute.Layer, attribute.ExecutionType);
        }
示例#2
0
        /// <summary>Initializes all.</summary>
        /// <param name="processAttributes">if set to <see langword="true" /> [process attributes].</param>
        /// <param name="assembliesToScan">The assemblies to scan.</param>
        /// <exception cref="Exception">propertyComponentPool is null.</exception>
        internal void InitializeAll(bool processAttributes, IEnumerable <Assembly> assembliesToScan = null)
        {
            if (processAttributes)
            {
                IDictionary <Type, List <Attribute> > types;
                if (assembliesToScan == null)
                {
#if FULLDOTNET || METRO || UNITY5
                    types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes);
#else
                    types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes, null);
#endif
                }
                else
                {
                    types = AttributesProcessor.Process(AttributesProcessor.SupportedAttributes, assembliesToScan);
                }

                foreach (KeyValuePair <Type, List <Attribute> > item in types)
                {
#if METRO
                    if (typeof(EntitySystem).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo()))
#else
                    if (typeof(EntitySystem).IsAssignableFrom(item.Key))
#endif
                    {
                        Type type = item.Key;
                        ArtemisEntitySystem pee      = (ArtemisEntitySystem)item.Value[0];
                        EntitySystem        instance = (EntitySystem)Activator.CreateInstance(type);
                        this.SetSystem(instance, pee.GameLoopType, pee.Layer, pee.ExecutionType);
                    }
#if METRO
                    else if (typeof(IEntityTemplate).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo()))
#else
                    else if (typeof(IEntityTemplate).IsAssignableFrom(item.Key))
#endif
                    {
                        Type type = item.Key;
                        ArtemisEntityTemplate pee      = (ArtemisEntityTemplate)item.Value[0];
                        IEntityTemplate       instance = (IEntityTemplate)Activator.CreateInstance(type);
                        this.entityWorld.SetEntityTemplate(pee.Name, instance);
                    }
#if METRO
                    else if (typeof(ComponentPoolable).GetTypeInfo().IsAssignableFrom(item.Key.GetTypeInfo()))
#else
                    else if (typeof(ComponentPoolable).IsAssignableFrom(item.Key))
#endif
                    {
                        this.CreatePool(item.Key, item.Value);
                    }
                }
            }

            for (int index = 0, j = this.mergedBag.Count; index < j; ++index)
            {
                this.mergedBag.Get(index).LoadContent();
            }
        }