Object State Data Fixes


Keeping Me Awake

I woke up last night at like 1am and couldn't fall back to sleep because I kept thinking about what I planned to work on today in this project. My mind kept spinning around and around about the changes I needed to make, the best approach to doing certain things, and where to even begin. So now, here I am, ready to work!

Doing the Work

First things first. I need to look at how I previously implemented the world object state data. This is a system that passes data between my city scene and the savegame manager. My initial idea for implementation was just a pair of strings, one to identify the object, the other to denote the state of the object. The problem with that approach is that it's too limited. An object can only save a single piece of data regarding its state and my plans involve multiple pieces of data persisting. So it's time to change it up!

I guess the first step is to make sure I understand what needs to change. Luckily, in regards to the actual saving and loading, there shouldn't need to be any change there. The main changes are going to happen in the get and set functions in my savegame manager and the city scene itself. I started with the savegame manager because it is the "source of truth" for the data and the city scene just passes data back and forth. Once that was done, I just needed to update a couple of keywords (and changed one variable for clarity).

Updating Interactables

 Once that was done, I needed to actually put it to use. But, one thing that bugging me last night was the approach I took when I built my interactables. Originally, I created one base object, then I duplicated it and made some changes to get things just right for each different object. Turns out that's not the best approach. Instead, I've recreated those scenes as inherited scenes. It took a bit of messing around to figure out exactly what I was doing, but in the end it was all good. I then ended up adding a new "operational status" to the interactable, which will allow me to skin them differently. 

Of course, after all that work, I had to test it. And testing it shows that I totally missed something related to the object state data in my city core complex. Actually, it turned out a missed a whole lot of stuff! I actually had the old system working with this scene, even though it wasn't touching smaller objects. So, a quick couple of changes to that function and the city core complex is working properly again. Now back to affecting interactable object states. . . 

Ugh, I think I need a global signal bus here. . . I didn't build the game initially with one because I wasn't fully understanding my needs, but now it really seems like it will simplify a lot of things. At the very least, I can keep all my signals as they are, and start using a signal bus. maybe eventually I update everything to just pass through it?  There seems to be two main approaches here. One approach is to just declare your signals and then call them directly from other scripts. The other is to actually create a function that re-emits signals it receives. I think I'm going to build a sort of hybrid model because of the way everything's written so far.

A quick and easy hack and I have a signal handler that will allow passing a signal down the tree to my interactable objects. They're not really setup to do anything with the signal yet, but for now it's a beginning. Testing and nothing is broken, so that's good. This whole thing is going to take a lot of work. Oh, I guess I never really laid out what I was trying to accomplish here, did I?

Why Do This?

So, I wanted to add a "broken" state of many interactables, to allow the player to repair them. I haven't defined exactly how that all works because I first needed to be able to pass data around so these things know they're broken or working. Once I've got the data portion working I can build out the actual "work" on the objects themselves. But, I think I've done all I feel like for today.

Next Time

Next time, I'll get my interactable base object working with the signals and state data. It really shouldn't be all that hard, I'm just not in the mood to deal with much more today. I've been at this for a few hours so far and I wanna jump back into Oxygen Not Included! I can't help but keep playing that game. It's also a bit of an inspiration for my game.

Leave a comment

Log in with itch.io to leave a comment.