Skip to content

Instantly share code, notes, and snippets.

@egocarib
Last active January 26, 2021 01:30
Show Gist options
  • Save egocarib/e86e0df3c59d3f54d5254f3f74151c70 to your computer and use it in GitHub Desktop.
Save egocarib/e86e0df3c59d3f54d5254f3f74151c70 to your computer and use it in GitHub Desktop.
Example of submerged harmony patch with toggle
using HarmonyLib;
using XRL.World;
namespace WingysMod.HarmonyPatches
{
[HarmonyPatch(typeof(GameObject))]
public class Patch_PhaseAndFlightMatches
{
public static bool TemporarilyDisabled = false;
[HarmonyPostfix]
[HarmonyPatch("PhaseAndFlightMatches")]
static void Postfix(GameObject GO, ref GameObject __instance, ref bool __result)
{
if (__result == true && TemporarilyDisabled == false)
{
if (__instance.IsCreature && GO.IsCreature)
{
bool thisObjectSubmerged = __instance.HasEffect("Submerged");
bool otherObjectSubmerged = GO.HasEffect("Submerged");
if (thisObjectSubmerged || otherObjectSubmerged)
{
bool bothSubmerged = thisObjectSubmerged && otherObjectSubmerged;
if (!bothSubmerged)
{
//change result of "PhaseAndFlightMatches" method to false
__result = false;
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment