giovinazzo-kevin / Fiero

1 stars 0 forks source link

Serialization #13

Open giovinazzo-kevin opened 1 year ago

giovinazzo-kevin commented 1 year ago

It's imperative to think about binary serialization before things get even messier.

The gist of it is:

Core

Business

giovinazzo-kevin commented 10 months ago

This can probably be done through Ergo, but it may be unnecessary.

giovinazzo-kevin commented 5 months ago

Actually I'm getting more confident that most of the work can be done by Ergo. In fact, the game is already relying on C#-Ergo marshalling and serialization a great deal, which is good.

The only real problem is serializing some components which, right now, are simply being omitted from the marshalling process. That includes any component which contains properties which can not be marshalled automatically, such as Funcs. Theoretically, it should be possible to refactor them in such a way that they go back to being POD objects, which are straightforward to marshal and easy to serialize. Refactoring them is not always simple, however.

Then there's effects, which, again, need to be resumed and potentially to store some state instead of being restarted every time. New effects are being implemented directly in Ergo, so they handle their own state already. Serializing those should be easy since it's just a matter of writing the KB to disk, which contains state in the form of dynamic predicates. Bombs and explosive barrels are an example of this.

As for effects written in C#, they would need some explicit interface methods to do so.

That said, this should be 80% of the work because almost everything in Fiero is an entity: map tiles and features, items, actors. Clearly the solution would need to be performant, but that's a great excuse to further optimize Ergo.