Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BaratinhaMatheus v1.0.0
BepInEx/plugins/BaratinhaMatheus/BaratinhaMatheus.dll
Decompiled 5 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BaratinhaMatheus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BaratinhaMatheus")] [assembly: AssemblyTitle("BaratinhaMatheus")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BaratinhaMatheus { internal static class HoarderBugPatch { private static readonly HashSet<int> processadas = new HashSet<int>(); public static void Prefix(HoarderBugAI __instance) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null)) { int instanceID = ((Object)__instance).GetInstanceID(); if (!processadas.Contains(instanceID)) { processadas.Add(instanceID); Plugin.Log.LogWarning((object)"===================================="); Plugin.Log.LogWarning((object)"HOARDING BUG DETECTADA!"); Plugin.Log.LogWarning((object)("BUG POS: " + ((object)((Component)__instance).transform.position/*cast due to .constrained prefix*/).ToString())); Plugin.Log.LogWarning((object)("BUG ROT: " + ((object)((Component)__instance).transform.eulerAngles/*cast due to .constrained prefix*/).ToString())); Plugin.Log.LogWarning((object)"===================================="); CriarMatheus(__instance); } } } private static void CriarMatheus(HoarderBugAI bug) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Expected O, but got Unknown //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.MatheusPrefab == (Object)null) { Plugin.Log.LogError((object)"MatheusPrefab NULL!"); return; } Shader val = Shader.Find("HDRP/Lit"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"HDRP/Lit NULL!"); return; } GameObject val2 = Object.Instantiate<GameObject>(Plugin.MatheusPrefab); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogError((object)"Não consegui instanciar MatheusPrefab!"); return; } ((Object)val2).name = "MATHEUS_RIG_ANIMADO"; val2.SetActive(true); SetLayerRecursive(val2.transform, 22); SkinnedMeshRenderer componentInChildren = val2.GetComponentInChildren<SkinnedMeshRenderer>(true); if ((Object)(object)componentInChildren == (Object)null) { Plugin.Log.LogError((object)"SkinnedMeshRenderer NULL!"); Object.Destroy((Object)(object)val2); return; } if ((Object)(object)componentInChildren.sharedMesh == (Object)null) { Plugin.Log.LogError((object)"sharedMesh NULL!"); Object.Destroy((Object)(object)val2); return; } ((Renderer)componentInChildren).enabled = true; componentInChildren.updateWhenOffscreen = true; ((Renderer)componentInChildren).localBounds = new Bounds(Vector3.zero, new Vector3(20f, 20f, 20f)); Plugin.Log.LogWarning((object)("SMR MATHEUS: " + ((Object)((Component)componentInChildren).gameObject).name)); Plugin.Log.LogWarning((object)("MESH MATHEUS: " + ((Object)componentInChildren.sharedMesh).name)); Plugin.Log.LogWarning((object)("VERTICES MATHEUS: " + componentInChildren.sharedMesh.vertexCount)); Animator componentInChildren2 = val2.GetComponentInChildren<Animator>(true); if ((Object)(object)componentInChildren2 == (Object)null) { Plugin.Log.LogError((object)"ANIMATOR MATHEUS NÃO ENCONTRADO!"); } else { ((Behaviour)componentInChildren2).enabled = true; componentInChildren2.applyRootMotion = false; componentInChildren2.cullingMode = (AnimatorCullingMode)0; Plugin.Log.LogWarning((object)"ANIMATOR MATHEUS ENCONTRADO!"); if ((Object)(object)componentInChildren2.runtimeAnimatorController != (Object)null) { Plugin.Log.LogWarning((object)("CONTROLLER MATHEUS: " + ((Object)componentInChildren2.runtimeAnimatorController).name)); } int num = Animator.StringToHash("Running"); bool flag = componentInChildren2.HasState(0, num); Plugin.Log.LogWarning((object)("Running encontrado: " + flag)); if (flag) { componentInChildren2.Play(num, 0, 0f); componentInChildren2.Update(0f); Plugin.Log.LogWarning((object)"RUNNING INICIADO!"); } } Animator componentInChildren3 = ((Component)bug).GetComponentInChildren<Animator>(true); if ((Object)(object)componentInChildren3 != (Object)null) { ((Behaviour)componentInChildren3).enabled = true; componentInChildren3.cullingMode = (AnimatorCullingMode)0; Plugin.Log.LogWarning((object)("ANIMATOR DA BARATA: " + ((Object)((Component)componentInChildren3).gameObject).name)); if ((Object)(object)componentInChildren3.runtimeAnimatorController != (Object)null) { AnimationClip[] animationClips = componentInChildren3.runtimeAnimatorController.animationClips; Plugin.Log.LogWarning((object)"===== CLIPS DA BARATA ====="); AnimationClip[] array = animationClips; foreach (AnimationClip val3 in array) { if (!((Object)(object)val3 == (Object)null)) { Plugin.Log.LogWarning((object)("CLIP BARATA: " + ((Object)val3).name)); } } Plugin.Log.LogWarning((object)"==========================="); } } else { Plugin.Log.LogWarning((object)"Animator da barata não encontrado."); } Mesh val4 = new Mesh(); ((Object)val4).name = "MATHEUS_ANIMATED_BAKED"; val4.MarkDynamic(); componentInChildren.BakeMesh(val4); val4.RecalculateBounds(); Plugin.Log.LogWarning((object)("BAKED VERTICES: " + val4.vertexCount)); Plugin.Log.LogWarning((object)("BAKED BOUNDS: " + ((object)val4.bounds/*cast due to .constrained prefix*/).ToString())); GameObject val5 = new GameObject("BARATINHA_MATHEUS") { layer = 0 }; MeshFilter val6 = val5.AddComponent<MeshFilter>(); MeshRenderer obj = val5.AddComponent<MeshRenderer>(); val6.sharedMesh = val4; ((Renderer)obj).enabled = true; ((Renderer)obj).forceRenderingOff = false; ((Renderer)obj).allowOcclusionWhenDynamic = false; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; Material[] sharedMaterials = CriarMateriaisHDRP(componentInChildren, val4.subMeshCount, val); ((Renderer)obj).sharedMaterials = sharedMaterials; val5.transform.SetParent((Transform)null); val5.transform.localScale = Vector3.one; val5.transform.position = ((Component)bug).transform.position; val5.transform.rotation = Quaternion.Euler(-90f, ((Component)bug).transform.eulerAngles.y, 0f); MatheusAnimatedFollower matheusAnimatedFollower = val5.AddComponent<MatheusAnimatedFollower>(); matheusAnimatedFollower.target = ((Component)bug).transform; matheusAnimatedFollower.bugAI = bug; matheusAnimatedFollower.sourceRenderer = componentInChildren; matheusAnimatedFollower.rig = val2; matheusAnimatedFollower.bakedMesh = val4; matheusAnimatedFollower.matheusAnimator = componentInChildren2; matheusAnimatedFollower.bugAnimator = componentInChildren3; matheusAnimatedFollower.heightOffset = 0f; matheusAnimatedFollower.yawOffset = 0f; matheusAnimatedFollower.InicializarBoneBridge(); matheusAnimatedFollower.AtualizarAgora(); Renderer[] componentsInChildren = ((Component)bug).GetComponentsInChildren<Renderer>(true); int num2 = 0; Renderer[] array2 = componentsInChildren; foreach (Renderer val7 in array2) { if (!((Object)(object)val7 == (Object)null) && !((Object)((Component)val7).gameObject).name.ToLowerInvariant().Contains("scannode")) { val7.enabled = false; num2++; } } Plugin.Log.LogWarning((object)("Renderers da barata escondidos: " + num2)); Plugin.Log.LogWarning((object)"===================================="); Plugin.Log.LogWarning((object)"=== MATHEUS COMPLETO CRIADO ==="); Plugin.Log.LogWarning((object)"===================================="); } private static Material[] CriarMateriaisHDRP(SkinnedMeshRenderer sourceRenderer, int subMeshCount, Shader hdrpShader) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) Material[] sharedMaterials = ((Renderer)sourceRenderer).sharedMaterials; int num = Mathf.Max(1, subMeshCount); Material[] array = (Material[])(object)new Material[num]; for (int i = 0; i < num; i++) { Material val = null; if (sharedMaterials != null && sharedMaterials.Length != 0) { val = sharedMaterials[Mathf.Min(i, sharedMaterials.Length - 1)]; } Material val2 = new Material(hdrpShader); ((Object)val2).name = "BM_HDRP_MATERIAL_" + i; Texture val3 = null; if ((Object)(object)val != (Object)null) { if (val.HasProperty("_MainTex")) { val3 = val.GetTexture("_MainTex"); } if ((Object)(object)val3 == (Object)null && val.HasProperty("_BaseColorMap")) { val3 = val.GetTexture("_BaseColorMap"); } if ((Object)(object)val3 == (Object)null && (Object)(object)val.mainTexture != (Object)null) { val3 = val.mainTexture; } } if ((Object)(object)val3 != (Object)null && val2.HasProperty("_BaseColorMap")) { val2.SetTexture("_BaseColorMap", val3); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.white); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } Texture val4 = null; if ((Object)(object)val != (Object)null) { if (val.HasProperty("_BumpMap")) { val4 = val.GetTexture("_BumpMap"); } if ((Object)(object)val4 == (Object)null && val.HasProperty("_NormalMap")) { val4 = val.GetTexture("_NormalMap"); } } if ((Object)(object)val4 != (Object)null && val2.HasProperty("_NormalMap")) { val2.SetTexture("_NormalMap", val4); val2.EnableKeyword("_NORMALMAP_TANGENT_SPACE"); } if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", 0f); } if (val2.HasProperty("_Smoothness")) { val2.SetFloat("_Smoothness", 0.2f); } if (val2.HasProperty("_DoubleSidedEnable")) { val2.SetFloat("_DoubleSidedEnable", 1f); } if (val2.HasProperty("_CullMode")) { val2.SetInt("_CullMode", 0); } if (val2.HasProperty("_CullModeForward")) { val2.SetInt("_CullModeForward", 0); } val2.EnableKeyword("_DOUBLESIDED_ON"); array[i] = val2; } return array; } private static void SetLayerRecursive(Transform root, int layer) { ((Component)root).gameObject.layer = layer; for (int i = 0; i < root.childCount; i++) { SetLayerRecursive(root.GetChild(i), layer); } } } internal class MatheusAnimatedFollower : MonoBehaviour { public Transform target; public HoarderBugAI bugAI; public SkinnedMeshRenderer sourceRenderer; public GameObject rig; public Mesh bakedMesh; public Animator matheusAnimator; public Animator bugAnimator; public float heightOffset; public float yawOffset; private bool perseguindoAntes; private float chaseSeed; private bool atacandoAntes; private string ultimoClipBarata = ""; private Transform[] bugBones; private Quaternion[] bugBaseRotations; private Transform[] matheusBones; private Quaternion[] matheusBaseRotations; private bool boneBridgePronto; private static readonly HumanBodyBones[] bonesHumanos; public void InicializarBoneBridge() { //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) chaseSeed = Random.Range(0f, 1000f); if ((Object)(object)target == (Object)null || (Object)(object)matheusAnimator == (Object)null) { Plugin.Log.LogWarning((object)"BoneBridge não pôde ser iniciado."); return; } SkinnedMeshRenderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer val = null; int num = 0; SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val2 in array) { if (!((Object)(object)val2 == (Object)null) && val2.bones != null && val2.bones.Length > num) { num = val2.bones.Length; val = val2; } } if ((Object)(object)val == (Object)null || val.bones == null || val.bones.Length == 0) { Plugin.Log.LogWarning((object)"Bones da barata não encontrados."); return; } Transform[] bones = val.bones; Plugin.Log.LogWarning((object)("BONES DA BARATA: " + bones.Length)); List<Transform> list = new List<Transform>(); List<Transform> list2 = new List<Transform>(); for (int j = 0; j < bonesHumanos.Length; j++) { Transform boneTransform = matheusAnimator.GetBoneTransform(bonesHumanos[j]); if (!((Object)(object)boneTransform == (Object)null)) { Transform val3 = bones[j % bones.Length]; if (!((Object)(object)val3 == (Object)null)) { list.Add(val3); list2.Add(boneTransform); Plugin.Log.LogWarning((object)("MAP CURSED: " + ((Object)val3).name + " -> " + ((object)Unsafe.As<HumanBodyBones, HumanBodyBones>(ref bonesHumanos[j])/*cast due to .constrained prefix*/).ToString())); } } } bugBones = list.ToArray(); matheusBones = list2.ToArray(); bugBaseRotations = (Quaternion[])(object)new Quaternion[bugBones.Length]; matheusBaseRotations = (Quaternion[])(object)new Quaternion[matheusBones.Length]; for (int k = 0; k < bugBones.Length; k++) { bugBaseRotations[k] = bugBones[k].localRotation; matheusBaseRotations[k] = matheusBones[k].localRotation; } boneBridgePronto = bugBones.Length != 0; Plugin.Log.LogWarning((object)("BONE BRIDGE PRONTO: " + boneBridgePronto)); } private void LateUpdate() { AtualizarAgora(); } public void AtualizarAgora() { //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null || (Object)(object)sourceRenderer == (Object)null || (Object)(object)bakedMesh == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } string text = ObterClipAtualDaBarata(); if (text != ultimoClipBarata) { ultimoClipBarata = text; Plugin.Log.LogWarning((object)("CLIP BARATA AGORA: " + (string.IsNullOrEmpty(text) ? "NENHUM" : text))); } bool flag = BarataEstaAtacando(text); if (flag != atacandoAntes) { atacandoAntes = flag; if (flag) { Plugin.Log.LogWarning((object)">>>>>>>> ATAQUE DA BARATA DETECTADO <<<<<<<<"); } else { Plugin.Log.LogWarning((object)">>>>>>>> ATAQUE TERMINOU <<<<<<<<"); } } if (flag && boneBridgePronto) { AplicarPoseDaBarata(); } sourceRenderer.BakeMesh(bakedMesh); bakedMesh.RecalculateBounds(); bool flag2 = (Object)(object)bugAI != (Object)null && ((EnemyAI)bugAI).currentBehaviourStateIndex == 2; if (flag2 != perseguindoAntes) { perseguindoAntes = flag2; if (flag2) { Plugin.Log.LogWarning((object)">>>>>>>> MATHEUS ENTROU EM PERSEGUIÇÃO <<<<<<<<"); } else { Plugin.Log.LogWarning((object)">>>>>>>> MATHEUS SAIU DA PERSEGUIÇÃO <<<<<<<<"); } } if (!flag2) { ((Component)this).transform.position = target.position + Vector3.up * heightOffset; float num = target.eulerAngles.y + yawOffset; ((Component)this).transform.rotation = Quaternion.Euler(-90f, num, 0f); return; } float num2 = Time.time + chaseSeed; float num3 = 0.7f + Mathf.Sin(num2 * 9f) * 0.25f; float num4 = Mathf.Sin(num2 * 14f) * 0.18f; float num5 = Mathf.Cos(num2 * 11f) * 0.12f; float num6 = Mathf.Sin(num2 * 31f) * 0.04f; float num7 = Mathf.Cos(num2 * 27f) * 0.04f; ((Component)this).transform.position = target.position + Vector3.up * num3 + target.right * (num4 + num6) + target.forward * (num5 + num7); float num8 = target.eulerAngles.y + yawOffset; float num9 = Mathf.Sin(num2 * 13f) * 20f; float num10 = Mathf.Cos(num2 * 17f) * 35f; float num11 = Mathf.Sin(num2 * 7f) * 30f; float num12 = Mathf.Sin(num2 * 41f) * 6f; ((Component)this).transform.rotation = Quaternion.Euler(-90f + num9 + num12, num8 + num11, num10 - num12); } private void AplicarPoseDaBarata() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (bugBones == null || matheusBones == null) { return; } int num = Mathf.Min(bugBones.Length, matheusBones.Length); for (int i = 0; i < num; i++) { Transform val = bugBones[i]; Transform val2 = matheusBones[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { Quaternion val3 = val.localRotation * Quaternion.Inverse(bugBaseRotations[i]); val2.localRotation = matheusBaseRotations[i] * val3; } } } private string ObterClipAtualDaBarata() { if ((Object)(object)bugAnimator == (Object)null) { return ""; } AnimatorClipInfo[] currentAnimatorClipInfo = bugAnimator.GetCurrentAnimatorClipInfo(0); if (currentAnimatorClipInfo == null || currentAnimatorClipInfo.Length == 0 || (Object)(object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip == (Object)null) { return ""; } return ((Object)((AnimatorClipInfo)(ref currentAnimatorClipInfo[0])).clip).name; } private bool BarataEstaAtacando(string clipName) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 if ((Object)(object)bugAnimator == (Object)null) { return false; } string text = (string.IsNullOrEmpty(clipName) ? "" : clipName.ToLowerInvariant()); if (text.Contains("attack") || text.Contains("bite") || text.Contains("hit") || text.Contains("strike")) { return true; } AnimatorControllerParameter[] parameters = bugAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { if ((int)val.type != 4) { continue; } string text2 = val.name.ToLowerInvariant(); if (!text2.Contains("attack") && !text2.Contains("bite") && !text2.Contains("hit")) { continue; } try { if (bugAnimator.GetBool(val.nameHash)) { return true; } } catch { } } return false; } private void OnDestroy() { if ((Object)(object)rig != (Object)null) { Object.Destroy((Object)(object)rig); } } static MatheusAnimatedFollower() { HumanBodyBones[] array = new HumanBodyBones[12]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); bonesHumanos = (HumanBodyBones[])(object)array; } } [BepInPlugin("capilitu.baratinhamatheus", "Baratinha Matheus", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static GameObject MatheusPrefab; internal static ManualLogSource Log; private Harmony harmony; private static GameObject watcherObject; private void Awake() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"===================================="); Log.LogInfo((object)"BARATINHA MATHEUS INICIANDO"); Log.LogInfo((object)"===================================="); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "baratinhamatheus"); Log.LogWarning((object)("Bundle: " + text)); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { Log.LogError((object)"ASSETBUNDLE NÃO CARREGOU!"); return; } Log.LogWarning((object)"AssetBundle carregado!"); MatheusPrefab = val.LoadAsset<GameObject>("MatheusReplacement"); if ((Object)(object)MatheusPrefab == (Object)null) { Log.LogError((object)"MatheusReplacement NULL!"); return; } Log.LogWarning((object)"MatheusReplacement encontrado!"); harmony = new Harmony("capilitu.baratinhamatheus.manual"); MethodInfo methodInfo = AccessTools.Method(typeof(HoarderBugAI), "Update", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HoarderBugPatch), "Prefix", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { Log.LogError((object)"NÃO FOI POSSÍVEL MONTAR O PATCH DO HOARDER BUG!"); return; } Log.LogWarning((object)("TARGET ENCONTRADO: " + methodInfo.DeclaringType.FullName + "." + methodInfo.Name)); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogWarning((object)"PATCH MANUAL APLICADO NO UPDATE!"); Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo != null) { Log.LogWarning((object)("PREFIXES NO UPDATE: " + patchInfo.Prefixes.Count)); foreach (Patch prefix in patchInfo.Prefixes) { Log.LogWarning((object)("PATCH OWNER: " + prefix.owner)); } } if ((Object)(object)watcherObject == (Object)null) { watcherObject = new GameObject("BaratinhaMatheus_FallbackWatcher"); Object.DontDestroyOnLoad((Object)(object)watcherObject); watcherObject.AddComponent<BaratinhaMatheusFallbackWatcher>(); Log.LogWarning((object)"FALLBACK WATCHER ATIVADO!"); } Log.LogWarning((object)"===================================="); } } public class BaratinhaMatheusFallbackWatcher : MonoBehaviour { private float proximoScan; private void Update() { if (Time.unscaledTime < proximoScan) { return; } proximoScan = Time.unscaledTime + 0.25f; if ((Object)(object)Plugin.MatheusPrefab == (Object)null) { return; } HoarderBugAI[] array = Object.FindObjectsOfType<HoarderBugAI>(); if (array == null) { return; } HoarderBugAI[] array2 = array; foreach (HoarderBugAI val in array2) { if ((Object)(object)val == (Object)null) { continue; } try { HoarderBugPatch.Prefix(val); if ((Object)(object)((Component)val).GetComponent<BaratinhaMatheusForceChase>() == (Object)null) { ((Component)val).gameObject.AddComponent<BaratinhaMatheusForceChase>().bug = val; } } catch (Exception ex) { Plugin.Log.LogError((object)("ERRO NO FALLBACK WATCHER: " + ex)); } } } } public class BaratinhaMatheusForceChase : MonoBehaviour { public HoarderBugAI bug; private float proximaAtualizacao; private bool logouEntrada; private static readonly FieldInfo WatchingPlayerField = AccessTools.Field(typeof(HoarderBugAI), "watchingPlayer"); private static readonly MethodInfo SetDestinationMethod = AccessTools.Method(typeof(EnemyAI), "SetDestinationToPosition", new Type[2] { typeof(Vector3), typeof(bool) }, (Type[])null); private void Awake() { if ((Object)(object)bug == (Object)null) { bug = ((Component)this).GetComponent<HoarderBugAI>(); } } private void LateUpdate() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bug == (Object)null) { return; } if (((EnemyAI)bug).currentBehaviourStateIndex != 2) { logouEntrada = false; return; } if (!logouEntrada) { logouEntrada = true; Plugin.Log.LogWarning((object)"FORCE CHASE ATIVO!"); } if (Time.unscaledTime < proximaAtualizacao) { return; } proximaAtualizacao = Time.unscaledTime + 0.15f; PlayerControllerB val = EncontrarJogadorMaisProximo(); if ((Object)(object)val == (Object)null) { return; } try { ((EnemyAI)bug).targetPlayer = val; if (WatchingPlayerField != null) { WatchingPlayerField.SetValue(bug, val); } ((EnemyAI)bug).movingTowardsTargetPlayer = true; if (SetDestinationMethod != null) { SetDestinationMethod.Invoke(bug, new object[2] { ((Component)val).transform.position, false }); } else { Plugin.Log.LogError((object)"SetDestinationToPosition NÃO ENCONTRADO!"); } } catch (Exception ex) { Plugin.Log.LogError((object)("ERRO FORCE CHASE: " + ex.GetType().Name + " - " + ex.Message)); } } private PlayerControllerB EncontrarJogadorMaisProximo() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] array = null; if ((Object)(object)StartOfRound.Instance != (Object)null) { array = StartOfRound.Instance.allPlayerScripts; } if (array == null) { array = Object.FindObjectsOfType<PlayerControllerB>(); } PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead) { Vector3 val2 = ((Component)val).transform.position - ((Component)bug).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } } }