Created
January 22, 2021 23:17
-
-
Save egocarib/437c55702401b509d0354e55cff0ac47 to your computer and use it in GitHub Desktop.
Example of how to make phase/flight/movement work for submerged effect
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))] | |
class Patch_PhaseAndFlightMatches | |
{ | |
[HarmonyPostfix] | |
[HarmonyPatch("PhaseAndFlightMatches")] | |
static void Postfix(GameObject GO, ref GameObject __instance, ref bool __result) | |
{ | |
if (__result == true) | |
{ | |
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