R2Wiki: Risk of Rain 2 Modding Documentation

repository·master·Indexed 41 days ago

https://github.com/risk-of-thunder/r2wiki

A community-maintained documentation hub for Risk of Rain 2 modders. It provides guides on custom character creation using SurvivorAPI, implementing artifacts via ItemModCreationBoilerplate or Thunderkit, and a comprehensive mapping of item internal codes to display names.

Tokens
113.9K
Snippets
216
Records
419
Agent score
51%

What's inside R2Wiki

  1. What is ThunderKit?

    master
    ThunderKit is a Mod development environment designed for creating large-scale content mods for Risk of Rain 2. It focuses heavily on the Assets system, allowing developers to work with both GameObjects and ScriptableObjects. It provides editor tooling that approximates the development environment used by the game's original developers, enabling a more integrated workflow for asset-heavy modding.
  2. What is the DOTS framework in RoR2 modding?

    master

    The Data Oriented Technology Stack (DOTS) is a development philosophy for creating high-performance code using data-oriented programming. In the context of Risk of Rain 2 modding via ThunderKit, two pillars are accessible:

    1. Burst Compiler: Translates IL/.Net bytecode into native CPU code using the LLVM compiler for improved performance.
    2. C# Jobs: Allows for multithreaded code execution for performance-intensive tasks (e.g., complex math, transform modifications) with built-in safety guard rails.

    While the Entity Component System (ECS) is a core part of DOTS, its availability for modding is currently unknown.

  3. What is a ContentPack?

    master

    A ContentPack (found in the RoR2.ContentManagement namespace) is a class that represents a package of content for Risk of Rain 2. It is used by the game's catalog systems to load and manage various assets.

    Common assets included in a ContentPack:

    • ItemDef, EquipmentDef, BuffDef, EffectDef, etc.
    • Body Prefabs
    • Master Prefabs
    • Projectile Prefabs

    Precautions:

    • Unique Naming: Every asset in a ContentPack must have a unique name.
    • No Duplicates: You cannot have duplicate assets (e.g., two identical ItemDefs); doing so will cause the game to crash.
  4. What is UNetWeaver?

    master

    UNetWeaver is a utility that patches NetworkBehaviour components to ensure proper serialization and deserialization of data across the network. It allows developers to use standard Unity Networking (UNet) features outside of the Unity Editor in Risk of Rain 2 mods.

    Key benefits:

    • No user-side dependencies: Users only need your plugin DLL.
    • Native Unity integration: Uses standard using UnityEngine.Networking; syntax.
  5. What is Hooking and Patching?

    master

    Hooking and Patching are techniques used to modify the behavior of .NET assemblies, such as the Risk of Rain 2 codebase, other mods, or Unity's C# components.

    There are two primary frameworks used for this:

    • MonoMod: Uses generated files (e.g., MMHOOK_RoR2.dll) to provide IL and On namespaces, enabling easy method referencing and autocompletion.
    • Harmony: Uses attributes to mark patching code. It does not require generated files and has fewer dependency issues, but requires manual writing of patching signatures as it lacks the autocompletion provided by MonoMod.
  6. What is CIL and how does the stack work?

    master

    Common Intermediate Language (CIL) is the intermediate form produced when C# code is compiled. It is processed by the runtime and converted into machine code.

    CIL operates using a Stack. In this model:

    • Instructions push values onto the stack or pop values off to perform operations.
    • Only the value at the very top of the stack can be popped.
    • Stack Balance: At the point of method termination (ret), the stack must be empty. If instructions or values remain on the stack, the process will terminate with an Invalid ILCode error.
  7. Use TypeInfo for type comparisons

    master

    Reflection provides Type objects that describe assemblies, modules, and types. TypeInfo acts as a unique signature for a type (classes, interfaces, arrays, etc.). You can use typeof() to perform comparisons to ensure an object conforms to a specific type before attempting to invoke methods or access fields.

        var obj = "asdf";
        if(typeof(obj) == typeof(string)) {//true}
  8. Set up the Scene hierarchy (SceneInfo, Director, GameManager)

    master

    A functional stage requires three primary components in its hierarchy:

    1. SceneInfo

    Contains Scene Info (NodeGraphs and MapNodeGroups) and Classic Stage Info (Monster/Interactable DCCs Pools and Director Credits).

    2. Director

    Manages monster and ally spawns. Every stage requires a Network Identity, Director Core, and Scene Director.

    • For stages with monster waves and teleporters, use two Combat Director objects: one for faster/weaker waves and one for slower/stronger waves. The difference lies in the Min Reroll Spawn Interval and Max Reroll Spawn Interval fields.
    • Teleporter Injection: To add a teleporter, use LoP's Addressable Injector component to inject an asset into the Scene Director's Teleporter Spawn Card field.
      • Normal: RoR2/Base/Teleporters/iscTeleporter.asset
      • Lunar: RoR2/Base/Teleporters/iscLunarTeleporter.asset

    3. GameManager

    Must contain a Global Event Manager component. This handles core events like Character Deaths and Level Ups. Without this, the stage is unplayable.

  9. Create Expansion Icons

    master

    Expansion icons appear in the lobby to indicate content from a specific mod or expansion.

    Technical Specifications:

    • Canvas Size: 512 x 512.
    • Unity Import: Because of the larger canvas, you must set Pixels Per Unit to 200.
    • Visual Structure:
      • A primary foreground shape.
      • A translucent detailed background.
      • A transparent background.
      • No canvas border, but an outline around the central shape.

    Design Tips:

    • Maintain color consistency (e.g., if the theme is blue, use blue for the foreground and translucent blue for background details).
    • Translucency: For background details, use an Alpha value between 63 and 186:
      • Brighter colors (Yellow/Blue): Higher Alpha (closer to 186).
      • Bolder colors (Red/Green): Lower Alpha (closer to 63).
  10. Implement Stage RNG with Gates and Toggle Groups

    master

    To create randomized stage elements (like door states or shrine positions), use the Scene Object Toggle Group component.

    1. Scene Object Toggle Group

    Create an empty object (e.g., under SceneInfo) and add the Scene Object Toggle Group component. Add elements to the list, defining a Min Enabled and Max Enabled range for how many objects in that group should be active.

    2. Gates

    To prevent invalid gameplay spaces (e.g., a closed door with a chest behind it), use Gates.

    • Label nodes in your node graph with a Gate Name (found in the Node Group).
    • You can batch-edit names by shift-clicking nodes.

    3. Toggling Gates

    Use specialized components to enable/disable gates based on conditions:

    • Gate State Setter: Enables specific gates if the GameObject is enabled, and disables others.
    • Gate State Setter (Inverse): The opposite of the above.
    • Gate Toggle On Purchase: Used for items like the Fan jump pad. It enables/disables gates when the item is purchased.

    To make a 'switch' (where one gate is on and the other is off), use two Gate State Setter objects on a single GameObject that is controlled by a Scene Object Toggle Group.