Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent passing in type as component #8

Open
rdb opened this issue Mar 22, 2020 · 2 comments
Open

Prevent passing in type as component #8

rdb opened this issue Mar 22, 2020 · 2 comments
Labels
design Problems with how we do ECS

Comments

@rdb
Copy link
Contributor

rdb commented Mar 22, 2020

It would be useful if an error were raised if, say, a type instead of a Component were passed into the create_entity function.

@Schwarzbaer
Copy link
Collaborator

Okay, let's see... Right now, @Component() does nothing more than "This is a dataclass with eq=False". I think the simple solution would be to create a base class Component instead, and simply use isinstance(component, Component). No idea whether that'd limit our design space. It might be worth it to allow arbitrary objects as components, and just recommend to use @dataclass. It has been shown to be a good idea, but with the proposed change, it'd be one more thing developers would have to remember; Classes inheriting dataclasses are not automatically dataclasses themselves. Opinions, @janEntikan, @owlen?

@Schwarzbaer Schwarzbaer added the design Problems with how we do ECS label Jul 18, 2020
@owlen
Copy link
Contributor

owlen commented Jul 18, 2020

I really think that owlen@6c386d5#diff-aea33697fd7aee7c291e955864ea202bR63-R64 solves most if not all of the issue, as the common mistake is simply forgetting the parenthesis. That's a simple enough test that covers all of the times I encountered it, and probably most of those @janEntikan mentioned. I would start with this, and see if there are more complaints after that. Certainly wouldn't change the hierarchy structure if you don't have to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Problems with how we do ECS
Projects
None yet
Development

No branches or pull requests

3 participants