Bug in World Subscription / Serialization functionality?
See original GitHub issueI’m not sure if it’s a bug or if I’m doing something horribly wrong-- please correct me if necessary.
I’m using the integrated TextSerializer
to serialize and deserialize the complete state of my application, and it has been working without problems. At some point though I decided to use World.SubscribeComponentChanged<T>(foobar)
to implement a callback mechanic. I made some quick tests, and the callback mechanic was working just fine. Unfortunately, it broke the serialization mechanic.
The serializer throws an exception and complains about duplicate key entries for each component I register with SubscribeComponentChanged
. If I don’t subscribe, everything’s working fine again.
Maybe I’m doing something wrong, I don’t know. Disposing the subscriptions before serialization doesn’t help either, and I couldn’t find any relevant information in the documentation.
Can anybody reproduce this issue?
EDIT
To clarify what I’m trying to do here… I want to be notified whenever an entity is changed. I haven’t found a way to implement this other than using World.SubscribeComponentChanged<T>(foobar)
. I guess I could also explicitly add an UpdateComponent
or whatever to the entity whenever I change one of its components and create a dedicated system to react properly, but I’d prefer the implicit solution as it would be cleaner and much less error-prone in my opinion.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
You already fixed it? Great! 😃
And you already updated the NuGet package to 0.16.2? Damn… you’re fast.
Glad I could help.
I already removed all that
UpdateComponent
crap I added to my application code yesterday. I invokeWorld.SubscribeComponentChanged
now using generics with each and every component type I do have in my code base, and everything works as intended-- most of all the serialization no longer throws an exception.Thank you very much!
Thx for the small repro, I don’t understand how it slipped past me and didn’t fail earlier.