-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPlugin.cs
More file actions
94 lines (82 loc) · 2.25 KB
/
Copy pathPlugin.cs
File metadata and controls
94 lines (82 loc) · 2.25 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
using System.Reflection;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using PolyMod.Managers;
using UnityEngine;
namespace PolyMod;
[BepInPlugin("com.polymod", "PolyMod", VERSION)]
public partial class Plugin : BepInEx.Unity.IL2CPP.BasePlugin
{
internal record PolyConfig(
bool debug = false,
bool autoUpdate = true,
bool updatePrerelease = false
);
internal const int AUTOIDX_STARTS_FROM = 1000;
internal const string INCOMPATIBILITY_WARNING_LAST_VERSION_KEY
= "INCOMPATIBILITY_WARNING_LAST_VERSION";
public static readonly string BASE_PATH = Path.Combine(BepInEx.Paths.BepInExRootPath, "..");
public static readonly string MODS_PATH = Path.Combine(BASE_PATH, "Mods");
public static readonly string DUMPED_DATA_PATH = Path.Combine(BASE_PATH, "DumpedData");
internal static readonly string CONFIG_PATH = Path.Combine(BASE_PATH, "PolyMod.json");
internal static readonly string CHECKSUM_PATH
= Path.Combine(BASE_PATH, "CHECKSUM");
internal static readonly string DISCORD_LINK = "https://discord.gg/eWPdhWtfVy";
internal static readonly List<string> LOG_MESSAGES_IGNORE = new()
{
"Failed to find atlas",
"Could not find sprite",
"Couldn't find prefab for type",
"MARKET: id:",
"Missing name for value",
};
#pragma warning disable CS8618
internal static PolyConfig config;
internal static ManualLogSource logger;
#pragma warning restore CS8618
public override void Load()
{
try
{
config = JsonSerializer.Deserialize<PolyConfig>(File.ReadAllText(CONFIG_PATH))!;
}
catch
{
config = new();
}
WriteConfig();
UpdateConsole();
logger = Log;
ConfigFile.CoreConfig[new("Logging.Disk", "WriteUnityLog")].BoxedValue = true;
Compatibility.Init();
Audio.Init();
AutoUpdate.Init();
Loc.Init();
Visual.Init();
Hub.Init();
Main.Init();
}
internal static Stream GetResource(string id)
{
return Assembly.GetExecutingAssembly().GetManifestResourceStream(
$"{typeof(Plugin).Namespace}.resources.{id}"
)!;
}
internal static void WriteConfig()
{
File.WriteAllText(CONFIG_PATH, JsonSerializer.Serialize(config));
}
internal static void UpdateConsole()
{
if (config.debug)
{
ConsoleManager.CreateConsole();
}
else
{
ConsoleManager.DetachConsole();
}
}
}