Last active
January 26, 2021 01:30
-
-
Save egocarib/e86e0df3c59d3f54d5254f3f74151c70 to your computer and use it in GitHub Desktop.
Example of submerged harmony patch with toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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