Implemented "expected event count" special behavior, which fixes the bathtub draining and maybe a few other objects.
Also completely restructured how the VM works at its core, for better accuracy. The only thing it fixes in TSO is the barbeque, but it makes our engine compatible with TS1 style sims and NPCs (no "idle interaction", just run interactions directly from main).
Before (wrong):
- Main is run as an interaction in the queue.
- When main calls "idle for input, allow push", STOP this queue element (main) and run the next one. Works outside main, breaking the bbq.
- When interactions exit, simply run the next one. (do not return to main, as we have stopped it completely.
- MAIN NEVER RESUMES, OR EVEN RESTARTS! TS1 reruns main for idle interactions.
Now (correct):
- Main is run directly on the stack, NOT as an interaction.
- Queue elements are selected and dequeued directly by "Idle for Input, allow push". They are run DIRECTLY ABOVE the main entrypoint like a subroutine.
- When the interaction ends, control is
returned to the main entrypoint from where it left off. It is up to main to run another interaction.
- in TS1, between this and the next interaction we run motive failure checks and idle animations if nothing is queued up. In TSO, uh, you don't die unless your queue is empty...
- Stack frames now know if they are in an interaction or in main. "allow push" will not work in an interaction. (fixes bbq).
- Since interactions are run atomically, on request, we can now start to perform "test" trees directly before running interactions. This will stop going through with interactions that really shouldn't be possible anymore. (eg. use toilet when someone else is on it/going towards it). Not implemented yet.
This will debut in the next build. It pretty much changes everything, so if anything goes wrong tell me immediately! Deleting objects in use will now cause a full reset of the sim... users obviously won't be able to do this, but it is possible for objects to delete themselves or others, so it definitely needs to work reasonably.