thelinuxlich / artemis_CSharp

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

Enable generic addcomponent #54

Closed Maximusya closed 10 years ago

Maximusya commented 10 years ago

Fixed: All the AddComponent<T>(IComponent component) method chain was dead code by default: entity.AddComponent(new MyComponent()); always chose non-generic Entity.AddComponent(IComponent component)

Maximusya commented 10 years ago

Oh, that "are you serious" thing IComponent won't let tests pass

Maximusya commented 10 years ago

Ok, I think it's time to ditch IComponent<T> interface. To make the test pass - i.e. add derived component as a base component, you should change public void TestDerivedComponents():

entity.AddComponent(derived);

to this

entity.AddComponent(derived as TestBaseComponent);

See? C# power! Clear intentions, intuitive - not some hidden hack.

tpastor commented 10 years ago

Add this to the pull request. So i can merge all at once Em 12/12/2013 12:06, "Maximusya" notifications@github.com escreveu:

Ok, I think it's time to ditch IComponent interface. To make the test pass - i.e. add derived component as a base component, you should change public void TestDerivedComponents():

entity.AddComponent(derived);

to this

entity.AddComponent(derived as TestBaseComponent);

See? C# power! Clear intentions, intuitive - not some hidden hack.

— Reply to this email directly or view it on GitHubhttps://github.com/thelinuxlich/artemis_CSharp/pull/54#issuecomment-30424220 .

Maximusya commented 10 years ago

It looks like it was automatically added to the initial pull request - when I commited latest changes to the branch