To implement the separate and individual routines of all the different occupations I needed a way to store them. So I decided to make an object called RoutineEntry it contains information on the start and end time of the routine, the location, the type of action, the priority and if that action is done or not. Using this object should be flexible enough to create some routines that seem complex. I considered saving function for an action instead of just a location, this might make it easier to encapsulate more complex behaviours. However I want to make each RoutineEntry as simple as possible, so I went for the former implementation.
For the time being I only plan to have two "types" those being visit and stay. The visit routines are considered done once the NPC has reached the location, the stay routines are never done, the NPC only stops performing them when the end time is passed. However I can see this as a future issue if an NPC needs to be interrupted from a "stay" routine they are currently performing. If prioritizing works correctly there's a chance I can add a higher priority routine to their schedule while the game is running and the NPC will switch to that instead. This needs testing though.
To briefly explain how the NPC get their routine's populated, when they go to sleep a hard coded routine from their corresponding occupations are added to the next days routine, and the routine for the previous day is cleared. It would be nice to save the history of each individuals previous routines, however I think this out of the scope for this project currently.
In hindsight clearing and populating the next day's routine when an NPC goes to sleep is a bit naive. Obviously I want the variety of some NPCs to stay up all night and not get any sleep. With the current implementation this would have the interesting side effect of the NPC taking the next day off from any form of work, if they didn't go to sleep.
No comments:
Post a Comment