using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Unity.VisualScripting; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BLOKBUSTR")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+14bf29381e7b930cac5960f59a85c156c9659526")] [assembly: AssemblyProduct("REPOTweaks")] [assembly: AssemblyTitle("REPOTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace REPOTweaks { [HarmonyPatch(typeof(RunManager))] internal static class RunManagerHook { [HarmonyPostfix] [HarmonyPatch("ChangeLevel")] private static void ChangeLevelPostfix(RunManager __instance, bool _levelFailed) { if (!_levelFailed && !SemiFunc.IsLevelArena(RunManager.instance.levelCurrent)) { EnemyBirthdayBoyPatch.initialized = false; } } } internal class EnemyBirthdayBoySync : MonoBehaviour { internal EnemyBirthdayBoy enemyBirthdayBoy; internal PhotonView photonView; private static readonly int albedoColor = Shader.PropertyToID("_AlbedoColor"); private static readonly int baseColor = Shader.PropertyToID("_BaseColor"); private static readonly int emissionColor = Shader.PropertyToID("_EmissionColor"); internal void SyncColor(int colorIndex) { if (!SemiFunc.IsNotMasterClient()) { photonView.RPC("SyncColorRPC", (RpcTarget)0, new object[1] { colorIndex }); } } [PunRPC] private void SyncColorRPC(int colorIndex, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { SetColor(colorIndex, enemyBirthdayBoy); } } internal static void SetColor(int colorIndex, EnemyBirthdayBoy enemyBirthdayBoy) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) enemyBirthdayBoy.myIndex = colorIndex; if (colorIndex == 0) { REPOTweaks.Debug("Default colorIndex", (Object?)(object)enemyBirthdayBoy); return; } Color val = (enemyBirthdayBoy.balloonColor = enemyBirthdayBoy.colors[colorIndex]); ((Renderer)enemyBirthdayBoy.mr).material.SetColor(albedoColor, val); Material material = ((Renderer)((Component)enemyBirthdayBoy.animatingBalloon).GetComponentInChildren()).material; material.SetColor(baseColor, val); material.SetColor(emissionColor, val * 0.28f); EnemyBirthdayBoyPatch.initialized = true; REPOTweaks.Debug($"Set balloonColor: {val} | index: {colorIndex}", (Object?)(object)enemyBirthdayBoy); } } [HarmonyPatch(typeof(EnemyBirthdayBoy))] internal static class EnemyBirthdayBoyPatch { internal static bool initialized; private static int colorIndex; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(EnemyBirthdayBoy __instance) { REPOTweaks.Debug("AwakePostfix", (Object?)(object)__instance); if (SemiFunc.IsMultiplayer()) { EnemyBirthdayBoySync enemyBirthdayBoySync = ComponentHolderProtocol.AddComponent((Object)(object)__instance); enemyBirthdayBoySync.enemyBirthdayBoy = __instance; enemyBirthdayBoySync.photonView = __instance.photonView; REPOTweaks.Debug("Added EnemyBirthdayBoySync component", (Object?)(object)__instance); } } [HarmonyPrefix] [HarmonyPatch("CheckForDuplicates")] private static bool CheckForDuplicatesPrefix(EnemyBirthdayBoy __instance) { if (SemiFunc.IsNotMasterClient() || !REPOTweaks.configBirthdayBoyRandomizeColors.Value) { return true; } if (!initialized) { colorIndex = Random.Range(0, __instance.colors.Length); REPOTweaks.Debug($"Starting index: {colorIndex}", (Object?)(object)__instance); initialized = true; } if (SemiFunc.IsMultiplayer()) { EnemyBirthdayBoySync component = ((Component)__instance).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { REPOTweaks.Error("EnemyBirthdayBoySync not found! Falling back to vanilla behavior.", (Object?)(object)__instance); return true; } component.SyncColor(colorIndex); } else { EnemyBirthdayBoySync.SetColor(colorIndex, __instance); } colorIndex = ++colorIndex % __instance.colors.Length; return false; } } [HarmonyPatch(typeof(FlatScreenTV))] internal static class FlatScreenTVPatch { [HarmonyPrefix] [HarmonyPatch("BrokenOrNot")] private static void BrokenOrNotPrefix(FlatScreenTV __instance) { if (!__instance.isActive) { float value = REPOTweaks.configArcticTVActiveChance.Value; if (1 == 0) { } bool broken = value <= 0f || (!(value >= 1f) && Random.value > value); if (1 == 0) { } __instance.broken = broken; REPOTweaks.Debug($"broken = {__instance.broken}", (Object?)(object)__instance); } } } [HarmonyPatch(typeof(JackhammerValuable))] internal static class JackhammerValuablePatch { [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(JackhammerValuable __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (REPOTweaks.configJackhammerVoiceTrembleAmount.Value <= 0f || (int)__instance.currentState == 0 || !__instance.physGrabObject.grabbed) { return; } foreach (PhysGrabber item in __instance.physGrabObject.playerGrabbing) { float value = REPOTweaks.configJackhammerCameraShakeAmount.Value; if (value > 0f) { float num = Mathf.Sin(Time.time * REPOTweaks.configJackhammerCameraShakeRate.Value) * value; if (item.isLocal) { CameraAim.Instance.AdditiveAimY(num); } else { item.playerAvatar.playerAvatarVisuals.HeadTiltOverride(num * REPOTweaks.configJackhammerPeerShakeMultiplier.Value); } } if (item.playerAvatar.voiceChatFetched) { item.playerAvatar.voiceChat.OverridePitch(1f, 0.1f, 0.1f, 0.2f, REPOTweaks.configJackhammerVoiceTrembleAmount.Value, REPOTweaks.configJackhammerVoiceTrembleRate.Value); } } } } [HarmonyPatch(typeof(PhysGrabHinge))] internal static class PhysGrabHingePatch { [HarmonyPostfix] [HarmonyPatch("OnJointBreak")] private static void OnJointBreakPostfix(PhysGrabHinge __instance) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsNotMasterClient() && !(REPOTweaks.configHingeBreakEnemyInvestigate.Value <= 0f)) { float value = REPOTweaks.configHingeBreakEnemyInvestigate.Value; EnemyDirector.instance.SetInvestigate(((Component)__instance).transform.position, value, false); REPOTweaks.Debug($"OnJointBreak investigate (radius: {value})", (Object?)(object)__instance); } } } [HarmonyPatch(typeof(ShopKeeper))] internal static class ShopkeeperPatch { [HarmonyPostfix] [HarmonyPatch("ShakeSoundLocalLogic")] private static void ShakeSoundLocalLogicPostfix(ShopKeeper __instance) { if (!(REPOTweaks.configShopkeeperVoiceShakeAmount.Value <= 0f) && __instance.shakeSoundActive && Object.op_Implicit((Object)(object)__instance.playerTarget) && __instance.playerTarget.voiceChatFetched) { __instance.playerTarget.voiceChat.OverridePitch(1f, 0.1f, 0.1f, 0.2f, REPOTweaks.configShopkeeperVoiceShakeAmount.Value, REPOTweaks.configShopkeeperVoiceShakeRate.Value); } } } [BepInPlugin("BLOKBUSTR.REPOTweaks", "REPOTweaks", "1.0.0")] public class REPOTweaks : BaseUnityPlugin { public static ConfigEntry configJackhammerVoiceTrembleAmount; public static ConfigEntry configJackhammerVoiceTrembleRate; public static ConfigEntry configJackhammerCameraShakeAmount; public static ConfigEntry configJackhammerCameraShakeRate; public static ConfigEntry configBirthdayBoyRandomizeColors; public static ConfigEntry configShopkeeperVoiceShakeAmount; public static ConfigEntry configShopkeeperVoiceShakeRate; public static ConfigEntry configArcticTVActiveChance; public static ConfigEntry configHingeBreakEnemyInvestigate; private static ConfigEntry configEnableDebug; internal static ConfigEntry configJackhammerPeerShakeMultiplier; internal static REPOTweaks Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; RegisterConfig(); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); Debug("Debug logging is enabled."); Debug($"{Time.time}"); } private void RegisterConfig() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown configJackhammerVoiceTrembleAmount = ((BaseUnityPlugin)this).Config.Bind("Valuables", "JackhammerVoiceTrembleAmount", 0.035f, new ConfigDescription("The intensity of the voice tremble caused by holding the McJannek Jackhammer valuable. Set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.1f), Array.Empty())); configJackhammerVoiceTrembleRate = ((BaseUnityPlugin)this).Config.Bind("Valuables", "JackhammerVoiceTrembleRate", 70f, new ConfigDescription("The rate of the voice tremble caused by holding the McJannek Jackhammer valuable.", (AcceptableValueBase)(object)new AcceptableValueRange(50f, 100f), Array.Empty())); configJackhammerCameraShakeAmount = ((BaseUnityPlugin)this).Config.Bind("Valuables", "JackhammerCameraShakeAmount", 0.5f, new ConfigDescription("The intensity of the camera shake caused by holding the McJannek Jackhammer valuable. Set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); configJackhammerCameraShakeRate = ((BaseUnityPlugin)this).Config.Bind("Valuables", "JackhammerCameraShakeRate", 60f, new ConfigDescription("The rate of the camera shake caused by holding the McJannek Jackhammer valuable.", (AcceptableValueBase)(object)new AcceptableValueRange(50f, 80f), Array.Empty())); configBirthdayBoyRandomizeColors = ((BaseUnityPlugin)this).Config.Bind("Monsters", "BirthdayBoyRandomizeColors", true, "Whether the colors of Birthday Boy should be randomized instead of defaulting to red for the first instance."); configShopkeeperVoiceShakeAmount = ((BaseUnityPlugin)this).Config.Bind("Shop", "ShopkeeperVoiceShakeAmount", 0.025f, new ConfigDescription("The intensity of the voice tremble caused by being shaken by the Shopkeeper. Set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.1f), Array.Empty())); configShopkeeperVoiceShakeRate = ((BaseUnityPlugin)this).Config.Bind("Shop", "ShopkeeperVoiceShakeRate", 40f, new ConfigDescription("The rate of the voice tremble caused by being shaken by the Shopkeeper.", (AcceptableValueBase)(object)new AcceptableValueRange(20f, 80f), Array.Empty())); configArcticTVActiveChance = ((BaseUnityPlugin)this).Config.Bind("Props", "ArcticTVActiveChance", 0.125f, new ConfigDescription("The probability of the McJannek Station jumpscare TV spawning in its working state. The vanilla probability is 1 in 8.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); configHingeBreakEnemyInvestigate = ((BaseUnityPlugin)this).Config.Bind("Props", "HingeBreakEnemyInvestigate", 8f, new ConfigDescription("Broken hinge objects (doors, chests, cabinets. etc.) will cause enemies to investigate. Adjust this value to set the radius of the investigation trigger, or set to 0 to disable.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 15f), Array.Empty())); configEnableDebug = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableDebug", false, "Whether to enable debug logging. Keep this disabled for normal gameplay."); configJackhammerPeerShakeMultiplier = ((BaseUnityPlugin)this).Config.Bind("Experimental", "JackhammerPeerShakeMultiplier", 50f, new ConfigDescription("The shake intensity multiplier for peer players affected by the McJannek Jackhammer valuable. This will be hard-coded once I find a good value, unless I decide it's better to make it a normal config entry.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 500f), Array.Empty())); } private void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal static void Debug(string message, Object? obj = null) { if (configEnableDebug.Value) { Logger.LogDebug((object)(Object.op_Implicit(obj) ? $"{obj} ({obj.GetInstanceID()}): {message}" : message)); } } internal static void Error(string message, Object? obj = null) { Logger.LogError((object)(Object.op_Implicit(obj) ? $"{obj} ({obj.GetInstanceID()}): {message}" : message)); } } }