-
Notifications
You must be signed in to change notification settings - Fork 1
CSP Component Signal Processor
It's a system that allows the programmer to define outputs and inputs for a MonoBehaviour class. These can be connected by designers (or whoever) in-editor to create sequences of events. If you've worked with the IO system of the Source engine before - it's basically that.
First and foremost, here's a definition of the basic terminology:
It's an event that occurs when something happens. You raise these in your code at the appropriate places.
For instance there's an action "OnTriggerEnter" when something enters a trigger.
You'd raise that in OnTriggerEnter or OnTriggerEnter2D. You might put some conditions up front
so it would only be raised, for instance, when a player enters a trigger or a GameObject with a specific tag.
It's entirely up to you.
Inputs are, technically, a method (any method with either no arguments or a string as argument) in your MonoBehaviour that can be selected when an Output occurs. It can be anything. "Trigger a sequence" or "Turn the lights off". Conversely we can say Inputs are reactions that should happen upon a given output event.
Example:
- Player walks through a trigger area.
- Trigger fires a "TriggerEnter" CSP signal
- A "Falling Death Trap" object was wired up to the triggers TriggerEnter signal and on receiving this signal, call the "ActivateTrap" action
- ActivateTrap action is invoked - Player dies because of falling hazard?
This is a very simple example. On the field you can hook up very complex and advanced sequences of inputs and outputs. Inputs can even be used to invoke follow-up signals. In the example above, the "ActivateTrap" can be written to raise an output such as "OnActivateTrap". This could then be used to hook up events for what happens when this trap activates such as "turn the lights red". Just as an example.
"Wiring" is shown via red lines in the editor window.
On a gameobject you can have any number of CSP-enabled MonoBehaviours. When selecting this gameobject as a target, you'll have the option to choose which script you want, then a list with existing actions is loaded.
And that about sums up what CSP is. A very powerful tool to basically create anything with maximum reusability and minimal code efforts.