One way to make your item obtainable is to add it to already existing workbench. Please be aware that each workbench can have AT MOST 18 slots. You cannot exceed this value. As such this approach isn't too scaleable.
To do so add the following code to your IMod
class:
Following snippet makes use of CoreLib library
Please note that values returned by API.Authoring.GetObjectID() are not static and will change between game launches. Do not try to hardcode it or save it.
The CoreLib.Entity submodule is required for this guide section.
CoreLib.Entity submodule allows to easily add custom workbenches. All you have to do is define it via a special Scriptable Object.
Create a new Workbench definition by right clicking in project tab and selecting Create -> CoreLib -> New Workbench Definition
There are following fields to fill out:
Item ID - the same as Object Name in Object Authoring, refer to this
Icons - two sprites the player will see in inventory
Asset Skin - An Asset skin for a workbench, defines how the workbench will look in the world
Recipe - What is required to make the workbench
Can Craft - Most important section. Here you can list everything players will be able to find in the workbench. You can only at most 18 slots!
Related Workbenches - Any workbenches listed here (Modded via Workbench Definition) will be considered related and ingame you will see up and down arrows that allow switching between these.
Titles - Text that will be displayed on top of workbench UI. Must be localized, refer to this
Skin - Visual appearance of workbench UI
Ensure you have added localization texts for your workbench as described here
To create Sprite Asset Skin open create menu and select Create -> 2D -> Sprite Asset Skin
. Assign Target Asset
property. The sprite you want to select is Workbench
, and is bundled with CoreLib Package.
Assign main texture (Emmisive optionally) and three variants textures. Refer to original Sprite Asset for how these should look like.
In order for CoreLib to find your mod workbenches add following code to your IMod
class:
You are done! Now you should see your workbench in CoreLib's Root Workbench, which can be crafted in player inventory.