Repository navigation
Developer Guide
The core of any SlugBase character is its SlugBaseCharacter instance. Your mod will create a class that inherits from this, then register it with PlayerManager.RegisterCharacter(SlugBaseCharacter).
Here is a simple example with only abstract members implemented:
public class MySlugcat : SlugBaseCharacter
{
public MySlugcat() : base("My Slugcat", FormatVersion.V1, 0) {}
public override string Description => "My slugcat's description."
protected override void Disable() {}
protected override void Enable() {}
}RegisterCharacter must be called before it appears as an option to select:
PlayerManager.RegisterCharacter(new MySlugcat());After it is registered, a new character called "My Slugcat" will appear on the select screen. It will copy the Survivor's world, as indicated by the 0 in base("My Slugcat", FormatVersion.V1, 0).
Most character-dependent gameplay changes are customizable through virtual members of SlugBaseCharacter:
-
StartRoom: Change where the player starts in a new game. -
GetStats: Change the player's speed, combat skills, etc. -
GetFoodMeter: Change the amount of food used while sleeping and the maximum amount of food stored. -
CanEatMeat: Change whether or not the player can eat most creatures. -
QuarterFood: Change whether or not the player receives 1/4th the food from non-meat sources. -
GatesPermanentlyUnlock: Change whether or not gates stay open for this player like they do for the Monk. -
GetCycleLength: Change the duration of cycles. -
CanSkipTempleGuards: Change whether or not the temple guards are affected by flashbangs. -
HasDreams: Change whether or not dreams appear for this character.
Any other gameplay changes can be made manually, such as through hooks. Any changes made this way should be enabled in your mod's override of SlugBaseCharacter.Enable and disabled in your mod's override of SlugBaseCharacter.Disable. If a change must be applied before the RainWorldGame instance is created, then your changes may be applied in SlugBaseCharacter.Prepare.
Instead of using Enable and Disable, you can check if your modifications should be applied using SlugBaseCharacter.Enabled.
Some character-specific visuals can be changed be overriding members of SlugBaseCharacter:
-
DisplayName: Change this character's name when displayed to the user. -
Description: Change this character's description on the select screen. -
SlugcatColor: Change this character's color in-game and on the UI. -
SlugcatEyeColor: Change this character's eye color in-game.
The core of a SlugBase character's save file is the CustomSaveState class. You may add information on to this by inheriting from CustomSaveState, then overriding SlugBaseCharacter.CreateNewSave to instantiate your new class.
The CustomSaveState has some members you can override to add your own data to the save file:
-
Save: Add values to be saved. -
Load: Load saved values. -
SavePermanent: Add values to be saved that will not be reverted on death. -
LoadPermanent: Load saved values that will not be reverted on death.
Resources, such as images for scenes, are read from files by default. For more information on how they are formatted, see the File Formats guide.
You can change how these resources are loaded by overriding a handful of virtual fields on SlugBaseCharacter:
-
GetResource: Change how the resource stream is acquired, such as loading from embedded resources. -
BuildScene: Change how scenes are loaded, if they must vary from the default format. -
HasScene: Change how a scene's existence is checked for. -
BuildSlideshow: Change how slideshows are loaded, if they must vary from the default format. -
HasSlideshow: Change how a slideshow's existence is checked for.
Menu illustrations can be loaded from a SlugBase character's resources by setting the scene folder to "SlugBase Resources" and the image name to "PlayerName\Folder\AnotherFolder\Image.png". For example, to load an image called "MyImage.png" from the character "ExampleSlugcat":
new Menu.MenuIllustration(menu, owner, "SlugBase Resources", "ExampleSlugcat\\MyImage.png", pos, true, false);-
ArenaAdditions.GetSelectedArenaCharacter: Returns aPlayerDescriptorthat represents the character that will be used in arena mode. -
SlugBaseCharacter.WorldCharacter: Returns the slugcat index used for the world, such as placed object filters and creature spawns. A value of0copies Survivor's world,1copies Monk's, and2copies Hunter's.