-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompatibilityChecks.cs
More file actions
80 lines (70 loc) · 2.93 KB
/
Copy pathCompatibilityChecks.cs
File metadata and controls
80 lines (70 loc) · 2.93 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
using Modding;
using System;
using System.Reflection;
using MonoMod.RuntimeDetour;
using MWC = MultiWorldMod.Randomizer.MultiWorldController;
namespace VendorRando {
internal static class CompatibilityChecks {
private static bool ccWarned = false;
public static void Run() {
if(!VendorRando.globalSettings.Any)
return;
if(ModHooks.GetMod("RandoPlus") is Mod) {
CheckRandoPlus();
}
if(ModHooks.GetMod("BugPrince") is Mod) {
CheckBugPrince();
}
if(ModHooks.GetMod("ContainerConfig") is Mod) {
if(!ccWarned) {
ccWarned = true;
throw new VendorCompatibilityWarning();
}
}
}
private static void CheckRandoPlus() {
if(RandoPlus.RandoPlus.GS.FullFlexibleCount) {
throw new VendorCompatibilityException("Full Flexible Count", "RandoPlus", false);
}
if(RandoPlus.RandoPlus.GS.AreaBlitz) {
throw new VendorCompatibilityException("Area Blitz", "RandoPlus", false);
}
}
private static void CheckBugPrince() {
if(BugPrince.BugPrinceMod.RS.MapShop && VendorRando.globalSettings.Iselda) {
throw new VendorCompatibilityException("Map Shop", "BugPrince", true, "Iselda");
}
}
public static void PatchMultiWorld() {
MethodInfo methodToHook = typeof(MWC).GetMethod("InitialMultiSetup", BindingFlags.Public | BindingFlags.Instance);
new Hook(methodToHook, (Action<MWC> orig, MWC self) => {
if(VendorRando.globalSettings.Any)
throw new VendorMultiWorldException();
orig(self);
});
}
}
public class VendorCompatibilityException: Exception {
string setting;
string source;
bool individual;
string vendor;
public VendorCompatibilityException(string setting, string source, bool individual, string vendor = "Iselda") {
this.setting = setting;
this.source = source;
this.individual = individual;
if(individual)
this.vendor = vendor;
}
public override string Message => $"{setting} from {source} is not compatible with " + (individual ? vendor + " from VendorRando" : "VendorRando");
public override string ToString() => Message;
}
public class VendorCompatibilityWarning: Exception {
public override string Message => "ContainerConfig will break VendorRando locations! (Trying again will ignore this warning)";
public override string ToString() => Message;
}
public class VendorMultiWorldException: Exception {
public override string Message => "VendorRando cannot be used in MultiWorld";
public override string ToString() => Message;
}
}