To put this snippet in laymans terms, any script can call the ReportAction method in the quest manager to report an action that has occurred and the quest manager will add 1 to the number of times this action has been reported (the action name is saved as a key and the times it's been reported as it's definition in a dictionary).
This way, whenever I go to create the quests themselves, I can do so relatively easily because I can call this method from any script without dirtying up THAT code. I can design quests to defeat a certain enemy X times, defeat X enemies, survive for X waves, etc. by setting the quest's internal requirement to a certain action having been reported X times then calling ReportAction from whichever area of my codebase handles that particular event in the game and comparing the values every so often (I'll probably do this in the FixedUpdate loop or better yet write an OnActionReported event in this script and call it whenever ReportAction is called so it's not being checked 50 times a second, literally)













0 comments