How to Ensure Sequential Interaction Logic Between Actors (Fridge → Cutting Board → Cut Meat)?

1 In the object. It’s not just one variable, a particular object could have several ( or even many ) states. For instance a locked electronic door could have is powered, is locked, is open etc.

The other place to store these values is in the save game. Because each object needs to be able to remember what was happening before, when you start the game again.

2 Each actor is responsible for its own states. Generally speaking, its bad practice for actor A to change states for actor B.

3 Don’t compare them. Decisions are made by passing messages between actors. So the key actor sends the unlock message to the door actor when the player uses it. Then the key can remember ( save game ), it was used, and door can remember it was unlocked.

4 Don’t pass them. Just pass messages between the actors, that’s where using interfaces comes in.

2 Likes