Skip to content

Instantly share code, notes, and snippets.

@egocarib
Created January 22, 2021 23:17
Show Gist options
  • Save egocarib/437c55702401b509d0354e55cff0ac47 to your computer and use it in GitHub Desktop.
Save egocarib/437c55702401b509d0354e55cff0ac47 to your computer and use it in GitHub Desktop.
Example of how to make phase/flight/movement work for submerged effect
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