Lib.QuickReload 1.1.2

Install-Package Lib.QuickReload -Version 1.1.2
dotnet add package Lib.QuickReload --version 1.1.2
<PackageReference Include="Lib.QuickReload" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lib.QuickReload --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Lib.QuickReload, 1.1.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lib.QuickReload as a Cake Addin
#addin nuget:?package=Lib.QuickReload&version=1.1.2

// Install Lib.QuickReload as a Cake Tool
#tool nuget:?package=Lib.QuickReload&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Rimworld C# Hot Reloader

Lib.QuickReload

Nuget package version Nuget package downloads

By simply adding an attribute to your rimworld C# class, your code is automatically hot-reloaded, meaning that you don't have to close to the game to apply changes. This will save countless hours of waiting over the course of mod development, especially for code that requires many small tweaks such as UI.

Installation

  1. Open your Rimworld mod C# project in Visual Studio.
  2. Right-click on your project, select Manage NuGet Packages...
  3. Search for package Lib.QuickReload by Epicguru and install it.
  4. Rebuild to make sure that it is installed correctly.

Usage

For the mod assembly(s) to be reloaded, you must add the [ReloadAPI.Reloadable] attribute to any class in your mod. I recommend putting it on your main Mod class, but it doesn't really matter where it is. For example:

using Verse;
using ReloaderAPI;

[Reloadable(ReloadBehaviour.All)]
public class Core : Mod
{
    // ... mod code here.
}

There are four possible options for the ReloadBehaviour. There is a slight performance difference between them, but generally All is the best option.

  • ReloadBehaviour.All : Every single method in the assembly can be hot-reloaded. This is the default value.
  • ReloadBehaviour.None : Disables hot reloading.
  • ReloadBehaviour.OnlyWithAttribute : Only methods that have the [Reloadable] attribute can be hot-reloaded.
  • ReloadBehaviour.OnlyWithAttribute : Only methods that do not have the [Reloadable] attribute can be hot-reloaded.

To hot-reload, simply re-build your code. The keyboard shortcut to rebuild is Ctrl+Shift+B. If you have a good project configuration, this should automatically output .dll files to your mod's Assemblies folder. You should immediately see your changes reflected in Rimworld, and a confirmation message. If the game crashes, your probably edited something that isn't allowed (see limitations below).

Limitations

  • You cannot change method signitures.
  • You cannot create new types, methods etc.

Credits

Based closely on the Unity hot reload code written by Zapu.

Uses Mono.Cecil behind the scenes, which I obviously didn't make.

  • .NETFramework 4.7.2

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 148 9/25/2021
1.1.1 71 9/24/2021
1.1.0 72 9/24/2021
1.0.0 71 6/29/2021
0.1.0 83 9/24/2021

Tweaks to public API, not user facing changes.