Over the weekend I expanded upon the logic processing or my game engine. Originally it would process all of the logic for the current room (a level essentially), actors in the current room and any logic scripts held in a global list. When a new room is entered all logic not contained in the global list is dumped and the new room and actor logic is run.
There are functions to load and stop global logic so if I needed to kick off logic that would process across multiple rooms that is very easy to do. But I hit an issue putting together a new room that needed to have more complex logic that was executed only in that room.
I could make a script that is run globally but I would need to make sure to kill it when the player exits the room. This is not a problem but it does leave plenty of room for error if you forget to kill it when the room exits.
Introducing "local logic" all the flexibility of "global logic" but with out the need to clean up. The local logic gets emptied any time the room changes. Now I can kick off scripts on the local level and not have to worry about cleanup though I still have the power to kill the script at anytime. Now you can break up the logic into many smaller pieces and start and stop them through the main room script. Its like Lego but with game logic.
Comments
Post a Comment