-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patch.cs
30 lines (30 loc) · 1.24 KB
/
Patch.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
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
namespace SeamothBrineResist.Patches
{
[HarmonyPatch(typeof(SeaMoth), nameof(SeaMoth.OnUpgradeModuleChange))]
public class SeaMoth_Update_Patch
{
[HarmonyPostfix]
static void Postfix(SeaMoth __instance)
{
var count = __instance.modules.GetCount(Modules.SeamothBrineResistanceModule.TechTypeID); // get the Module count
// convert the DamageSystem.acidImmune array to a list and store it to the acidImmune variable
var acidImmune = DamageSystem.acidImmune == null ? new List<TechType>() : DamageSystem.acidImmune.ToList();
if (count > 0) // if the module is equipped
{
// add the seamoth to the acidImmune list
if (!acidImmune.Contains(TechType.Seamoth))
acidImmune.Add(TechType.Seamoth);
}
else if (count == 0) // if the module isn't equipped
{
// remove the seamoth from the acidImmune list
if (acidImmune.Contains(TechType.Seamoth))
acidImmune.Remove(TechType.Seamoth);
}
DamageSystem.acidImmune = acidImmune.ToArray();
}
}
}