Ejemplo n.º 1
0
 public EntityFactory(World world, EntityTemplateCollection templateCollection, Func <Type, string> componentNameExtractor, params Assembly[] componentAssemblies)
 {
     _world = world;
     _templateCollection    = templateCollection;
     ComponentNameExtractor = componentNameExtractor;
     _components            = componentAssemblies
                              .Union(new [] { Assembly.GetExecutingAssembly(), Assembly.GetCallingAssembly() })
                              .Union(AppDomain.CurrentDomain.GetAssemblies()
                                     .Where(x => !x.FullName.StartsWith("Microsoft.", StringComparison.InvariantCultureIgnoreCase) &&
                                            !x.FullName.StartsWith("System.", StringComparison.InvariantCultureIgnoreCase) &&
                                            !x.FullName.StartsWith("Windows.", StringComparison.InvariantCultureIgnoreCase)))
                              .SelectMany(x => x.GetTypes().Where(t =>
                                                                  t.Name.EndsWith("Component", StringComparison.InvariantCultureIgnoreCase) ||
                                                                  t.GetCustomAttributes(typeof(ComponentAttribute), true).Any()))
                              .ToDictionary(x => ComponentNameExtractor(x), x => x, StringComparer.InvariantCultureIgnoreCase);
 }
Ejemplo n.º 2
0
 public EntityFactory(World world, EntityTemplateCollection templateCollection,
                      params Assembly[] componentAssemblies)
     : this(world, templateCollection, DefaultComponentNameExtractor, componentAssemblies)
 {
 }