2 ms·
I think you misunderstand the ECS pattern. You want: class DrawSystem{ Draw(DrawComponent) } With some mapping of DrawComponent to MyEntity.
by jayd16 6y ago
I think you misunderstand the ECS pattern. You want:
class DrawSystem{
Draw(DrawComponent)
}
With some mapping of DrawComponent to MyEntity. That mapping would most likely NOT be in the MyEntity class definition.
Or you can put the DrawComponents on the Draw system and simply track mapping back to the MyEntity instance they correspond to. New code lives in the systems.
In a game you'd have some kind of scene system that could track what entity has what components and then you don't even need a MyEntity class at all. You wouldn't track that composition in a class.
The sugar that Rust is bringing is that it feels like the implementation is being added to the instance instead of an external system outside it, but you can make that work in C# with some extension methods. It would be nicer if/when C# gets extension interfaces.
- alkonaut 6y agoThats exactly how I understand an EC system but my issue with it is the overly soft coupling with just ids.
- jayd16 6y agoI guess you want to know that every MyEntity can be drawn and can move so you don't have to try-get the component. The disconnect I think is that part of the ECS design is that you have the freedom to break that guarantee. Entities are no longer types but collections of components. The soft coupling is the goal.
- alkonaut 6y agoYes exactly, I think it’s an elegant system for some contexts but I wouldn’t want every system to be forced to use it, so I wouldn’t want that ECS design to be a fundamental part of the language. Soft coupling is basically just giving up typing at some interface and relying on soft information. Which can be fine, but not always.