Posted May 23, 2022 by K&D Games
#prototyping #game mechanics #gamedev #quality of life
Today was very productive!
Started off the day getting the switch "routing" capability designed. I ended up going with an Activator/ActivatorCombiner approach which is a general purpose class that emits an activation state by whomever implements these abstract classes. This allowed me to make the base switches an Activator and create an Activator Combiner class that is itself also an Activator!
These Combiners just have a list of Activators to listen to for state changes in order to evaluate its own activation state. This is convenient because I can mix the list with one-use switches, pressure switches, toggle switches, and even other combiners!
Crucial part now was getting these combiners and connections between switches, combiners, and gates visualized in the editor so I can trace the relationships between my level. In come the Gizmos!
Combiners aren't something physical but they are on a GameObject. This means I can group them next to the switches and gates that they are affecting/listening to. These gizmos even represent the type of logical operation that is being done during the combiner evaluation. I've thought of it as cyAND and magentOR :D Combiners will take their full list and AND or OR their statuses together to set its own Activator State. In the picture, the two switches are connected to a Combiner that ANDs their activations states together to set its activation state. The Gate has its own Combiner that it listens to for activation in order to open and close itself. It is only listening to the switch Combiner so ANDing or ORing wouldn't make a difference.
Once I got all these logical connections up and running I had some time to spare for playing around with shaping Gate behaviors. This will be what I'll work on this week is different Gating variants (one-way, toggle, delayed, etc) but in the meantime, you can enjoy a floppy gate animation! XD