Porting to Unity VI: RPG elements, Time
This week I ported another bulk of data, namely RPG-system related stuff such as attributes, skills, skill categories, skill mastery levels and level-up strategies. The data all became scriptable objects (as they're constant assets), and all except the level-up strategies were enum-ified as it is quite likely that in the code I'll be referring to particular skills/attributes/etc (e.g. if skills[dexterity] > 10, do something)
I've added a much-needed global object with all the game configuration parameters (e.g. max character levels, skill points per level, etc), while in C++ it was pretty much a dictionary loaded from json to avoid recompiles, here I have it as a scriptable object with fixed fields, so access is faster, compiles fast and data are interchangeable.
Another addition is a very simplified form of date/time. I opt out of using C#'s DateTime or TimeSpan as they are for real-world time and therefore do not allow flexibility. What I'm using instead is a simple long value wrapped in a struct (called TimeUnit), representing microseconds. The struct stores loads of constants and helpers for printing and manipulating, so that in the end a TimeUnit is just an integral type with benefits. 64 bits support quite a bit of a range, so it should be enough for the game's time system resolution.