colyseus / schema

An incremental binary state serializer with delta encoding for games.
https://docs.colyseus.io/state/schema/
MIT License
130 stars 39 forks source link

Provide a custom "LANG.ts" option in code generator cli #57

Open zgz682000 opened 4 years ago

zgz682000 commented 4 years ago

the inner-provided LANG.ts in code generator may not satisfy everyone's need, such as me. It will be perfect if I can implement my own LANG.ts by responding some kind of protocol (interface or methods) . BTW, I also defined some enum type in my server side schema, generate them into the client side code is a reasonable requirement, isn't it.

endel commented 4 years ago

Hi @zgz682000, thanks for the feedback. Such API may not be easy to expose, but I think we can adapt the parser to identify and generate ENUM and INTERFACE types.

Which other changes you'd make to the default codegen output? You mind providing a comparison of what is generated, and what you'd like to have generated instead? So I can wrap my head around your requirements and try to come up with something. Cheers!

zgz682000 commented 4 years ago

ENUM and INTERFACE type will be enough temporarily. The other changes I prefer to make are about removing the default generated functions, because I am developing a message based game without any state patching, and message schema don't need onChange and so on. That would makes code looks cleaner.

Even If I develop a state patching game, I still don't hope these functions in my generated code files, because when some of the schemas modified, the regenerated code files will cover the code I wrote manually. That makes me trouble

endel commented 4 years ago

Nice @zgz682000, which client integration are you using? AFAIK for C#/Unity there are no onChange callbacks and such. Cheers!

zgz682000 commented 4 years ago

Typescript right now and u3d will be the next. Thank you very much for colyseus's support, it helps me a lot