-
Notifications
You must be signed in to change notification settings - Fork 5
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
Collect use cases and difficulties from users to improve documentation #21
Comments
I have a suggestion for the workflow of Processors. It would be great to be able to register components in the processor's constructor. That way you don't have to search through all entities and components during the update event, processor update functions will only be executed on entities that meet all component requirements. You could also have events fired when entities are added and removed from processors. Here's an example of the workflow I'm thinking of.
|
I like some of what you're proposing, but not all of it. I believe it would be a mistake to make processors depend on Component types. Specifically, I've already had processors that would work on a component, and then check if another one was present for an entity and do something special if it was. That would not be possible with your proposal. The events I like very much though, but I think I would implement them slightly differently. Here's what a Processor would look like in my idea: class RenderingProcessor {
constructor(manager) {
this.manager = manager;
this._sprites = {};
}
on(type, data) {
switch (type) {
case 'COMPONENT_CREATED':
if (data.component === 'Display') {
let display = data.state;
let position = this.manager.getComponentDataForEntity('Position', data.entity);
let newSprite = this.game.add.sprite(position.x, position.y, display.spriteImagePath);
this._sprites[data.entity] = newSprite;
}
break;
case 'COMPONENT_REMOVED':
if (data.component === 'Display' && this._sprites[data.entity]) {
this._sprites[entity].kill();
delete this._sprites[entity];
}
break;
default:
break;
}
}
update(dt) {
let displays = this.manager.getComponentsData('Display');
for (let entity in displays) {
let display = displays[entity];
let position = this.manager.getComponentDataForEntity('Position', entity);
this._sprites[entity].x = position.x;
this._sprites[entity].y = position.y;
}
}
} What do you think about that @CodestarGames ? On a side note, I see that you want to use entities as objects. That is something I really want to avoid, because conceptually, entities are just identifiers. This API is slightly more complicated to use than say Crafty's API, but it is also a lot more flexible and has a bunch of benefits (that I admit |
Thanks for some of the quick fixes on the other issues. I had been looking around for an ECS library to use for a roguelike project I recently started and initial concerns with many that I'd found was that they were unmaintained (sometimes for multiple years). I'm glad to see that I'm lazy (functions have long names)In
This means I can type Iterating through entitiesBecause With
I'm sure there's more to this that could work, but it's just the thoughts I had. I expect it's also possible to get fancy and have the manager do a lot of the work automatically by simply checking if an entity should be added or removed from a Group each time the user adds or removes a Component. Just register a Group and then use it. Anyway, sorry for the wall of text; I'll be working on my stuff and as I come across things I'll share them. I'll also look for ways to contribute to |
Thank a lot @Hectate for the great feedback! I do like having shorter names as well, and I like some of your propositions. The one I'm not sure about is Regarding the group feature, I'll have to think about it more. I understand that it is indeed a desirable feature, but I think I would, at first, do it as simply as possible, so doing something like your 2nd solution. I have also recently been talking about this with a colleague who's coding his own ECS, and there are some things that I believe I do wrong in here. I'd like to take some time to refine the API in the near future, and also do some performance testing to prove that the way this works is actually suitable for bigger games. I'll file new issues for each of these things, if you want to help you are very welcome to do so. Thanks again! |
In order to make a great documentation, I think we need a lot of very precise and concrete examples. For that, I would need to know what people struggle to understand or achieve using
ensy
. That can be something high level related to the concept of Entity Systems or things related to the use of the lib itself.So, if you read this and have anything to say, please comment! :)
The text was updated successfully, but these errors were encountered: