PlayerStatsManager: The Intelligent Core - Dynamic Vitals & Active Effects


My new approach is helping a lot with Gemini, but it still doesn't solve "Something went wrong". I started out the day thinking about "transferring" my knowledge to a new chat, but I had a goal today so that's left for another day. Today, I did my first vibe coding livestream. You heard me, I spent a good few hours today, livestreaming over on my Twitch channel. I had about the expect amount of turn-out, my usual viewers popped in and kept me company while I worked.

My goal today was to begin defining some simple buffs and de-buffs for the player, as well as tying them into the existing in-game time system. I was hopeful that wouldn't have to make significant changes across the board, but I knew just to get these active effects working, I'd have to overhaul some of my player manager. As a matter of fact, most of the changes today were centralized in that one script.

So the first thing that was needed was to actually define the data surrounding the effects and how they'd be applied. Over the course of the session, this was refined and distilled into a new resource definition that is handled by the data manager. During that process I setup a new JSON file for the data manager to load, for some generic effects that may or may not ever be used. This at least lays the groundwork for the future.

The actual tie-in to the time handler took a bit work. Originally, I was thinking of just triggering every in-game minute, but I realized that wouldn't be sufficient, since I'm going to have to be able to load in a save game or start a new game. So, I did have to make some slight modifications to the time handler, but nothing too major. I had to make sure I had the order of operations right. 

With the changes to the time handler, the playerstat manager waits for the initial "time_jump" signal (whether we're loading an existing save or starting a new game) to load up the effects, then begin triggering the countdown based on in-game time passing. The original logic and implemented logic were fairly similar but it was just too simple at first and could have shorted the duration of an active effect erroneously.

With all of that, I also wanted to implement a robust system for defining effects that could be applied based on other conditions (like a vital stat goes below a threshold). So, I rolled that into the data manager too, for the playerstat manager to be able to just read this data and work. I now have another JSON file where I can apply different effects (whether positive or negative) based on vital statistics such as health and hunger.

There was a bit of work done too, to prevent vitals from somehow going outside of the acceptable range, and allowed for other scripts to connect to signals for when a vital becomes depleted. All of this, with the idea in mind that we'll be able save and restore any of these things when we build that functionality.

Next steps, we keep working on the UI. Gotta get those elements I built yesterday, updating with the right information. So, I'll need to add a script to the HUD prefab and the debug overlay to deal with their internal components. I'll have to make changes to the ui manager to even be able to show those two different UI scenes (when appropriate) and hide them (without freeing them, hopefully) when they're not needed.

After that comes some real heavy work, the beginning of my savegame functionality. Gemini suggested I roll that into the data manager, but I think it may be best to keep the two separate. One deals with purely in-game definitions of resources, while the other deals specifically with saving and loading variables between game sessions. That's good stopping point for today. Time to transition the livestream into something else, like No Man's Sky!

Leave a comment

Log in with itch.io to leave a comment.