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 CustomPhoneNumbers v1.0.0
CustomPhoneNumbers.dll
Decompiled 10 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Scoops.misc; using Scoops.service; using Unity.Netcode; 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("CustomPhoneNumbers")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CustomPhoneNumbers")] [assembly: AssemblyTitle("CustomPhoneNumbers")] [assembly: AssemblyVersion("1.0.0.0")] namespace CustomPhoneNumbers; public class Config { public ConfigEntry<int> phoneNumber; public Config(ConfigFile cfg) { phoneNumber = cfg.Bind<int>("General", "PhoneNumber", -1, "Your own personal phone number!!! (wow so hard to make this right) Must be between 0 and 9999. -1 to randomize phone number"); } } [BepInPlugin("mad_sparrow_d2.CustomPhoneNumbers", "CustomPhoneNumbers", "1.0.0")] public class CustomPhoneNumbers : BaseUnityPlugin { [HarmonyPatch(typeof(PhoneNetworkHandler), "CreateNewPhoneNumberServerRpc")] private class Patch_CreateNewPhoneNumberServerRpc { private static bool Prefix(PhoneNetworkHandler __instance, ulong phoneId, string skinId, string charmId, string ringtoneId, ServerRpcParams serverRpcParams) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) short num = (short)config.phoneNumber.Value; ulong senderClientId = serverRpcParams.Receive.SenderClientId; FieldInfo field = typeof(PhoneNetworkHandler).GetField("phoneNumberDict", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PhoneNetworkHandler).GetField("phoneObjectDict", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<short, ulong> dictionary = (Dictionary<short, ulong>)field.GetValue(__instance); Dictionary<short, PhoneBehavior> dictionary2 = (Dictionary<short, PhoneBehavior>)field2.GetValue(__instance); if (num.ToString() == GetSwitchboardNumber() || num < 0 || num > 9999 || dictionary.ContainsKey(num)) { Debug.Log((object)$"[CustomPhoneNumbers] Issue assigning the configured phone number {num}. Generating a random number instead."); return true; } if (!NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(phoneId, out var value)) { Debug.LogError((object)$"[CustomPhoneNumbers] Could not find spawned NetworkObject with ID {phoneId}."); return false; } PhoneBehavior component = ((Component)value).GetComponent<PhoneBehavior>(); if ((Object)(object)component == (Object)null) { Debug.LogError((object)"[CustomPhoneNumbers] Could not find PhoneBehavior component on NetworkObject."); return false; } ((Component)component).GetComponent<NetworkObject>().ChangeOwnership(senderClientId); dictionary[num] = ((NetworkBehaviour)component).NetworkObjectId; dictionary2[num] = component; component.phoneSkinId = skinId; component.phoneCharmId = charmId; component.phoneRingtoneId = ringtoneId; component.SetNewPhoneNumberClientRpc(num); typeof(PhoneNetworkHandler).GetMethod("RequestClientUpdates", BindingFlags.Instance | BindingFlags.Public).Invoke(__instance, null); Debug.Log((object)$"[CustomPhoneNumbers] Assigned phone number {num} successfully."); return false; } } public static Config config; private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown config = new Config(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("mad_sparrow_d2.CustomPhoneNumbers"); val.PatchAll(); Debug.Log((object)"[CustomPhoneNumbers] Patch loaded."); } public static string GetSwitchboardNumber() { Type type = AccessTools.TypeByName("Scoops.Config"); if (type == null) { Debug.LogError((object)"[CustomPhoneNumbers] Could not find type 'Scoops.Config'."); return null; } FieldInfo field = type.GetField("switchboardNumber", BindingFlags.Static | BindingFlags.Public); if (field == null) { Debug.LogError((object)"[CustomPhoneNumbers] Could not find static field 'switchboardNumber' in 'Scoops.Config'."); return null; } if (!(field.GetValue(null) is ConfigEntry<string> val)) { Debug.LogError((object)"[CustomPhoneNumbers] 'switchboardNumber' field is not a ConfigEntry<string> or is null."); return null; } return val.Value; } }