-
Notifications
You must be signed in to change notification settings - Fork 37
Adding GameObjects using Asset Classes
As of version 2.0.4, a new set of classes was added to the SMLHelper.V2.Assets
namespace.
These classes were created to greatly simplify the process of adding GameObjects into the game for common use cases.
Depending on the complexity of your GameObject, you may need to include your own custom prefab handling.
There are a few classes you will want to know about
-
Spawnable :
ModPrefab
- Used for any item that can be spawned in the game and could be added to the player's inventory.
- Requires you to handle your own spawning but has optional ability to add to the random spawn table.
-
PdaItem :
Spawable
- Used to add PDA/Scanner data to a Spawnable object.
- Can be used to make Custom Scanner Fragments.
-
Buildable :
PdaItem
- Used for items created using the Habitat Builder
-
CustomFabricator :
Buildable
- Used for easily adding new fabricators into the game with new crafting trees
-
Craftable :
PdaItem
- Used for items created using a fabricator
-
Equipable :
Craftable
- Used for upgrade modules that go into Equipment slots
All these are abstract
classes which all inherit from the ModPrefab class.
What is special about them is that they offer additional abstract
and virtual
properties that will help guide you through all the requirements needed to get your item into the game without missing anything important. Each one adding and building upon what it inherits from to make adding your custom GameObject as simple as we can.
All you do is inherit one of these classes and override as needed.
The class you create will represent the modded prefab for the GameObject in the game.
using SMLHelper.V2.Assets;
internal class MyItem : Craftable
{
// Override all abstract members
// Optionally override any virtual members
}
The Visual Studio/Intellisense documentation will guide you through what each of these abstract
and virtual
are for.
Once you are ready, just call the Patch()
method on an instance of your class to get the ball rolling.
These classes were design to handle all the core patching needed to get a modded GameObject up and running.
[QModCore]
public static class MyMainClass
{
[QModPatch]
public static void MyModPatch()
{
var myItem = new MyItem(); // Create an instance of your class
myItem.Patch(); // Call the Patch method
}
}
Remember: These classes only handle basic functionality. Any other custom behavior or interaction will require that you include the necessary patches or custom code to make sure your item behaves as intended.
If there is something missing or ambiguous, please create an issue or contact us on the Subnautica Modding Discord using our tags:
- PrimeSonic:
@PrimeSonic#0667
- Metious:
@Metious#3682
Please note that some pages are under construction and the links to them will be enabled as they are completed
[Adding]
- Items/GameObjects using Asset Classes
- Asynchronous loading for ModPrefab
- [Custom Scanner Unlocks]
- Items/GameObjects to the Spawning System
- [Recipes to uncraftable items]
- [Custom Mouse Click Actions]
[Editing]
- Background Type
- Crafting Time
- Equipment Type
- Quick Slot Type
- Size in Inventory
- [Recipes for craftable items]
- Harvest Settings
- BioReactor Fuel Values
- [Scanning Count/Time]
- [Spawning (Where/How often/How many)]
[General Utilities]
- In-Game Options Menu
- Adding crafting recipes for other mods items
- Using items from other mods
- Texture/Sprite Utilities
- [Adding/Playing Audio]
- Config Files using Abstract Json Config class
- Custom Console Commands
- [Registering OnSave/OnQuit Actions]
[Language]