Before I had a bunch of serialized strings with the text for each hint and it had been reading from multiple otherwise irrelevant scripts in order to know when to show each one. With the addition I made yesterday of the messages and lang systems, it dawned on me that I had given myself a way to simplify the hints system A LOT!

For starters, I wrote this struct so I can add and modify hints from the inspector window. My idea when writing this was that the handler algorithm would display the definition of langEntryName in the user's language in the hint box in the HUD whenever a message matching triggerMessage is recieved by the message hub. In order to stop hints from showing repeatedly, there's also a boolean that will be updated to true when the hint has been shown.
Side note: One of my favorite aspects of the C# language is the ability to use the get property for the purpose of writing public accessor fields in particular. They're a lot more concise to my brain than having to write "GetTriggerMessage()" or "GetShown()" in my code.

My favorite part is how the HintsHandler class itself is hilariously shorter and more concise than it was. The algorithm in the Update method loops through each hint entry (ignoring it if it has been shown) and reads through the messages recieved by the message hub to check for the trigger message, displaying the hint's text in the hint box if the message is found. In order to show the core gameplay mechanics hint immediately, I just send that message on start, simple as that.
The only drawback here is the small delay that comes with the way my message system has a 1 frame delay between when a message is sent and when it's been recieved (you can see this post I made yesterday if you're curious as to why this occurs). It's not particularly noticeable unless you're running at a low framerate, though.













0 comments