-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollectMethods.cs
132 lines (125 loc) · 5.58 KB
/
CollectMethods.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using FlipwitchAP.Data;
using HarmonyLib;
using UnityEngine;
namespace FlipwitchAP
{
public class CollectMethods
{
[HarmonyPatch(typeof(ChestLootDrop), "OnEnable")]
[HarmonyPrefix]
private static bool OnEnable_FixSwitchOrCollectOnChestLoot(ChestLootDrop __instance, ref string ___switchName,
ref bool ___dropped, ref bool ___playerWithinZone, ref float ___spawnCountdown)
{
___switchName = ChestSwitchFixer(__instance.name, ___switchName);
___dropped = false;
___playerWithinZone = false;
___spawnCountdown = 0f;
if (!FlipwitchLocations.CoinChestLocations.TryGetValue(___switchName, out var location))
{
return true;
}
if (SwitchDatabase.instance.getInt(___switchName) > 0 || Plugin.ArchipelagoClient.IsLocationChecked(location.APLocationID))
{
___dropped = true;
__instance.GetComponent<Animator>().enabled = false;
__instance.GetComponent<InteractSymbol>().enabled = false;
__instance.GetComponent<PlayAnimationOnInteract>().enabled = false;
}
else
{
__instance.GetComponent<Animator>().enabled = true;
InteractSymbol component = __instance.GetComponent<InteractSymbol>();
__instance.GetComponent<PlayAnimationOnInteract>().enabled = true;
component.enabled = true;
component.resetSymbol();
}
return false;
}
[HarmonyPatch(typeof(ChestItemDrop), "OnEnable")]
[HarmonyPrefix]
private static bool OnEnable_FixSwitchOrCollectOnChestItem(ChestItemDrop __instance, ref string ___switchName,
ref bool ___dropped, ref bool ___playerWithinZone, ref float ___spawnCountdown)
{
___dropped = false;
___playerWithinZone = false;
___spawnCountdown = 0f;
if (!FlipwitchLocations.ChestLocations.TryGetValue(__instance.itemName, out var location))
{
Plugin.Logger.LogInfo($"The switch {__instance.itemName} isn't in the dictionary.");
return true;
}
var isSwitchToggled = SwitchDatabase.instance.getInt(___switchName) > 0;
var isLocationChecked = Plugin.ArchipelagoClient.IsLocationChecked(location.APLocationID);
Plugin.Logger.LogInfo($"Switch Toggled: {isSwitchToggled}, location checked: {isLocationChecked}");
if (isSwitchToggled || isLocationChecked)
{
___dropped = true;
__instance.GetComponent<Animator>().enabled = false;
__instance.GetComponent<InteractSymbol>().enabled = false;
__instance.GetComponent<PlayAnimationOnInteract>().enabled = false;
}
else
{
__instance.GetComponent<Animator>().enabled = true;
InteractSymbol component = __instance.GetComponent<InteractSymbol>();
__instance.GetComponent<PlayAnimationOnInteract>().enabled = true;
component.enabled = true;
component.resetSymbol();
}
return false;
}
[HarmonyPatch(typeof(GachaCoinCollect), "OnEnable")]
[HarmonyPrefix]
private static bool OnEnable_ToggleCoinIfCollected(GachaCoinCollect __instance, ref string ___switchName, ref bool ___collected)
{
___collected = SwitchDatabase.instance.getInt(___switchName) > 0;
if (!FlipwitchLocations.CoinLocations.TryGetValue(___switchName, out var location))
{
return true;
}
if (___collected || Plugin.ArchipelagoClient.IsLocationChecked(location.APLocationID))
{
__instance.gameObject.SetActive(value: false);
}
return false;
}
[HarmonyPatch(typeof(HealthContainerUpgrade), "OnEnable")]
[HarmonyPrefix]
private static bool OnEnable_ToggleHealthHeartIfCollected(HealthContainerUpgrade __instance, ref string ___switchName, ref bool ___collected)
{
if (!FlipwitchLocations.StatLocations.TryGetValue(___switchName, out var location))
{
return true;
}
if (SwitchDatabase.instance.getInt(___switchName) > 0 || Plugin.ArchipelagoClient.IsLocationChecked(location.APLocationID))
{
__instance.gameObject.SetActive(value: false);
___collected = true;
}
return false;
}
[HarmonyPatch(typeof(ManaContainerUpgrade), "OnEnable")]
[HarmonyPrefix]
private static bool OnEnable_ToggleManaHeartIfCollected(HealthContainerUpgrade __instance, ref string ___switchName, ref bool ___collected)
{
if (!FlipwitchLocations.StatLocations.TryGetValue(___switchName, out var location))
{
return true;
}
if (SwitchDatabase.instance.getInt(___switchName) > 0 || Plugin.ArchipelagoClient.IsLocationChecked(location.APLocationID))
{
__instance.gameObject.SetActive(value: false);
___collected = true;
}
return false;
}
public static string ChestSwitchFixer(string chestName, string switchName)
{
if (chestName == "Drop Coins Chest" && switchName == "gc_slime_secret_coins")
{
return "gc_slime_secret_coins_upper";
}
return switchName;
}
}
}