using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Photon; using SideLoader; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ImmersiveCustomization")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ImmersiveCustomization")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("215c80fe-e43c-4f33-9d00-af448d901a86")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ImmersiveLinks; [BepInPlugin("com.iggy.immersivecustoms", "Immersive Customization", "2.1")] public class ImmersiveCustoms : BaseUnityPlugin { private const string GUID = "com.iggy.immersivecustoms"; private const string NAME = "Immersive Customization"; private const string VERSION = "2.1"; public static ImmersiveCustoms Instance; internal void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) Instance = this; Debug.Log((object)"Immersive Customization awake"); ((Component)this).gameObject.AddComponent(); new Harmony("com.iggy.immersivecustoms").PatchAll(); } internal void Start() { Debug.Log((object)"Immersive Customs Loaded"); } } public class DodgePlayerManager : MonoBehaviour { [HarmonyPatch(typeof(Character), "HasHit")] public class Character_HasHit { [HarmonyPrefix] public static bool Prefix(Character __instance, Weapon _weapon, float _damage, Vector3 _hitDir, Vector3 _hitPoint, float _angle, bool _blocked, Character _target, float _knockback, int _attackID = -999) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (Instance.PlayerLastHitTimes.ContainsKey(UID.op_Implicit(__instance.UID))) { Instance.PlayerLastHitTimes[UID.op_Implicit(__instance.UID)] = Time.time; } else { Instance.PlayerLastHitTimes.Add(UID.op_Implicit(__instance.UID), Time.time); } return true; } } [HarmonyPatch(typeof(Character), "DodgeInput", new Type[] { typeof(Vector3) })] public class Character_DodgeInput { [HarmonyPrefix] public static bool Prefix(Character __instance, Vector3 _direction) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Invalid comparison between Unknown and I4 //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (__instance.IsAI || !__instance.IsPhotonPlayerLocal) { return true; } float staminaCost = __instance.DodgeStamCost; int num = -22006; int num2 = -2110; if (((CharacterKnowledge)__instance.Inventory.SkillKnowledge).IsItemLearned(num2)) { return false; } if (!((CharacterKnowledge)__instance.Inventory.SkillKnowledge).IsItemLearned(num)) { return true; } float num3 = 0.5f; float num4 = 0.8f; float num5 = 2f; if (Instance.PlayerLastHitTimes.ContainsKey(UID.op_Implicit(__instance.UID)) && Time.time - Instance.PlayerLastHitTimes[UID.op_Implicit(__instance.UID)] < num3) { return false; } HurtType val = (HurtType)At.GetField(__instance, "m_hurtType"); float num6 = num4; if ((int)val == 2) { num6 = num5; } float num7 = (float)At.GetField(__instance, "m_timeOfLastStabilityHit"); if (Time.time - num7 > num6) { val = (HurtType)3; At.SetField(__instance, "m_hurtType", (object)val); } if (!__instance.Dodging && (int)val == 3) { Instance.SendDodge(__instance, staminaCost, _direction); } ((MonoBehaviour)Instance).StartCoroutine(Instance.DodgeLateFix(__instance)); return false; } } [HarmonyPatch(typeof(Character), "AttackInput")] public class Character_AttackInput { public static bool Prefix(Character __instance, int _type, int _id = 0) { bool flag = true; if (__instance.IsLocalPlayer && flag && !__instance.IsAI && __instance.Blocking) { ((MonoBehaviour)Instance).StartCoroutine(Instance.StopBlockingCoroutine(__instance)); At.Invoke(__instance, "StopBlocking", Array.Empty()); At.SetField(__instance, "m_blockDesired", (object)false); } return true; } } public static DodgePlayerManager Instance; private Dictionary PlayerLastHitTimes = new Dictionary(); private ImmersiveCustoms main; internal void Awake() { Instance = this; main = ((Component)this).GetComponent(); Debug.Log((object)"Immersive Customs: Dodge Manager Loaded"); } private IEnumerator DodgeLateFix(Character character) { yield return (object)new WaitForSeconds(0.25f); while (!character.NextIsLocomotion) { yield return null; } At.SetField(character, "m_dodging", (object)false); } private void SendDodge(Character self, float staminaCost, Vector3 _direction) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((float)At.GetField(self.Stats, "m_stamina") >= staminaCost) { self.Stats.UseStamina(TagSourceManager.Dodge, staminaCost, 1f); At.SetField(self, "m_dodgeAllowedInAction", (object)0); if (Object.op_Implicit((Object)(object)self.CharacterCamera) && self.CharacterCamera.InZoomMode) { self.SetZoomMode(false); } self.ForceCancel(false, true); self.ResetCastType(); ((MonoBehaviour)self).photonView.RPC("SendDodgeTriggerTrivial", (PhotonTargets)0, new object[1] { _direction }); At.Invoke(self, "ActionPerformed", new object[1] { false }); ((MonoBehaviour)self).Invoke("ResetDodgeTrigger", 0.1f); } } private IEnumerator StopBlockingCoroutine(Character character) { yield return (object)new WaitForSeconds(0.05f); At.Invoke(character, "StopBlocking", Array.Empty()); At.SetField(character, "m_blockDesired", (object)false); } }