Today went a bit differently than I expected it would. My initial goal was going to be working on the dialogue system. I needed the NPC to open up the dialogue system UI and populate the easy stuff. To be honest, I can't even remember everything I went through today. I've spent far longer on this today than anything in the last month or so.
The first issue I had was that my dialogue definition didn't take into account data that I needed for updating my dialogue system display. Specifically, I needed an image for my portrait and a name to display for the NPC. That's not really part of a dialogue. So I ended up refactoring a couple of things, adding a whole new resource definition, and updating my data manager to load it.
The refactoring covered a few areas, but a lot of it boiled down to changing the way the game manager dealt with dialogues. Originally, I was basing the dialogue system off the dialogue ID, but I needed to take a step back. So, I changed the game manager to work from the NPC ID, which now corresponds to an NPC Definition, which contains my dialogue ID. The NPC definition will end up growing a bit as I get further along.
The actual NPC resource definition is pretty simple. It contains a few strings, an ID, a name, the path to a portrait, and a dialogue ID. There's also a function to return a Texture2D from a string property on the resource. Again, I'm sure it'll grow. Actually, I know it'll grow, I need to add an audio clip in there. Okay, raised an issue for later in my git.
Then, once I built a simple JSON containing my first NPC, I had to get the data manager to load it. This was pretty straightforward. I just copied the existing functionality of the other loading. I had a couple of small issues, but the recent refactor of my JSON load to break the different dictionaries apart really made this easy.
With that done, I build out the rest of the dialogue system to work from the NPC ID. The portrait gets set, the name updates, and it picks and displays a random greeting from the list. I still haven't built out the conditional greeting functionality, and the only button that works is the goodbye button. . . But it's what I wanted to get accomplished today.
I did have a major hard time troubleshooting the text update though. Randomly, my RichTextLabels wouldn't show their text. It was set, but it wouldn't show on the screen unless I intervened. And it wasn't the node visibility, it was the actual node itself not drawing properly or something. Turns out, in the end, the problem was all me. I was using the text property to set it, when I should have been using the add_text method instead.
And the best part was, I did a lot of this myself. Don't get me wrong, I did get help from Gemini. But, compared to some days, a lot more of today consisted of me writing everything myself. This is one step closer to my vision, but there's still so much more to do. Even with the dialogue system I still need to make the buttons work.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.