Systems - pirate-games/LabRats GitHub Wiki
There are several important systems in the game that you will have to understand before diving into development.
Elements System
The periodic table is vast, containing around 118 elements. These individual elements are incorporated into the project by reading data from a JSON file and passing it on as values to a scriptable object. These scriptable objects are then generated into a file via a file path chosen by the user. If you want to adjust the values, you can adjust them individually in the scriptable objects, or adjust them in the json file then regenerate the scriptable objects via the Assets Tab > Generate Element Files.
A new window will appear where you will have to provide the json file you wish to read, and the filepath where the element objects will be generated. Choosing to overwrite existing files will prevent from potential duplicates being generated whenever you're regenerating the scriptable objects.
These scriptable objects can then be placed on an object that has the "Element Model" script attached. The object will subsequently adopt the element that was assigned to the scriptable object slot. To create a new object with an element not currently present in the scene, you can add an element prefab and switch the scriptable object in the "Element Model" script, and you are good to go.
TriggerDetector
The trigger detector script is a generic script used for detecting objects with a specific component, it sends events in the onTriggerEnter, onTriggerStay and onTriggerExit functions when the correct type is detected. To add new types of detectors, create a new script that inherits from TriggerDetectorT and set the correct type. For example:
NOTE: The new scripts cannot be put into a single file with other TriggerDetectorT classes because of how Unity handles the setting of generic types in the inspector Unity will only show the first generic type in the inspector
Audio System
For this project, we made our own audio system. Whenever adding audio to the game, you will first have to add a new AudioEvent or Composite Effect. You can do that by creating a new asset, choosing Audio > Audio Event or Composite Effect.
Audio Events are used for single SFX events. When creating an AudioEvent Scriptable Object, simply put in the SFX file into the correct slot. You can adjust the volume and pitch for the event.
CompositeAudioEffect is used whenever you want to have an array of SFX to use for a single event in order to add some variety. CompositeAudioEffect has an array where you can drag AudioEvent Scriptable Objects in and also determine the weight of the audio. The weight determines the priority of it being played compared to the other audio events in the array.