Multi-character Drawing Support (Patreon)
Content
The character drawing code is some of the oldest and most core code in Lab Rats 2. It has been iterated on multiple times to add new functionality, but one thing has stayed constant: it was designed to display a single character to the screen at a time. In retrospect I should have taken the time when I first wrote the display code to support multiple characters from the start, but the next best time to do it is now!
The first step to solving a problem is to lay out what the problem is. In this case the problem is that some scenes involve multiple characters, and these characters are often suppose to be taking simultaneous actions. Due to the single character restriction only one person can be shown at a time, meaning there are either lots and lots of switches between characters (which can be tedious to code and to play through) or forcing the player to pick a single character to look at and ignoring everything else going on. This will be even more of a problem when threesomes (and other types of multi-character interactions) are introduced.
The solution is obviously to start showing multiple characters at once, but there are some important goals I also want to achieve. The first is one of simplicity: I want any changes to the draw system to allow for the exact same single character behavior that exists right now. The vast majority of events will only involve a single character, so I want to avoid any extra work there. Second, I want the way multiple characters are displayed to carry extra information. Specifically I want to be able to use the multi-character display to draw attention to information like who is talking, or who is being described by the narration. Third, I want multi-character scenes to have no major performance drawbacks. I will need to do some testing, but this might involve having only the "primary" character animated, while the rest are static. Finally, I want the new display code to handle an arbitrary number of characters on screen. In practice two character scenes are going to be most common and super high character counts may be impractical, but if I'm putting in the time I might as well make it something that will be usable for every event imaginable.
My design will have all of the character images lined up, starting from the right side of the screen (where characters currently display) and then spacing them out to the left. Events with multiple characters will have a "primary" character, who is usually the active speaker or the topic of narration. The "primary" will appear full size and at the front of the stack. All other characters will be placed behind and shrunk slightly. As you move further left and right along the stack characters will be shrunk slightly more, to give a wedge appearance with the primary at the front. Character order in this stack will be consistent throughout a scene to help the player keep track of who is who.
To implement this design I will be adding a new display class. This class will be used in any event that has multiple characters, and will be responsible for drawing each character in the appropriate position in the character stack as well as tracking who is the primary speaker. This display class will also be able to keep track of existing characters and move them/resize them around instead of redrawing them any time a change is made to a different character in the character stack. This should keep the extra performance impact of multiple characters low.
So that's the plan. I've prototypes a few bits of the new system, so now I need to tie it all together and get it running smoothly. Once that's done I will be going through all of the existing events and updating any events that involve multiple characters to use the new system. After that I'll evaluate how much time left I have before the v0.33 release and see what else I can add!