forked from tModLoader/tModLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleMod.cs
28 lines (23 loc) · 1.53 KB
/
ExampleMod.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using Terraria.GameContent.UI;
using Terraria.ModLoader;
namespace ExampleMod
{
// This is a partial class, meaning some of its parts were split into other files. See ExampleMod.*.cs for other portions.
public partial class ExampleMod : Mod
{
public const string AssetPath = $"{nameof(ExampleMod)}/Assets/";
public static int ExampleCustomCurrencyId;
public override void Load() {
// Registers a new custom currency
ExampleCustomCurrencyId = CustomCurrencyManager.RegisterCurrency(new Content.Currencies.ExampleCustomCurrency(ModContent.ItemType<Content.Items.ExampleItem>(), 999L, "Mods.ExampleMod.Currencies.ExampleCustomCurrency"));
}
public override void Unload() {
// The Unload() methods can be used for unloading/disposing/clearing special objects, unsubscribing from events, or for undoing some of your mod's actions.
// Be sure to always write unloading code when there is a chance of some of your mod's objects being kept present inside the vanilla assembly.
// The most common reason for that to happen comes from using events, NOT counting On.* and IL.* code-injection namespaces.
// If you subscribe to an event - be sure to eventually unsubscribe from it.
// NOTE: When writing unload code - be sure use 'defensive programming'. Or, in other words, you should always assume that everything in the mod you're unloading might've not even been initialized yet.
// NOTE: There is rarely a need to null-out values of static fields, since TML aims to completely dispose mod assemblies in-between mod reloads.
}
}
}