namespace Harmony.EAIManagerPatches { [HarmonyPatch(typeof(EAIManager))] [HarmonyPatch("GetType")] public class GetTypePatch { public static bool Prefix(EAIManager __instance, ref System.Type __result, string _className) { switch (_className) { case "ApproachAndAttackTarget": __result = typeof(EAIApproachAndAttackTarget); return false; case "ApproachDistraction": __result = typeof(EAIApproachDistraction); return false; case "ApproachSpot": __result = typeof(EAIApproachSpot); return false; case "BlockIf": __result = typeof(EAIBlockIf); return false; case "BlockingTargetTask": __result = typeof(EAIBlockingTargetTask); return false; case "BreakBlock": __result = typeof(EAIBreakBlock); return false; case "DestroyArea": __result = typeof(EAIDestroyArea); return false; case "Dodge": __result = typeof(EAIDodge); return false; case "Leap": __result = typeof(EAILeap); return false; case "Look": __result = typeof(EAILook); return false; case "RangedAttackTarget": __result = typeof(EAIRangedAttackTarget); return false; case "RangedAttackTarget2": __result = typeof(EAIRangedAttackTarget2); return false; case "RunawayFromEntity": __result = typeof(EAIRunawayFromEntity); return false; case "RunawayWhenHurt": __result = typeof(EAIRunawayWhenHurt); return false; case "SetAsTargetIfHurt": __result = typeof(EAISetAsTargetIfHurt); return false; case "SetNearestCorpseAsTarget": __result = typeof(EAISetNearestCorpseAsTarget); return false; case "SetNearestEntityAsTarget": __result = typeof(EAISetNearestEntityAsTarget); return false; case "TakeCover": __result = typeof(EAITakeCover); return false; case "Territorial": __result = typeof(EAITerritorial); return false; case "Wander": __result = typeof(EAIWander); return false; default: //Log.Warning("EAIManager GetType slow lookup for {0}", (object)_className); __result = System.Type.GetType("EAI" + _className); return false; } return false; } } [HarmonyPatch(typeof(EAIManager))] [HarmonyPatch("CalcSenseScale")] public class CalcSenseScalePatch { public static bool Prefix(EAIManager __instance, ref float __result) { string rebirthFeralSense = RebirthVariables.customFeralSense; int currentDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime); bool randomValid = rebirthFeralSense == "random" && currentDay == RebirthManager.nextFeralSenseDay; if (randomValid && GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 1) { randomValid = false; } if (randomValid && !GameManager.Instance.World.IsDaytime() && RebirthManager.nextFeralSensePeriod == 2) { randomValid = false; } bool isValidFeralSense = (rebirthFeralSense == "always") || (GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "dayonly") || (!GameManager.Instance.World.IsDaytime() && rebirthFeralSense == "nightonly") || randomValid; if (isValidFeralSense) { __result = 1f; return false; } switch (GamePrefs.GetInt(EnumGamePrefs.ZombieFeralSense)) { case 1: if (GameManager.Instance.World.IsDaytime()) { __result = 1f; return false; } break; case 2: if (GameManager.Instance.World.IsDark()) { __result = 1f; return false; } break; case 3: __result = 1f; return false; } __result = 0f; return false; } } }