magikusgierus
Nam of this pattern?
Let's say I'm creating a game. I want to prevent player from saving in some situations, eg.:
- during fights
- in specific location
- in other cases
I could just create variable canPlayerSave on SaveSyste and let other systems set it. But what if:
- player enters specific location - variable is set to true
- fight start - variable set to true
- fight end - variable is set to false, even though player is still in the non-saving location
Solution I worked out: instead of bool, use int: I created a canPlayerSaveCounter, and every time player starts a fight or enter a non-saving location, it's increased by one, and decreased when it ends. Player can only save when the counter is exactly 0.
My question is: does the thing I invented has a name? Can it be implemented differently?
23 replies