thelinuxlich / artemis_CSharp

Artemis Entity System Framework ported to C#
Other
341 stars 78 forks source link

ComponentTypeManager initialization #56

Closed Maximusya closed 10 years ago

Maximusya commented 10 years ago

Regarding #53 This optional initialization is supposed to solve multi-world multithreading issue. An app with a single world running on a single thread does not need this kind of initialization.

The intention is to call ComponentTypeManager.Initialize method once at startup, prior to creating any EntityWorld in any thread.

Example usage:

// Scans all the app assemblies for the Component types
ComponentTypeManager.Initialize();
// Initializes using the Types specified
ComponentTypeManager.Initialize(new List<Type>
{
    typeof(TestBaseComponent),
    typeof(TestHealthComponent),
    typeof(TestPowerComponent),
    typeof(TestPowerComponentPoolable),
    typeof(IComponent), // should be filtered out
    typeof(ComponentPoolable), // should be filtered out
    typeof(TestDerivedComponent), // should be filtered out
});

Warning

The new code in ComponentTypeManager has been tested only in FULLDOTNET environment. METRO-functionality regarding Reflection needs review.

Maximusya commented 10 years ago

Since the whole staticness of ComponentType system does not smell good, and I didn't bother redesigning it, so wrote unit tests using Reflection - thus relying on private static implementation >_<

Maximusya commented 10 years ago

Are NUnit tests (under Mono) run concurrently? I can see Travis reported of multiple NullReferenceExceptions. Attempted to soften assertions.

tpastor commented 10 years ago

Nunit call each test sequentially