-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCalamityCN.cs
More file actions
96 lines (90 loc) · 3.43 KB
/
Copy pathCalamityCN.cs
File metadata and controls
96 lines (90 loc) · 3.43 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria;
using System.Collections.Generic;
using MonoMod.RuntimeDetour;
using System.Reflection;
using System.Linq;
using System;
using ReLogic.Graphics;
namespace CalamityCN
{
public class CalamityCN : Mod
{
// public CalamityCN() { CalamityCN.Instance = this; base.PreJITFilter = new DisableJIT(); }
// internal static CalamityCN Instance;
// private List<Hook> _onHooks;
public override void PostSetupContent()
{
ModLoader.TryGetMod("CalamityMod", out Mod Calamity);
ModLoader.TryGetMod("Wikithis", out Mod wikithis);
if (wikithis != null && !Main.dedServ)
{
wikithis.Call("AddModURL", Calamity, "https://calamity.huijiwiki.com/wiki/{}", GameCulture.CultureName.Chinese);
wikithis.Call(0, Calamity, "https://calamity.huijiwiki.com/wiki/{}", GameCulture.CultureName.Chinese);
}
}
// public override void Load()
// {
// this._onHooks = new List<Hook>();
// foreach (Type type in CalamityCN.Instance.Code.GetTypes())
// {
// if (type.IsSubclassOf(typeof(OnPatcher)))
// {
// OnPatcher onPatcher = Activator.CreateInstance(type) as OnPatcher;
// // TODO: logger
// if (onPatcher != null && onPatcher.AutoLoad)
// {
// this._onHooks.Add(new Hook(onPatcher.ModifiedMethod, onPatcher.Delegate));
// }
// }
// }
// if (this._onHooks.Count > 0)
// {
// foreach (Hook hook in this._onHooks)
// {
// if (hook != null)
// {
// hook.Apply();
// }
// }
// }
// //TODO
// //typeof(LocalizationLoader).GetCachedMethod("Autoload").Invoke(null, new object[] { this });//强制重新加载自己Mod的hjson,因为patch加载在hjson加载后
// }
// public override void Unload()
// {
// Instance = null;
// CalamityCNConfig.Instance = null;
// if (this._onHooks != null)
// {
// foreach (Hook hook in this._onHooks)
// {
// if (hook != null)
// {
// hook.Dispose();
// }
// }
// }
// this._onHooks = null;
// ClearCache();
// }
// public static void ClearCache()
// {
// if (typeof(ReflectionHelper).GetField("AssembliesCache", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is Dictionary<string, WeakReference[]> cache1)
// {
// foreach (var key in cache1.Keys.ToArray())
// {
// cache1.Remove(key);
// }
// }
// if (typeof(ReflectionHelper).GetField("ResolveReflectionCache", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is Dictionary<string, WeakReference> cache2)
// {
// foreach (var key in cache2.Keys.ToArray())
// {
// cache2.Remove(key);
// }
// }
// }
}
}