Continuing Code Cleanup


Note To Self:

As I was laying down to sleep last night, tossing and turning because my brain wouldn't shut off, a couple of things related to Xenodochium flit through my thoughts. The first, and most important, was that I haven't taken time jumps into account when dealing with time-related things such as interactables and satiety drain. I'm really not sure exactly how I want to address these things yet, but this is definitely something I need to ponder. My initial thoughts are to take time jumps into account for interactables, but not when it comes to player satiety and other effects. It would make sense to tick down buffs and drain satiety when the player chooses to skip time though.

The other thing I was thinking about is related specifically to NPCs. I think it may be time to create an NPC state for interactables and then roll the existing NPC scene into a new scene inherited from the interactable. Right now, the NPC is a bastardization of the original interactable base, so it doesn't include any of the operational states or any of the cleaned up code in my current interactable design. I know I need to refactor NPCs eventually, and I know I need to put more work into interactables, so those two will probably go hand-in-hand. I think when I'm ready to implement animations for interactables I will begin with rolling the NPC in first. Once that's done I will only have to add animation to a single thing instead of doing it twice. 

Working Out

With those notes out of the way for later, it's time to switch into cleanup mode. Today, I'm going to start with a very specific area for cleanup. There are a couple of systems that kick out constant chatter, the HUD and interactables. I'm starting with the HUD because that should be a pretty easy cleanup. The thing that jumps out at me most is that every time my HUD updates something, such as current vitals, it drops a debug message. No need for all of that!

As I was digging through the code, I came across something I didn't expect. For some reason, in my HUD prefab code, there's a bunch of "push_error" lines, instead of the usual "push_warning" calls. Not having thought about it before, I think a lot of my existing warnings should actually be errors, so one day I'll have to go back through all of this again to replace a bunch of warnings with errors. It's a little funny looking at this code because there are a few debug messages I'd already commented out in an earlier session because I just happened upon it while updating something else. Along with the debug cleanup, there were a lot of old comments that I erased. Most of the comments were explanatory things from when Gemini built the system(s) originally. But now that I am more experienced with Godot, I don't need those anymore.

Wow, after going over my HUD script, I see so much opportunity for improvement! There is a lot of redundant code and other quirky things that can probably be improved. I do remember that I need to refactor my UI manager too, so hopefully when I work on one I'll work on the other. I feel like a lot of my UI manager is redundant, and most of the functions in there should be combined into a more modular approach. That is work for another day, today is about debug cleanup!

Testing shows my cleanup of the HUD code was successful and doesn't appear to have introduced any new bugs. Next stop, interactables. There's a few very specific places I need to fix. The issue is that every single interactable in the world kicks out two or three individual debug messages that just aren't needed. Funny enough, there was one debug line inside the setter of one of my variables but the setter only existed for the debug message, so that whole setter was thrown in the trash! Most of the messages I'm cleaning up are "setup" related, such as pulling data and setting interaction limits.

Next Time

I'm confident I got a bunch of useless chatter cleaned up but there's so much more to go. I've done what I wanted to today, so I'll be back for more tomorrow. And, as I mentioned recently, I think tomorrow is going to be Documentation Day! I'm hopeful I can really push through and rework some of the documentation I have. Currently, it's pretty sparse and there's no real structure to it. I'm hopeful I can come up with a good way to design the documentation to make it more useful down the road. Then once I get my structure defined I can start filling it in more. I think I might actually share the docs here eventually. At the very least it can serve as a bit of a road map for the game. Actually, maybe I should try to define an actual road map . . . 

Leave a comment

Log in with itch.io to leave a comment.