Hacker News new | past | comments | ask | show | jobs | submit | jolexxa's comments login

All very good advice that I feel deeply. I think I fell into the honey trap some time ago, but I've made peace with that — the tools I'm making will probably do more good than any game I could finish making, at least for now.

Jokes aside, though, I do try to dog-food my tooling as much as possible. I maintain a Godot/C# 3d platformer game demo with full state preservation/restoration (<https://github.com/chickensoft-games/GameDemo>) to demonstrate this.

By the time I've finished writing tests and docs for a tool, I've usually identified and fixed a bunch of usability pain points and come up with a happy path for myself and other developers — even if it's not 100% perfect.

I also have a bunch of unreleased game projects that spawned these projects, and even gave a talk on how this stuff came about (<https://www.youtube.com/watch?v=fLBkGoOP4RI&t=1705s>) a few months ago if that's of interest to you or anyone else.

The requirements you mentioned in your comment cover selectively serializing state and decoupling saving/loading logic, and I could not agree more. While you can always abuse a serializer, I hope my demonstration in the game demo code shows how I've selectively saved only relevant pieces of game data and how they are decoupled and reconstructed across the scene tree.

Also probably worth mentioning the motivation behind all this — the serialization system here should hopefully enable you to easily refactor type hierarchies without having to maintain manual lists of derived types like System.Text.Json requires you to do when leveraging polymorphic deserialization.

Manually tracking types (presumably in another file, even) is such an error-prone thing to have to do when using hierarchical state machines where each state has its own class (like <https://github.com/chickensoft-games/LogicBlocks>). States as classes is super common when following the state pattern and it is well supported with IDE refactoring tools since they're just classes. Basically this serialization system exists to help save complex, hierarchical state without all the headaches. While I was at it, I also introduced opinionated ways to handle versioning and upgrading because that's also always a headache.


I really like this implementation, but it's probably worth mentioning here that RunUO and other tools like it are solving the problem at a layer of abstraction beneath what I was introducing here.

The serialization system I am providing here actually leverages System.Text.Json for reading and writing data — it's more concerned with helping you represent version-able, upgrade-able data models that are also compatible with the hierarchical state machine implementation I use for managing game state.


This is a good point. I don't think anyone wakes up wanting to make a new serializer. At this point, I was already pretty deep into making and releasing tools for my game projects so doing this didn't seem like such a stretch (although it actually ended up being one of the hardest things I've ever done).

A lot of small to mid-size games (which are the focus of the tools I provide) want to save data into JSON, whether it is to be mod-friendly or just somewhat human-friendly to the developer while working on the game. Not familiar with Thrift, but PB is obviously for binary data and has a focus on compactness and performance, which isn't the primary concern on my list of priorities for a serialization system. My primary concern for a serialization system is refactor-friendliness. I want to be able to rework type hierarchies without breaking existing save files, or get as close to that as possible.

I suppose you could say I'm only really introducing "half" of a serialization system: the heavy lifting is being split between the introspection generator (for writing metadata at compile time via source generation) and System.Text.Json (which handles a lot of the runtime logic for serializing/deserializing things).


That's essentially what this system does — it identifies the models and their properties that you've marked as serializable at build-time using source generation, and then allows you to provide a type resolver and converter to System.Text.Json that lets you make upgrade-able models with logic like you just described.

The assist from the source generation helps reduce some of the boilerplate you need, but there's no escaping it ultimately.


Hi friends, I worked really hard on trying to make serialization and complex save/load easier to implement for C# Godot games (a lot of it is just pure C# and works for other stuff, too).

This serialization effort ended up resulting in the creation of a number of new tools, as well as major updates to existing ones.

As usual, I am always open to feedback and questions. Just wanted to share in hopes that it helps someone and maybe get some critical insight into technical improvements, if you spot something.


hey me too!! The video that finally helped me get going was this one from Imphenzia on YT: https://youtu.be/1jHUY3qoBu8

all his other stuff is great, like building and rigging a low-poly character. Instead of having to follow tutorials and make stuff I didn’t want to, he shows you how to use the tools to make what’s in your imagination!


It’s used with Flutter, Google’s app development framework. I really enjoy Dart as a language, but it is fairly young and missing a few conveniences (such as data classes). It also can’t compile to dynamic libraries, only executables. Despite that, it is very pleasant if you enjoy managed languages.


Wow, that’s really exciting. I’m looking forward to having the option to run linux. I’ve been eyeing elementaryOS for years, but it will be hard to leave some macOS-only apps behind.


wow thanks for sharing this! super convenient to hit “follow all” and suddenly have 80 people to follow!


I first started learning C# and XNA before college to make a game for my Zune HD. That was my first exposure to OOP. Ah, those were the days...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: