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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Pigeon.Movement; using Unity.Collections; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("StreamerMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0-alpha.0.1+8645477b5755c17b1951565678815beae082759c")] [assembly: AssemblyProduct("StreamerMod")] [assembly: AssemblyTitle("StreamerMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 StreamerMod { [MycoMod(/*Could not decode attribute arguments.*/)] [BepInPlugin("StreamerMod", "StreamerMod", "0.0.0")] public sealed class Plugin : BaseUnityPlugin { private static readonly string[] FirstParts = new string[30] { "Acid", "Amalgam", "Armed", "Binary", "Bongo", "Bruiser", "Bunker", "Caustic", "Crawler", "Engram", "Explosive", "Fungal", "Glider", "Glow", "Heavy", "Hornet", "Incendiary", "Mortar", "Ouro", "Photon", "Planetary", "Railgun", "Rocket", "Saxonite", "Scrap", "Scrapper", "Shock", "Solo", "Turbo", "Voxel" }; private static readonly string[] SecondParts = new string[30] { "Accelerator", "Amalgamation", "Battery", "Beezia", "Bit", "Bomb", "Bot", "Carver", "Core", "Crawler", "Disc", "Drone", "Gear", "Globbler", "Glowungus", "Grenade", "Gunkhouse", "Hornet", "Jukebox", "Lasso", "Ouroboros", "Pigeon", "Railgun", "Roachard", "Salvo", "Saxonite", "Scrapper", "Shocklance", "Trident", "Wrench" }; private static readonly Random Random = new Random(); private Harmony _harmony; private InputActionMap _controls; private InputAction _toggleAction; internal static ManualLogSource Log { get; private set; } = null; internal static string ReplacementName { get; private set; } = "MUSHROOM"; public static bool IsEnabled { get; private set; } = true; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("StreamerMod"); _harmony.PatchAll(); _controls = new InputActionMap("StreamerModControls"); _toggleAction = InputActionSetupExtensions.AddAction(_controls, "toggleStreamerMode", (InputActionType)0, "/F9", (string)null, (string)null, (string)null, (string)null); _toggleAction.performed += OnTogglePerformed; _controls.Enable(); Log.LogInfo((object)"StreamerMod loaded. A name will be generated when you connect."); } private static void OnTogglePerformed(CallbackContext _) { ToggleMod(); } private void OnDestroy() { _toggleAction.performed -= OnTogglePerformed; _controls.Disable(); _controls.Dispose(); } public static void SetEnabled(bool enabled) { if (IsEnabled != enabled) { IsEnabled = enabled; string text = (Online.playerName = (enabled ? GenerateReplacementName() : GetRealPlayerName())); SendNameToServer(text); Log.LogInfo((object)("StreamerMod " + (enabled ? "enabled" : "disabled") + ". Current in-game name: '" + text + "'.")); } } public static void EnableMod() { SetEnabled(enabled: true); } public static void DisableMod() { SetEnabled(enabled: false); } public static void ToggleMod() { SetEnabled(!IsEnabled); } internal static string GenerateReplacementName() { string replacementName = ReplacementName; int num = ((FirstParts.Length * SecondParts.Length <= 1) ? 1 : 8); string text; do { text = FirstParts[Random.Next(FirstParts.Length)] + SecondParts[Random.Next(SecondParts.Length)]; } while (--num > 0 && text == replacementName); ReplacementName = text; Online.playerName = ReplacementName; Log.LogInfo((object)("Generated a new in-game name: '" + ReplacementName + "'.")); return ReplacementName; } private static string GetRealPlayerName() { string text; try { text = Online.GetUserName(); } catch (Exception) { text = "Player"; } if (string.IsNullOrEmpty(text)) { text = "Player"; } if (text.Length > 16) { return text.Substring(0, 16); } return text; } private static void SendNameToServer(string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; if (localPlayer == null) { return; } try { FixedString32Bytes name_ServerRpc = FixedString32Bytes.op_Implicit(name); localPlayer.SetName_ServerRpc(name_ServerRpc); } catch (Exception ex) { Log.LogWarning((object)("Could not apply the name immediately: " + ex.Message)); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "StreamerMod"; public const string PLUGIN_NAME = "StreamerMod"; public const string PLUGIN_VERSION = "0.0.0"; } } namespace StreamerMod.Patches { [HarmonyPatch] internal static class OnlineGetNamePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Online), "GetName", Type.EmptyTypes, (Type[])null); } [HarmonyPostfix] private static void GetName(ref string __result) { if (Plugin.IsEnabled) { __result = Plugin.ReplacementName; } } } [HarmonyPatch] internal static class OnlineGetNetworkNamePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Online), "GetName", new Type[1] { typeof(int) }, (Type[])null); } [HarmonyPrefix] private static void GetNetworkName() { if (Plugin.IsEnabled) { Plugin.GenerateReplacementName(); } } [HarmonyPostfix] private static void GetNetworkName(ref string __result) { if (Plugin.IsEnabled) { __result = Plugin.ReplacementName; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }