I need to build an event management system to control NPC behavior, level events, and to simulate off-screen occurrences. For example, the player is in his office doing work. His coworker NPCs should arrive and leave as fits their assigned schedule. While working, they should do little busywork type tasks like type at their desk, get up and appear to talk to each other, etc. They should also be interruptible so they can respond to player interaction, adjust to new orders if necessary, and respond to events like if the room were to suddenly catch fire.
I read through this great thread here, and I’m certain the method @JoeStrout describes is what I want to implement, but I’m stuck even visualizing the details of how this works. So let’s say I have an EventManager object that has a SortedList event queue that will be checked each time tick to see if there are events that need to be processed. But what does that event class/struct look like? How do you store the variety of data needed to pass back to the appropriate entity to execute? And since it’s not just characters that can execute events, but the level itself, how do you standardize events to be able to handle the different options?
To add more complexity, only a limited number of characters will be on-screen at any given time. I’d like to roughly simulate actions for characters not in the currently loaded scene, so that if the character were to, for example, call that person and say “Come to work!” the amount of time it would take them to get there would depend on what they were currently doing. Coworkers at home asleep respond more slowly than ones who are across the street getting coffee.
I know this isn’t a ton of detail, but I guess I’m looking for guidance on how to really structure things. I think I have an idea of how it should work conceptually, but I don’t know how to translate that into code.