Refactoring: Cutscene Player Finale
Finale?
I picked the title of this post before I even did any work, I think I'm feeling a little bold today. In reality, I am worried about what I need to do. I haven't seriously looked at the functionality in my cutscene player in a while, so I'm not even sure what is needed to accomplish what I want. And that's what's bothering me, this will be a bit complex, and I know I won't be able to rely on Gemini for all of it.
I know I will need to add new nodes to the cutscene player itself (based on the nodes in the current cutscene template). I will need to change the way my cutscene player works to no longer instantiate the cutscene itself. I need to move the functionality from the cutscene template into the cutscene player itself. Actually, maybe that's how I should start, look over the code and document the logical steps of my cutscenes and how it all works together. With that information I'll be able to more precisely figure out what needs to be done.
Let's Dig In
First, I need to figure out how exactly I'm even starting my cutscene. I start my cutscenes by calling a function on my game manager, feeding it with the location of the cutscene I want loaded. The game manager sets the game state to cutscene, loads the cutscene player, instantiates it as a child of root, and finally calls a function in my cutscene player to start the cutscene (as defined by the location that was passed to the game manager).
When instantiated, the cutscene player itself then verifies all it's nodes, sets up its initial UI state (basically clearing everything), and connects its buttons. Once the cutscene is started it loads and instantiates the individual cutscene scene, and then begins the cutscene sequence. This just basically does the same thing as when the cutscene progresses to the next frame. This is where the individual cutscene scene takes over processing. The actual cutscene then processes one step of my cutscene data at a time, updating the individual nodes according to what is defined.
What Do?
Wow, I'm actually glad I did this exercise because I see now that there's more to do than I originally intended. I think I'm going to end up redoing a lot of this. First, my game manager should not be handling the cutscene player. It should hold the data surrounding the cutscene but it should work similarly to the dialogue system. I call a function on the game manager which sets a variable then sets the state. The UI manager should then take over everything to do with the cutscene when it detects that state.
I'm afraid, I always hate messing around in my game manager. I think Gemini led me astray when I built the game manager. Looking back, I feel like it should have been a scene and not just a script. I was much too new to this whole thing to have a good idea of what I was doing and was relying on Gemini too much. And, because I was still learning Godot, I made stupid choices and actively refused to use scenes for my singletons. Live and learn!
I have to figure out the order of operations when it comes to fixing this mess. I think maybe I start where I was planning, roll the cutscene template up into the cutscene player. Start by hard-coding the cutscene being played since there's only the one so far. Once I've got that working I can move on to the next step, which will be to move the loading of the cutscene player to the UI manager and out of the game manager. I think I've skipped something in there though.
Let's Go!
I was considering leaving it there and not actually doing anything today. It wouldn't really be a good idea, but it would be valid for my approach to this game. I am still working too. Like, actual work at a paying job. I do all this work in my spare time. I guess I'll start with Gemini and see how it goes. First, let's give it some direction. I'm giving the scripts for my cutscene player and the template (technically, I'm working from my prologue cutscene) along with some direction and the text of this post so far.
After I fed it the two scripts, this post (as it was at the time), and some specific direction, it asked me some questions for guidance. I answered them to the best of my ability and off we went. It gave me back the cutscene player script with most of what I wanted. Since it was a new chat instance it didn't understand my project so made some assumptions I had to correct (it was trying to "find" my singletons and assign them to internal variables instead of just calling their global name).
Then there was the legacy issue. Currently, my cutscene is started from the game manager, with a parameter of which cutscene to load. I'm moving away from that functionality, but the call for the cutscene loading included a parameter, so I had to accept a parameter. It doesn't do anything, but it won't run without it. And again, after correcting the AI's use of my global variables, it started using the wrong case, so I had to correct that.
The next script included a useless function so I had that removed. I also updated it to use my own debug handler instead of pushing warnings. Then, as it turns out, the entire cutscene definition was being loaded and passed instead of just the step data (my "frames"), so I had to get that corrected! And again, Gemini tried to use an invalid function, making assumptions on the data structure, so I sent it a copy of the resource definition.
That's when I realized I had made a mistake, I totally forgot to assign my nodes to the export variables! That's also when I realized Gemini was once again hallucinating and referencing keys in my frames that didn't exist. Instead of "dialogue_text" it was trying "dialog", and it did that with EVERY SINGLE KEY. The information was right there in the files I gave it. . .
Then I realized that Gemini had removed an entire function from my cutscene player without maintaining the functionality elsewhere. My music wasn't playing, my background image wasn't showing. Another update to the code and it still wasn't right, my music still wasn't loading. Finally, I made the last correction. I took the code from my original script and modified it to fit this new scenario. Gemini was trying to pass a path to a music track, but my audio handler requires an array of AudioStream.
It took a few (8) tries. Eventually, I had to actually make some corrections myself. But in the end, it's working! I knew it was going to be trouble, but I also know it needed to be done. And it's not done, yet. I still have to push through and completely change the way the cutscene player starts. I have to get the functionality out of my game manager and instead move it into my ui manager. But that should be a lot easier than this, because I can simply copy existing code (like for my dialogue system) to make it work.
But that's work for another day, I'm taking today's win and taking a break!
Xenodochium
The future is what you make of it!
Status | In development |
Author | Munchmo |
Genre | Role Playing |
Tags | 2D, Cozy, Godot, Indie, Life Simulation, Pixel Art, Sci-fi, Singleplayer |
Languages | English |
More posts
- Cutscene Refactor: The Other Pieces20 hours ago
- Refactoring Cutscenes: Part 22 days ago
- Refactoring: Cutscene Player3 days ago
- Localization: Finished, Terminado, Fertig, Tapos Na!4 days ago
- Localization: Digging Deep5 days ago
- Localization: A Return6 days ago
- Of Dragon Con, Debug Overlay, and Localization10 days ago
- Dragon Con: A Vacation12 days ago
- Dialogue System: Talking Points Go BRRRR14 days ago
Leave a comment
Log in with itch.io to leave a comment.