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 BaseGameFixes v1.0.2
plugins/BaseGameFixes/BaseGameFixes.dll
Decompiled 12 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using EntityStates; using EntityStates.DefectiveUnit; using EntityStates.SolusWing; using EntityStates.VoidBarnacle; using HG.Reflection; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.Projectile; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BaseGameFixes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7de38b9ece04dbfe92ccce9140f03a5f29b1d3eb")] [assembly: AssemblyProduct("BaseGameFixes")] [assembly: AssemblyTitle("BaseGameFixes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 BaseGameFixes { internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber) { int num = callerPath.LastIndexOf("BaseGameFixes"); if (num >= 0) { callerPath = callerPath.Substring(num + "BaseGameFixes".Length + 1); } return $"{callerPath}:{callerLineNumber} ({callerMemberName}) "; } internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogDebug((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Debug_NoCallerPrefix(object data) { _logSource.LogDebug(data); } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data)); } internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } } [BepInPlugin("Phreel.BaseGameFixes", "BaseGameFixes", "1.0.2")] public class Main : BaseUnityPlugin { public const string PluginGUID = "Phreel.BaseGameFixes"; public const string PluginAuthor = "Phreel"; public const string PluginName = "BaseGameFixes"; public const string PluginVersion = "1.0.2"; private Harmony harmony; internal static Main Instance { get; private set; } public void Awake() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown Instance = this; Log.Init(((BaseUnityPlugin)this).Logger); harmony = new Harmony("Phreel.BaseGameFixes"); harmony.PatchAll(typeof(Main).Assembly); } public void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } } namespace BaseGameFixes.Patches { [HarmonyPatch(typeof(DeathState), "AttemptDeathBehavior")] internal static class DefectiveUnitDeathStateFix { private static readonly Func<GenericCharacterDeath, Transform> getCachedModelTransform = AccessTools.MethodDelegate<Func<GenericCharacterDeath, Transform>>(AccessTools.PropertyGetter(typeof(GenericCharacterDeath), "cachedModelTransform"), (object)null, true); private static bool Prefix(DeathState __instance) { return Object.op_Implicit((Object)(object)getCachedModelTransform((GenericCharacterDeath)(object)__instance)); } } [HarmonyPatch(typeof(DreamDemonProjectileController), "SetGrowthLevel")] internal static class DreamDemonProjectileFix { private static void Prefix(ref Renderer[] ___growthColorRenderers) { if (___growthColorRenderers == null) { ___growthColorRenderers = Array.Empty<Renderer>(); return; } Renderer[] array = ___growthColorRenderers; foreach (Renderer val in array) { if (!Object.op_Implicit((Object)(object)val)) { ___growthColorRenderers = Array.FindAll(___growthColorRenderers, (Renderer r) => Object.op_Implicit((Object)(object)r)); break; } } } } [HarmonyPatch(typeof(DroneCommandReceiver), "DoTargetInfoSearch")] internal static class DroneCommandReceiverChestTargetFix { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(RaycastHit), "collider"); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(Component), "transform"); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(Transform), "position"); MethodInfo methodInfo4 = AccessTools.PropertyGetter(typeof(Component), "gameObject"); MethodInfo methodInfo5 = AccessTools.Method(typeof(DroneCommandReceiverChestTargetFix), "GetChestPosition", (Type[])null, (Type[])null); List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 1; i < list.Count - 2; i++) { if (!CodeInstructionExtensions.Calls(list[i], methodInfo) || !CodeInstructionExtensions.Calls(list[i + 1], methodInfo2) || !CodeInstructionExtensions.Calls(list[i + 2], methodInfo3)) { continue; } CodeInstruction val = null; for (int num = i - 1; num > 0; num--) { if (CodeInstructionExtensions.Calls(list[num], methodInfo4)) { val = list[num - 1]; break; } } if (val == null || !CodeInstructionExtensions.IsLdloc(val, (LocalBuilder)null)) { break; } list[i] = CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(val.opcode, val.operand), list[i]); list[i + 1] = new CodeInstruction(OpCodes.Call, (object)methodInfo5); list.RemoveAt(i + 2); return list; } Log.Warning("Could not find chest target position in DroneCommandReceiver.DoTargetInfoSearch", "D:\\Games\\LostItems\\BaseGameFixes\\BaseGameFixes\\Patches\\DroneCommandReceiverChestTargetFix.cs", "Transpiler", 51); return list; } private static Vector3 GetChestPosition(ref RaycastHit hitInfo, Component chest) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Collider collider = ((RaycastHit)(ref hitInfo)).collider; if (Object.op_Implicit((Object)(object)collider)) { return ((Component)collider).transform.position; } return Object.op_Implicit((Object)(object)chest) ? chest.transform.position : Vector3.zero; } } [HarmonyPatch(typeof(MinionOwnership), "HandleMinionRemoved")] internal static class MinionOwnershipRemovedFix { private static bool Prefix(MinionOwnership minion) { return Object.op_Implicit((Object)(object)minion); } } [HarmonyPatch(typeof(RigidbodySoundOnImpact), "OnCollisionEnter")] internal static class RigidbodySoundOnImpactFix { private static bool Prefix(RigidbodySoundOnImpact __instance, ref Rigidbody ___rb) { if (!Object.op_Implicit((Object)(object)___rb)) { ___rb = ((Component)__instance).GetComponent<Rigidbody>(); } return Object.op_Implicit((Object)(object)___rb); } } [HarmonyPatch(typeof(SetStateOnHurt), "GetModifiedDuration")] internal static class SetStateOnHurtDurationFix { private static void Prefix(SetStateOnHurt __instance, ref AlterBuffDuration[] ___buffDurationControllers) { if (___buffDurationControllers == null) { ___buffDurationControllers = ((Component)__instance).GetComponents<AlterBuffDuration>(); } } } [HarmonyPatch(typeof(SolusWingOverheatBeamBaseState), "UpdateBeamTransforms")] internal static class SolusWingBeamTransformsFix { private static readonly Func<SolusWingOverheatBeamBaseState, GameObject> getBeamVfxInstance = AccessTools.MethodDelegate<Func<SolusWingOverheatBeamBaseState, GameObject>>(AccessTools.PropertyGetter(typeof(SolusWingOverheatBeamBaseState), "beamVfxInstance"), (object)null, true); private static readonly Func<SolusWingOverheatBeamBaseState, Transform> getMuzzleTransform = AccessTools.MethodDelegate<Func<SolusWingOverheatBeamBaseState, Transform>>(AccessTools.PropertyGetter(typeof(SolusWingOverheatBeamBaseState), "muzzleTransform"), (object)null, true); private static bool Prefix(SolusWingOverheatBeamBaseState __instance) { return Object.op_Implicit((Object)(object)getBeamVfxInstance(__instance)) && Object.op_Implicit((Object)(object)getMuzzleTransform(__instance)); } } [HarmonyPatch(typeof(SpecialObjectAttributes), "Start")] internal static class SpecialObjectAttributesStartFix { private static void Prefix(List<GameObject> ___collisionToDisable, List<GameObject> ___objectsToDetach) { ___collisionToDisable?.RemoveAll((GameObject o) => !Object.op_Implicit((Object)(object)o)); ___objectsToDetach?.RemoveAll((GameObject o) => !Object.op_Implicit((Object)(object)o)); } } [HarmonyPatch(typeof(NoCastSpawn), "OnEnter")] internal static class VoidBarnacleSpawnFXFix { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo original = AccessTools.Method(typeof(EffectManager), "SimpleMuzzleFlash", (Type[])null, (Type[])null); MethodInfo replacement = AccessTools.Method(typeof(VoidBarnacleSpawnFXFix), "SafeSimpleMuzzleFlash", (Type[])null, (Type[])null); bool patched = false; foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, original)) { instruction.operand = replacement; patched = true; } yield return instruction; } if (!patched) { Log.Warning("Could not find EffectManager.SimpleMuzzleFlash call in NoCastSpawn.OnEnter", "D:\\Games\\LostItems\\BaseGameFixes\\BaseGameFixes\\Patches\\VoidBarnacleSpawnFXFix.cs", "Transpiler", 32); } } private static void SafeSimpleMuzzleFlash(GameObject effectPrefab, GameObject obj, string muzzleName, bool transmit) { if (Object.op_Implicit((Object)(object)effectPrefab)) { EffectManager.SimpleMuzzleFlash(effectPrefab, obj, muzzleName, transmit); } } } }