I’ve finished stage 1: the UI stat dictionary is no more. All data is now coming from a single, ridiculously complicated source.
I’m not kidding about the “ridiculously complicated” bit, either. Check out how many different stat classes there are, just to hold the various values associated with creatures alongside their descriptions, mutation rates, minimum/maximum, and mutation maps:
It works, though. Pretty much all the important stat data is now coming from the StatData definition class. This is a good thing.
Hmm… eh, why not. It’s possible some of my readers are almost as boring and nerdly as me, so…
Here’s a copy of the source code for the StatData class’s constructor.
In it’s current state, it includes the complete definition for all the stats, including the delegates that actually calculate quite a few higher-level stats. Things like speed, stamina and attack damage: the complete formula for them are all here.
It’s still functionally identical to what’s running in 0.8.0: some syntax and text changes, but nothing that actually changes how the simulation behaves. So you can compare it to the actual game, if you so desire.
The second stage is supposed to be softcoding the entire UI, but… well, that’s looking more complicated than initially expected.
See, rather than just hardcoding data for the UI, I’ve made quite a bit of use of C# abilities. So while some control definitions look nice and simple, like this…
startingWorldGroupBox.Position = new Vector2(0.05f, 0.36f);
… other control definitions are… less simple.
mainMenuGroupBox.Position = new Vector2(screenWidth / 2 - aspectRatio * 475 / 2, screenHeight / 2 - aspectRatio * 316 / 2);
I’m weighing my options.
I could import definitions as strings rather than numbers, with tokens like [SCREENWIDTH] being replaced by variables in the interpreter. I could try to replicate all this functionality with a data-driven system (using anchors, for example), rather than an algorithmic one. I could try to store these values as a node/variable in XML (I think that’s a thing you can do. Really not as familiar as I should be with XML).
… or I could just… not.
The investment is turning out to be larger than I’d originally planned, and although I’d still love to softcode the entire UI for modding purposes, is it really worth it if it takes a few months extra to do so?
The alternative is just doing a more general clean up on the whole thing, while keeping it contained in C# files. I’m really not sure if this is a better option or not.
Luckily, I’ve got another feature I’ve decided to play with while I decide what I’m going to do here, so I can at least postpone that decision while I consider it.