-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModCountLabel.cs
More file actions
34 lines (31 loc) · 984 Bytes
/
ModCountLabel.cs
File metadata and controls
34 lines (31 loc) · 984 Bytes
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
29
30
31
32
33
34
using HarmonyLib;
using System.Reflection;
namespace TerrariaInjector
{
public class ModCountLabel
{
public static void Patch(Assembly Terraria, Harmony harmony)
{
_game = Terraria;
harmony.Patch(TargetMethod(), new HarmonyMethod(SymbolExtensions.GetMethodInfo(() => ModCountLabel.Prefix())));
}
private static Assembly _game;
public static void Initialize()
{
GM.Logger.Info(MethodBase.GetCurrentMethod().DeclaringType.Name + " initialized!");
}
static MethodBase TargetMethod()
{
return _game.GetType("Terraria.Main").GetMethod("DrawVersionNumber", BindingFlags.NonPublic | BindingFlags.Static);
}
static void Prefix()
{
string version = (string)_game.GetType("Terraria.Main").GetField("versionNumber").GetValue(null);
if (!version.Contains("Modded!"))
{
version += " - Modded! (" + GM.ModCount + ")";
_game.GetType("Terraria.Main").GetField("versionNumber").SetValue(null, version);
}
}
}
}