C.5 Inside/Outside Hazards

Updated 2 days ago

Code

Editor

[DISCLAIMER]
This page assumes you've correctly setup Unity and followed the steps within the first two pages https://thunderstore.io/c/lethal-company/p/TeamXiaolan/DawnLib/wiki/4097-a-unity-setup/
https://thunderstore.io/c/lethal-company/p/TeamXiaolan/DawnLib/wiki/4099-b2-registering-via-unity-editor/
If you have not finished those steps, finish them and come back to this page.

Make a folder for your moon and inside it add a Registry folder.
In the registry folder right click, hover over create -> DawnLib -> Definitions -> DuskMapObjectDefinition.
Fill in the Namespace field, something like code_rebirth.
Assumes you've made a prefab with how your hazard works, place it inside of the GameObject field.
Also give it a name, something like Air Control Unit, this will also automatically fill in the key of the Namespace at the top.
From there, if it's an inside and/or outside hazard, fill in the settings for how it should spawn, outside currnently only has an option to make the GameObject aligned with the ground so it's not just pointing striaght up if it spawns at a slanted hill (but this is sometimes wanted).

Mess with the Config settings to do with the inside and outside portion of the hazard, if you'd like to give accurate weights please refer to the tool made specifically for this:
https://cosmobrain0.github.io/graph-generation/

[Config+Tool Explanation]
Config follows this structure: MoonName - X1,Y1 ; X2,Y2 ; X3,Y3 | MoonName2 - Etc.....
The separators are:
- for the MoonName and Coordinates
, for the x and y value of a coordinate.
; for separating different coordinates.
| for separating multiple moon entries.
This follows how vanilla spawns hazards on moons accurately, where vanilla generates a number between 0 and 1 and assigns it to the X-axis.
Using that X-axis value, it picks the corresponding Y-value, rounds it to down to an integer (DawnLib rounds to the nearest integer rather than down only), and spawns that amount of hazards.
It's done as a curve so that, depending on luck, you can have days where you spawn almost no hazards and on some days you have Turret Hell on very rare occurance.
Now the linked tool has it's own settings to make creating these graphs and copy pasting them easier.
Starting Y: Defines the minimum amount of the hazard that can spawn.
Ending Y: Defines the maximum amount of the hazard that can spawn.
Samples: How smoothly the curved line is rendered, not something you should change from the default 100.
Output Samples: How many samples are outputted to match the curve, 5 samples means 5 coordinates, the more samples the more accurate your curve config is to the actual curve, 10 is a good recommended amount but can do more.
Output Decimal Places: Defines how many decimal places the output coordinates have, 1 or 2 decimal places is a good default, not necessary to change.
Min Y: Defines the minimum Y that is visually shown to you for the tool.
Max Y: Defines the maximum Y that is visually shown to you for the tool.
Graph Name: Defines what moon you're writing the config for, i.e. Experimentation or magicwesleys_mod:trite
At the very bottom the config string is outputted.
You are also given the option to put in a string and convert that to a graph rather than pressing LMB and RMB to create and remove points on the graph.
Recommended to set Sample Percentage to max when using it as it will potentially skip some samples to simplify the graph if it is less.

Put the DuskMapObjectDefinition and all related assets under an AssetBundle like "aircontrolunitassets".
Include this AssetBundle into the list of AssetBundles in your ContentContainer (made during the Unity Setup page).

Done!

[Remember]
You may always contact @xuxiaolan on discord, whether through the lethal modding discord or DMs for more inquires or any difficulties encountered.