Пример #1
0
        private static void RegisterComponent(Type component, ref List <Type> registeredTypes)
        {
            // Get the base class so those can be registered first.
            var baseType = component.BaseType;

            if (baseType != null && baseType != typeof(object) && baseType.Assembly == component.Assembly)
            {
                var registerQueue = new List <Type>();
                registerQueue.Add(baseType);

                while (baseType.BaseType != null && baseType.BaseType.Assembly == component.Assembly)
                {
                    baseType = baseType.BaseType;
                    registerQueue.Add(baseType);
                }

                for (int i = registerQueue.Count - 1; i > -1; i--)
                {
                    var type = registerQueue[i];
                    if (registeredTypes.Contains(type))
                    {
                        continue;
                    }

                    registeredTypes.Add(type);
                    EntityComponent.TryRegister(type);
                }
            }

            registeredTypes.Add(component);
            EntityComponent.TryRegister(component);
        }
Пример #2
0
 internal static void ScanAssembly(Assembly assembly)
 {
     foreach (Type t in assembly.GetTypes())
     {
         EntityComponent.TryRegister(t);
         BehaviorTreeNodeFactory.TryRegister(t);
     }
 }