-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Namespace: Not applicable.
Description: This is the file that marks your mod to be loaded, also specifying some of it's attributes. It is required for your mod to function.
Example:
{
"Name": "RL2.API", # Required: The mods display name
"Author": "TacoConKvass", # Optional: The mods author
"Version": "0.2.0", # Required: Version. Must follow the specification outlined in https://semver.org/
"ModAssembly": "RL2.API.dll", # Required: The relative path to the assembly containing this mods code
"LoadAfter": [] # Optional: Which mods should be loaded before this one. Add their display names to the list. If your mod depends on another one, add it to the list.
}
Namespace: None, available everywhere if the project references RL2.ModLoader.dll
Description: By placing this attribute on a type declaration, an object of this type will be created during load and treated as the mods main object. Place your initialization logic in the parameterless constructor of the type.
Example usage:
[ModEntrypoint]
public class TestMod {
public TestMod() {
// Initialization logic
}
}
Namespace: RL2.ModLoader
Description: An event allowing you to run code after the game finishes loading and loading mods is finished.
Example usage:
ModLoader.OnLoad += () => {
// Logic here
}
// OR
ModLoader.OnLoad += SomeMethod;
public void SomeMethod() {
// Logic here
}
Namespace: RL2.ModLoader
Description: An event allowing you to run code before the game unloads all mods.
Example usage:
ModLoader.OnUnload += () => {
// Logic here
}
// OR
ModLoader.OnUnload += SomeOtherMethod;
public void SomeOtherMethod() {
// Logic here
}
Namespace: RL2.ModLoader
Description: By placing this atribute on a static method, that doesn't return anything, invoking this method will be possile in the console opened by pressing the backtick and typing \commandName [arguments]
. We highly recommend prefixing your commands name with your mods name.
Example usage:
[Command("TestMod:TestCommand")] // This command will be callable by typing '\TestMod:TestCommand [arguments]' in the console
public static void TestCommand(string[] args) {
// Command logic
}
Namespace: RL2.ModLoader
Description: Represents a version number, following the semantic versioning schema. Comparison happens via comparing first major version, minor version, patch version, release type and build veriosn in this order. If one comparison has a result, the prevailing comparisons are not made. and the result is returned.
Example usage:
SemVersion version_NoAdditions = new SemVersion(1, 0, 3); // Translates to 1.0.3
SemVersion version_ReleaseType = new SemVersion(1, 0, 3, "alpha"); // Translates to 1.0.3-alpha
SemVersion version_BuildVersion = new SemVersion(1, 0, 3, "alpha", "2ds123"); // Translates to 1.0.3-alpha+2ds123
SemVersion version_BuildVersion_ReleaseType = new SemVersion(1, 0, 4, "", "109712h"); // Translates to 1.0.4+109712h
Console.WriteLine(version_NoAdditions.CompareTo(version_ReleaseType)); // Returns -1: version_NoAdditions is a later version
Console.WriteLine(version_BuildVersion.CompareTo(version_BuildVersion_ReleaseType)); // Returns 1: version_BuildVersion_ReleaseType is a later version (1.0.3 < 1.0.4)
Namespace: Rewired.Utils.Libraries.TinyJson
Description: Prettifies the provided string. Uses tabulation as indentation by default.
Example usage:
string testJson = @"{'ExampleKey':'Value','ExampleArray':['entry1', 'entry2']}";
Console.WriteLine(testJson.Prettify());
/*
Outputs:
{
'ExampleKey': 'Value',
'ExampleArray': [
'entry1',
'entry2'
]
}
*/
Console.WriteLine(testJson.Prettify(" "));
/*
Outputs:
{
'ExampleKey': 'Value',
'ExampleArray': [
'entry1',
'entry2'
]
}
*/
Namespace: RL2.ModLoader
Description: Returns a texture, which has isReadable set to false, in a readable form.
Note: This method is not very performant, so it's best to check if the texture is readable first before calling it.
Example usage:
Texture2D currentTexture = (Texture2D)renderer.material.GetTexture(id);
Color32[] origPixels = currentTexture.GetPixels32(); // Throws an error if the texture has isReadable set to false
Color32[] origPixels2 = currentTexture.ConvertToReadable().GetPixels32(); // Works properly
Namespace: RL2.ModLoader
Description: Loads texture from path. Returns a 1x1 empty texture if file at the path is found not found.
Example usage:
Texture2D texture = TextureExtension.LoadTexture("Path");