C. Creating Enemies
Updated 3 weeks agoPreparation
Your mod can only contain one ContentContainer
ScriptableObject, if you've already made one then that's good, but if not then right-click your assets, hover over Create -> CodeRebirthLib -> ContentContainer
Then create a new AssetBundle and name it something like mymodmainassets
, and assign your ContentContainer into that bundle.
Unity Editor Portion
Firstly you'll want to make a folder for your enemy, generally I like to structure my enemy folders like so:
Enemies/MyFirstEnemyName/ -> Animations -> Audio -> Materials/Textures -> Model -> Registry
Rinse and repeat if you're adding multiple enemies.
Before doing anything, create a new AssetBundle on the bottom right, something like enemynameassets
, then click onto your enemy's main folder, i.e. MyFirstEnemyName
and put that folder into the AssetBundle, from there everything inside it is referenced perfectly fine into the AssetBundle automatically.
Inside each folder you put whatever is required into it, i.e. I usually extract the Animation files from the Model file and just put them into the Animations folder for the sake of being able to edit the animations and organisation.
Sound files into the Audio folder, Materials into the Materials folder, Textures inside the Textures folder, etc, etc.
In the Registry Folder, you'll want to right-click and hover over Create -> CodeRebirthLib -> Definitions -> Enemy Definition and press that.
Within the EnemyDefinition you're able to enter in as many ConfigEntries as needed (only accessible via code and maybe JLL? currently).
Then you enter the Entity Name Reference
, this part is very important, I usually just enter the Enemy's own name into that, it's used to match content with eachother when registering.
You also need to enter an EnemyType
, this is the direct reference of your enemy and it contains all the enemy's information.
The TerminalNode
and TerminalKeyword
are available in the case you'd want to create your own bestiary entry, if not an empty one is created so you can leave these empty if you do not care about bestiaries.
Overall you should have something looking like this:
- Folder Structure
- Enemy Definition
Finally, go back to the Content Container and press +
to add a new element for your new enemy, from there fill it in with the name of the AssetBundle, whether it should always be loaded (you can ignore this unless you include VideoClips into your bundle), I tend to put the config name as my enemy's name.
Then press on the Enemies list and press +
again there to add an enemy entry to your AssetBundleData and set it up so it should look something like this:
Code/CSharp Portion
This portion assumes you're using the C# Template for CodeRebirthLib, and if you haven't then do that part first in https://thunderstore.io/c/lethal-company/p/XuXiaolan/CodeRebirthLib/wiki/3731-setting-up-c-template/.
Then you need to create a ContentHandler for your Enemy/Enemies, the way to do this is already detailed in the main README and the C# Template offers an example DefaultContentHandler you can use and after renaming some things it should look something like this: