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 StrangeObjects v1.1.1
BepInEx/plugins/StrangeObjects.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Dissonance.Integrations.Unity_NFGO; using GameNetcodeStuff; using HarmonyLib; using StrangeObjects.Patches; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("StrangeObjects")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("StrangeObjects")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e7e087a1-2426-4476-9b63-af35329e5ac2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace StrangeObjects { [BepInPlugin("Bits.StrangeObjects", "Strange Objects", "1.0.0.0")] public class StrangeObjectsBase : BaseUnityPlugin { private const string modGUID = "Bits.StrangeObjects"; private const string modName = "Strange Objects"; private const string modVersion = "1.0.0.0"; private readonly Harmony harmony = new Harmony("Bits.StrangeObjects"); private static StrangeObjectsBase Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Bits.StrangeObjects"); harmony.PatchAll(typeof(StrangeObjectsBase)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(SpawnScrapInLevelPatch)); harmony.PatchAll(typeof(GrabbleObjectPatch)); harmony.PatchAll(typeof(HUDManagerPatch)); harmony.PatchAll(typeof(NegativeEffectPatch)); harmony.PatchAll(typeof(ShipLeavingPatch)); harmony.PatchAll(typeof(SyncScrapValuesPatch)); } } } namespace StrangeObjects.Patches { [HarmonyPatch(typeof(GrabbableObject))] internal class GrabbleObjectPatch { [HarmonyPatch("SetScrapValue")] [HarmonyPostfix] private static void SubtextPatch(int setValueTo, ref GrabbableObject __instance, ref Item ___itemProperties) { ScanNodeProperties componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>(); if (!((Object)(object)componentInChildren == (Object)null) && (__instance.scrapValue >= 900 || ___itemProperties.batteryUsage >= 900f)) { List<string> list = new List<string> { "Weird", "Bleak", "Grim", "Dark", "Odd", "Evil", "Dreaded", "Spooky", "Eerie", "Haunted", "Freak", "Cruel", "Ghastly", "Gloomy", "Creepy", "Fearful", "Vivid", "Bloody", "Cryptic", "Grave", "Horrid", "Wicked", "Mystic", "Sad", "Lonely", "Angry", "Company" }; if (__instance.scrapValue >= 900) { ___itemProperties.batteryUsage = 999f; GrabbableObject obj = __instance; obj.scrapValue -= 989; } Random random = new Random(__instance.scrapValue + __instance.itemProperties.minValue + __instance.itemProperties.maxValue + (int)__instance.itemProperties.weight); char c = (char)(65 + random.Next(0, 26)); string text = random.Next(0, 10).ToString() + random.Next(0, 10); string text2 = list[random.Next(list.Count)]; string[] array = componentInChildren.headerText.Split(new char[1] { ' ' }); if (array.Length != 0 && !list.Contains(array[0])) { componentInChildren.headerText = list[random.Next(list.Count)] + " " + componentInChildren.headerText; } componentInChildren.subText = $"Value: ${__instance.scrapValue}" + " \nObject: " + c + "-" + text; componentInChildren.scrapValue = __instance.scrapValue; } } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatch { [HarmonyPatch("UpdateScanNodes")] [HarmonyPostfix] private static void SubtextPatch(ref HUDManager __instance, ref TextMeshProUGUI[] ___scanElementText, ref RectTransform[] ___scanElements) { for (int i = 0; i < ___scanElements.Length; i++) { ___scanElementText = ((Component)___scanElements[i]).gameObject.GetComponentsInChildren<TextMeshProUGUI>(); if (___scanElementText.Length <= 1) { continue; } try { string[] array = ((TMP_Text)___scanElementText[1]).text.Split(new char[1] { ' ' }); if (array.Length > 2 && array[2] == "\nObject:") { ((Component)___scanElements[i]).GetComponent<Animator>().SetInteger("colorNumber", 1); } } catch (Exception arg) { Debug.LogError((object)$"Error in updatescanNodes C: {arg}"); } } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class NegativeEffectPatch { [HarmonyPatch("GrabObject")] [HarmonyPostfix] private static void grabObjectPatch(ref bool ___grabInvalidated, ref GrabbableObject ___currentlyGrabbingObject, ref float ___insanityLevel, ref float ___maxSlideFriction) { if (___grabInvalidated) { return; } if (___currentlyGrabbingObject.itemProperties.batteryUsage == 999f || ___currentlyGrabbingObject.itemProperties.batteryUsage == 980f) { Random random = new Random(___currentlyGrabbingObject.scrapValue + ___currentlyGrabbingObject.itemProperties.minValue + ___currentlyGrabbingObject.itemProperties.maxValue + (int)___currentlyGrabbingObject.itemProperties.weight); int num = random.Next(1, 5); float num2 = ___maxSlideFriction; float num3 = -1f * (float)num; if (___currentlyGrabbingObject.itemProperties.batteryUsage == 980f) { ___maxSlideFriction = -4f; } else if ((num3 == -1f && ___maxSlideFriction == -1f) || (num3 == -1f && ___maxSlideFriction == -100f)) { ___maxSlideFriction = -100f; } else if ((num3 == -1f && ___maxSlideFriction == -2f) || (num3 == -2f && ___maxSlideFriction == -1f)) { ___maxSlideFriction = -102f; } else if ((num3 == -2f && ___maxSlideFriction == -100f) || (num3 == -1f && ___maxSlideFriction == -102f)) { ___maxSlideFriction = -1002f; } else if ((num3 == -1f && ___maxSlideFriction == -3f) || (num3 == -3f && ___maxSlideFriction == -1f) || (num3 == -3f && ___maxSlideFriction == -103f)) { ___maxSlideFriction = -103f; } else if ((num3 == -3f && ___maxSlideFriction == -100f) || (num3 == -1f && ___maxSlideFriction == -103f)) { ___maxSlideFriction = -1003f; } else if ((num3 == -2f && ___maxSlideFriction == -103f) || (num3 == -1f && ___maxSlideFriction == -103f) || (num3 == -3f && ___maxSlideFriction == -103f)) { ___maxSlideFriction = -1003f; } else if (num3 == -2f && ___maxSlideFriction == -1003f) { ___maxSlideFriction = -1023f; } else if ((num3 == -2f && ___maxSlideFriction == -3f) || (num3 == -3f && ___maxSlideFriction == -2f)) { ___maxSlideFriction = -203f; } else { ___maxSlideFriction = num3; } if (___maxSlideFriction == -4f) { Random random2 = new Random(); ___currentlyGrabbingObject.scrapValue = random2.Next(___currentlyGrabbingObject.itemProperties.minValue, ___currentlyGrabbingObject.itemProperties.maxValue); ___currentlyGrabbingObject.itemProperties.batteryUsage = 980f; ___maxSlideFriction = num2; } else { ___currentlyGrabbingObject.itemProperties.batteryUsage = 950f; ___insanityLevel = 50f; } } ___currentlyGrabbingObject.SetScrapValue(___currentlyGrabbingObject.scrapValue); } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void addNegativePatch(ref PlayerControllerB __instance, ref float ___sprintMeter, ref float ___maxSlideFriction, ref float ___drunkness, ref float ___movementSpeed) { //IL_0085: 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) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (___maxSlideFriction == -1f || ___maxSlideFriction == -103f || ___maxSlideFriction == -102f) { ___drunkness = 0.2f; } if (___maxSlideFriction == -100f || ___maxSlideFriction == -1002f || ___maxSlideFriction == -1003f || ___maxSlideFriction == -1023f) { ___drunkness = 1f; } if (___maxSlideFriction == -2f || ___maxSlideFriction == -102f) { __instance.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); if (___maxSlideFriction == -102f) { ___maxSlideFriction = -1f; } else { ___maxSlideFriction = 0f; } } if (___maxSlideFriction == -203f || ___maxSlideFriction == -1002f || ___maxSlideFriction == -1023f) { __instance.DamagePlayer(90, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); if (___maxSlideFriction == -203f) { ___maxSlideFriction = -3f; } else if (___maxSlideFriction == -1002f) { ___maxSlideFriction = -100f; } else if (___maxSlideFriction == -1023f) { ___maxSlideFriction = -1003f; } } if (___maxSlideFriction == -3f || ___maxSlideFriction == -103f || ___maxSlideFriction == -1003f) { ___movementSpeed = 2.3f; } } } [HarmonyPatch(typeof(ElevatorAnimationEvents))] internal class ShipLeavingPatch { [HarmonyPatch("ElevatorFullyRunning")] [HarmonyPostfix] private static void adjustMaxSlideFrictionPatch(ref ElevatorAnimationEvents __instance) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { GameNetworkManager.Instance.localPlayerController.drunkness = 0f; GameNetworkManager.Instance.localPlayerController.movementSpeed = 4.6f; GameNetworkManager.Instance.localPlayerController.maxSlideFriction = 0f; } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal class SpawnScrapInLevelPatch { private static FieldInfo f_someField = AccessTools.Field(typeof(GrabbableObject), "fallTime"); private static FieldInfo f_someField_2 = AccessTools.Field(typeof(GrabbableObject), "scrapValue"); private static FieldInfo f_someField_3 = AccessTools.Field(typeof(GrabbableObject), "itemProperties"); private static FieldInfo f_someField_4 = AccessTools.Field(typeof(Item), "batteryUsage"); private static FieldInfo f_someField_5 = AccessTools.Field(typeof(RoundManager), "scrapValueMultiplier"); private static MethodInfo m_randomChance = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => randomChance())); private static MethodInfo m_listCount = typeof(List<int>).GetProperty("Count").GetGetMethod(); private static MethodInfo m_listGet = typeof(List<int>).GetProperty("Item").GetGetMethod(); private static MethodInfo m_listSet = typeof(List<int>).GetProperty("Item").GetSetMethod(); private static MethodInfo getComponentGenericMethod = AccessTools.Method(typeof(Component), "GetComponent", new Type[0], (Type[])null); private static MethodInfo m_component = getComponentGenericMethod.MakeGenericMethod(typeof(GrabbableObject)); private static int randomChance() { Random random = new Random(); int result = 0; if (random.Next(0, 100) < 10) { result = 1; } return result; } private static IEnumerable<CodeInstruction> Transpiler(ILGenerator generator, IEnumerable<CodeInstruction> instructions) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Expected O, but got Unknown //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Expected O, but got Unknown //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Expected O, but got Unknown //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Expected O, but got Unknown //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); bool flag = false; bool flag2 = false; Label label = generator.DefineLabel(); Label label2 = generator.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.StoresField(list[i], f_someField) && !flag) { list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null) { labels = new List<Label> { label } }); list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_R4, (object)0.3f)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Stloc_S, (object)5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_randomChance)); flag = true; } if (CodeInstructionExtensions.StoresField(list[i], f_someField_2) && !flag2) { list.Insert(i + 1, new CodeInstruction(OpCodes.Nop, (object)null) { labels = new List<Label> { label2 } }); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listSet)); list.Insert(i + 1, new CodeInstruction(OpCodes.Add, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)999)); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listGet)); list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Callvirt, (object)m_listCount)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Stfld, (object)f_someField_5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Sub, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_R4, (object)0.3f)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldfld, (object)f_someField_5)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(i + 1, new CodeInstruction(OpCodes.Beq_S, (object)label2)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldc_I4, (object)0)); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldloc_S, (object)5)); flag2 = true; } } return list; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal class SyncScrapValuesPatch { [HarmonyPostfix] private static void fixScrapTotalPatch(int[] allScrapValue, ref float ___totalScrapValueInLevel) { int num = 0; if (allScrapValue != null) { for (int i = 0; i < allScrapValue.Length; i++) { num = ((allScrapValue[i] < 900) ? (num + allScrapValue[i]) : (num + (allScrapValue[i] - 989))); } } ___totalScrapValueInLevel = num; } } [HarmonyPatch(typeof(StartOfRound))] internal class VoiceRefreshPatch { [HarmonyPatch("RefreshPlayerVoicePlaybackObjects")] [HarmonyPostfix] private static void addMufflePatch(ref PlayerControllerB[] ___allPlayerScripts) { if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return; } PlayerVoiceIngameSettings[] array = Object.FindObjectsOfType<PlayerVoiceIngameSettings>(true); for (int i = 0; i < ___allPlayerScripts.Length; i++) { PlayerControllerB val = ___allPlayerScripts[i]; if (!val.isPlayerControlled && !val.isPlayerDead) { continue; } for (int j = 0; j < array.Length; j++) { if (array[j]._playerState == null) { array[j].FindPlayerIfNull(); if (array[j]._playerState != null) { } } else if (((Behaviour)array[j]).isActiveAndEnabled && array[j]._playerState.Name == ((Component)val).gameObject.GetComponentInChildren<NfgoPlayer>().PlayerId) { val.voicePlayerState = array[j]._playerState; val.currentVoiceChatAudioSource = array[j].voiceAudio; val.currentVoiceChatIngameSettings = array[j]; val.currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[val.playerClientId]; if (GameNetworkManager.Instance.localPlayerController.maxSlideFriction != -3f && GameNetworkManager.Instance.localPlayerController.maxSlideFriction != -103f && GameNetworkManager.Instance.localPlayerController.maxSlideFriction != -1003f) { ((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 1f; OccludeAudio component = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>(); component.overridingLowPass = false; component.lowPassOverride = 20000f; val.voiceMuffledByEnemy = false; } else { ((Component)val.currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>().lowpassResonanceQ = 5f; OccludeAudio component2 = ((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>(); component2.overridingLowPass = true; component2.lowPassOverride = 500f; Debug.Log((object)$"Applied Muffle to player voice object #{j} and player object #{i}"); val.voiceMuffledByEnemy = true; } } } } } } }