-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Using Entitas in generic way, instead of generators #345
Comments
If you don't like the code generators you can take a look at [ BTW it appears [here](https://github.com/sschmid/Entitas-CSharp/wiki/Tools-and-Extensions in the docs in case you've missed it, there are a couple more tools there you might be interested in. |
I know it's not exactly the point of your post, but you can re-gen your code in a few short steps which takes me about 1 minute. I do this if I make any breaking changes to a component.
It's not the robust solution you're looking for, but it should definitely not take you 30 mins to re-gen if something breaks. |
@FNGgames unity have a folder WebplayerTemplate, you can move files here if you don't want to compile. Your algorithm is very clear (and I can make a script to make it automagical), but on start, before of understand how framework is working exactly, it's make beginners feel very uncomfortable. I want to say this is huge problem in a core of framework. @danielbe1 I dig trough all wiki, I think. I don't understand why I need other tool to work with Entitas, and I don't like Eclipse :). Maybe, someday I will try it, but first, let me make a bicycle :). Maybe it will be working with generators some day, maybe I will not need it ever. |
Hi. I understand that the current workflow with the reflection-base code generator might be a pain, especially in the beginning when you're new to Entitas and code changes all the time. Good news is that we're currently working on finding better solutions like Entitas-lang or a roslyn-based code generator which will work even when there are compile errors. On premature optimization: Code generation was a natural evolution of the library and necessary to improve performance and optimized memory usage. As it turns out, it also enables us to do automatic object pooling and results in a great api. entity.AddComponent(new PositionComponent());
var pos = entity.GetComponent<PositionComponent)(); There is no object pooling of components and retrieving components like this was very slow and created a measurable bottle neck. Debug.Log(e.debugMessage.message);
// vs
DebugMessageComponent component = (DebugMessageComponent)e.GetComponent(_context.Table.IndexOf<DebugMessageComponent>());
Debug.Log(component.Message); I really like this api, that's why I went with code generation. Luckily code generation is optional and flexible. You can chose to only use a small subset of generator like But your code suggestions contain a few nice ideas that I also wanted to try when tackling #307 |
A multiplayer backend doesn't do anything involving graphics and it's a question of real money if you need 1000 servers or if you can do the same with 100 servers with an optimized framework |
I think a really good point you made is the dependency image. I'll think about it |
@sschmid yeah, I understand about multiplayer and etc. But beginners may not get there because of complicity of work with generators. Is Roslyn work with mac? I made wrong implementation at first, now I move all get/set component code in LookUpTable now just statically extends
Generic.Entity:
I updated gist with full implementation. I think, that code some "not written now" generator of code can convert to more fast in a particular case, if necessary. Conclusion I understand that there a framework with long history, with robust workflow and etc. I just want to give a few ideas, show an example of work without a code generator. Thanks for answers! |
Correct me if I am wrong, but under that solution, the code might compile, but might fail at runtime if any mistake is done. The code generated version will not compile and not fail at runtime and is much more IDE friendly. |
@danielbe1 as a generic solution, it will not compile if you made some type conversion mistakes, as it guarantee type safe. Also, to be honest, I don't test my solution not for errors, not for speed or efficiency, I made it for learning. I want to start using ECS as fast as I can, without fighting with compiler, that I hate to do. If I would love to fight with compiler I'm will programming on C++ xD. Code generated solution more robust, more user friendly and very performant solution, but it have defect with compiling while you in active developing, and made many of changes in components, like remove, rename fields and etc. I love to remove and rename something every time :) and that defect makes me crazy, I feel unconfident and uncomfortable. |
Renaming is quite easy. Use your IDE for that job (Visual Studio or something else). I had my difficulties with the codegen at beginning, too. But now i feel comfortable with it. Sure, there could be some improvements. But speed is very important! The best way to learn and use entitas is to take a look at the examples and videos. And first think about components and then act! And finally, the simplest solution is the right solution ;) |
@Spy-Shifty there problem that when you rename field (with resharper, of course) or change signature, it need to be regenerated, but it can't because of reflection. Generic solution, to my opinion will works same as generated solution, maybe with suspectible lack of performance, but still fast than MonoBehaviour, because in core it is a entitas with their awesomness. Thanks for your advices. |
@sschmid, Back to my first message. I said that I have two solutions, and seconds is using generic wrapper, that wraps entitas with generic methods. But first solution is make a copies of components and make dependencies to that copies instead of source components, I suggested, that this solution will fix issue with impossibility of re-generating when you change source component a lot. But, also I suggested that solution will need a lot of time to work... but last turned out it is not true :) I spend two hours and made some peglegs in code generators to test my suggestion. And it works. It really breaks that vicious circle of dependencies. Now I can use power of generators, and make a changes without pain in ass :). A few comments, that solution very simple, but need to make several changes in code generators, and that solution generate only simple components with fields only (it not copy-paste file, it use arguments list to made component). It need change all dependencies in Systems to generated components. I made it like a proof-of-concept, and it works. |
That second dependency graph which you've shown describes exactly what's Entitas-Lang achieves. It stores Components as separate files, while generated code is that Component Snapshot. I have some ideas about visual component editor (based on uFrame), which will allow the same thing (effectively storing components as editor assets, leaving the generated code to be Component Snapshot). I don't take any steps towards that at the moment because there's so much to do with tutorial videos and blueprints |
@KumoKairo yes, you right. But the fact is, that even with coupled with project compiler (like mono in unity) you can re-generate components after changing. I test that and that's works (I told about in chat). Third-party program not needed. |
Can you post some relative performance charts? Make a few use cases like Execute System with GetComponent, ReplaceComponent etc. With, say, 1000 entities. It will provide a great value to this topic in general. |
Quick draft of generic API: https://github.com/yosadchyi/Entitas.Generic |
How does Entitas-Lang work with player modding? It appears to me that a generic api having the ability to load arbitrary component at runtime is key to easy player modding, and modding capability is major reason to use a ECS system(instead of unity normal way) to me |
@WeslomPo has really strong points. I don´t see any future for Entitas if this is not fixed asap. I don´t have to spend 30 min trying to fix errors just because I renamed some component... and the code becomes too cluttered... I guess this is the opposite direction to go! |
I have to agree on the modding issue; I intend for my game to be very mod-friendly. To that end, I want my environment to be as close to what modders will use as possible, and using the unity editor and/or hard-compiled generated code seems to run contrary to that. IMHO, moddability is one of the most appealing aspects to ECS, so it's a shame Entitas doesn't play as nicely with runtime modification. |
Is this still being discussed? I personally think it would be a huge improvement in developer experience, especially since it would remove a whole step from the pipeline. Maybe some more bench marking would shed some light on whether this is feasible. @yosadchyi's results are certainly promising. |
@BenjaBobs, @sschmid I checked @yosadchyi's results and implemented my own. entity.Replace(new Position(position.Location + velocity.Linear * dt,
position.Rotation + velocity.Angular * dt)); I implemented through generics + lookup table here https://github.com/Deepscorn/EntitasWithoutCodeGeneration Looks nice to me. What do you think? |
Sorry that's off topic, what is the advantage of using generators in particular, instead, for example, generic methods or barehands? Why there no any of tutorial, how to use entitas without generators
notimetoexplain - use generators? Lack of time to make some, I think.
Today I spend whole day trying to work with Entitas and Generators, but it always broke all my code when I remove some parameters from components, or rename it. And that is annoying. 1 minute to change component, 30 minutes to generate code somehow... And there only TWO COMPONENTS. >___<. How it work when there ten of them, thousands, how it use with other teammates? Yeah, I know about compilers, reflections, mono, roslyn and etc, but it is so hard to work with(especially on mac), I did not even try to use them because of complexity.
I start thinking about two solution, first one, copy components in their generated environment (in different namespace, or in class), and use in system only components from there. It prevents of broke code and interrupt compiling process (in theory). Because it very hard to implement with one evening with my knowledge about entitas, I found second solution, that I'm prefer:
Get some generated classes, and make them in generic way. It took about three hours and I make some working solution to start working with Entitas without generator.
Here are a my three hours code, maybe need to add some methods...
Context:
LookupTable:
Matcher
Entity
How to use
Gist
The text was updated successfully, but these errors were encountered: