Imperium uses some game data that could be fairly dynamic. This includes things like the single- and multiplayer scenarios, engine parameters and all AI behavior scripts. Initially all this data was included in the normal game bundle. Easy solution as there’s really nothing to do but to load then data when needed. It’s also not very dynamic. To tweak a parameter, improve the AI slightly or just fix some issue in a scenario I would have to create a new version and submit it to the App Store. There it would be subject to the normal app review delay, making any form of quick turnaround impossible. Clearly not ideal.
To solve this I added an asset server to the normal multiplayer server. This game server runs on some hosted server and will be used for multiplayer games. It was quite simple to add some extra requests to allow the server to also serve asset data from a set of known files. The game would upon startup request a list of available assets. Each asset in the list would have a version and Imperium would compare the version to a local version and request a new version if the server had a newer one. Easy to set up and manage. The server side would just be a simple text file containing the asset index which could be easily updated as new asset versions were created. The problem with this solution is that the server is not really 100% done yet and requires some work in order to scale and be robust enough. That requires time that I don’t have right now.
In order to not have to work on the server asset handling I moved the static assets to Apple’s iCloud and access them via CloudKit. The conversion was quite easy and the code is now a lot simpler. The simplicity is mostly because I don’t have to worry about network communication myself, that’s handled by CloudKit. I also do not have to worry about scalability or stability of the server, that’s also handled by someone else. The asset downloading is perhaps a tiny bit slower now, but there will not be too frequent changes anyway so that’s a hit I’m willing to take. For single player games my own server will not be used at all for now, it will be back in the picture when it’s time to finish the multiplayer side. The game will download only changed assets by using a similar version attribute. Each game keeps track of the last version of assets it has downloaded and just asks CloudKit for any new assets with a higher version. Sometimes the result is empty, sometimes it’ll get some assets.
The drawbacks of using CloudKit is that the asset handling is a bit more cumbersome from my point of view. Uploading assets has to be done via Apple’s CloudKit dashboard and there is no easy form of automation available that could, say, sync the assets that I have locally with those on CloudKit. There is a web service that can be used to build such a thing, but it’s far too low level for this to be a viable task for me to do now. So assets will have to be manually click-click-click uploaded when they change. Not a terribly big issue once the game has been released, but while developing it’s a bit annoying.
But there’s been progress at least, some minor part has been finished. 🙂