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 REPOCommunityCode v1.2.0
REPOCommunityCode.dll
Decompiled 12 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using Photon.Pun; using Photon.Realtime; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("bricks04")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+ab8ab2e88be1b04f68012a51e8fcd1bb1296a24f")] [assembly: AssemblyProduct("bricks04.RepoSteamIdJoin")] [assembly: AssemblyTitle("bricks04.RepoSteamIdJoin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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.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; } } [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 RepoSteamIdJoin { [HarmonyPatch(typeof(ChatManager))] public class ChatManagerPatches { [HarmonyPatch("MessageSend")] [HarmonyPrefix] private static bool MessageSendPreFix(ChatManager __instance, bool _possessed) { if (!_possessed) { if (__instance.chatMessage == "/c") { SteamManagerPatches.CopyLobbyId(); return false; } if (__instance.chatMessage == "/clear") { SteamManagerPatches.playerJoinPair.Clear(); return false; } if (__instance.chatMessage == "/track") { SteamManagerPatches.maxPermittableJoins = 1; return false; } if (__instance.chatMessage == "/notrack") { SteamManagerPatches.maxPermittableJoins = 0; return false; } if (Regex.IsMatch(__instance.chatMessage, "^\\/joins\\s[0-9]{1,2}$")) { RepoSteamIdJoin.Logger.LogInfo((object)("Trying to change permittable joins to " + __instance.chatMessage.Substring(7))); if (int.TryParse(__instance.chatMessage.Substring(7), out var result)) { SteamManagerPatches.maxPermittableJoins = result; } else { RepoSteamIdJoin.Logger.LogWarning((object)"Entered value did not parse correctly!"); } return false; } if (__instance.chatMessage == "/truth") { __instance.chatMessage = "Ollie is the cutest!"; return true; } _ = __instance.chatMessage == "balls"; return true; } return true; } } internal static class LateJoinHooks { private delegate void ChangeLevelDetour(Action<RunManager, bool, bool, ChangeLevelType> original, RunManager self, bool completedLevel, bool levelFailed, ChangeLevelType changeLevelType); private delegate void PlayerSpawnDetour(Action<PlayerAvatar, Vector3, Quaternion, bool> original, PlayerAvatar self, Vector3 position, Quaternion rotation, bool debug); private delegate void LevelGeneratorStartDetour(Action<LevelGenerator> original, LevelGenerator self); private delegate void PlayerStartDetour(Action<PlayerAvatar> original, PlayerAvatar self); private static Hook? changeLevelHook; private static Hook? playerSpawnHook; private static Hook? levelGeneratorStartHook; private static Hook? playerStartHook; private static bool installed; private static readonly FieldInfo? removeFilterField = AccessTools.Field(typeof(PhotonNetwork), "removeFilter"); private static readonly FieldInfo? keyByteSevenField = AccessTools.Field(typeof(PhotonNetwork), "keyByteSeven"); private static readonly FieldInfo? serverCleanOptionsField = AccessTools.Field(typeof(PhotonNetwork), "ServerCleanOptions"); private static readonly MethodInfo? raiseEventInternalMethod = AccessTools.Method(typeof(PhotonNetwork), "RaiseEventInternal", (Type[])null, (Type[])null); internal static void Install() { if (installed) { return; } try { changeLevelHook = CreateHook(typeof(RunManager), "ChangeLevel", new ChangeLevelDetour(ChangeLevelHook)); playerSpawnHook = CreateHook(typeof(PlayerAvatar), "Spawn", new PlayerSpawnDetour(PlayerSpawnHook)); levelGeneratorStartHook = CreateHook(typeof(LevelGenerator), "Start", new LevelGeneratorStartDetour(LevelGeneratorStartHook)); playerStartHook = CreateHook(typeof(PlayerAvatar), "Start", new PlayerStartDetour(PlayerStartHook)); installed = true; RepoSteamIdJoin.Logger.LogInfo((object)"Late-join hooks installed (truck intermission joining)."); } catch (Exception arg) { RepoSteamIdJoin.Logger.LogError((object)$"Could not install late-join hooks: {arg}"); DisposeHooks(); } } private static Hook CreateHook(Type type, string methodName, Delegate hook) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(type.FullName, methodName); } return new Hook((MethodBase)methodInfo, hook); } private static void ChangeLevelHook(Action<RunManager, bool, bool, ChangeLevelType> original, RunManager self, bool completedLevel, bool levelFailed, ChangeLevelType changeLevelType) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (levelFailed || !PhotonNetwork.IsMasterClient) { original(self, completedLevel, levelFailed, changeLevelType); return; } try { object obj = AccessTools.Field(typeof(RunManager), "runManagerPUN")?.GetValue(self); PhotonView val = (PhotonView)((obj == null) ? null : /*isinst with value type is only supported in some contexts*/); if ((Object)(object)val != (Object)null) { PhotonNetwork.RemoveBufferedRPCs(val.ViewID, (string)null, (int[])null); } else { RepoSteamIdJoin.Logger.LogWarning((object)"RunManager PhotonView was unavailable while clearing cached join state."); } PhotonView[] array = Object.FindObjectsOfType<PhotonView>(); foreach (PhotonView val2 in array) { if ((Object)(object)val2 != (Object)null) { Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).buildIndex != -1) { ClearPhotonCache(val2); } } } } catch (Exception ex) { RepoSteamIdJoin.Logger.LogWarning((object)("Late-join cache cleanup failed: " + ex.Message)); } original(self, completedLevel, arg3: false, changeLevelType); bool flag = SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsLobby(); SteamLobbyManager instance = SteamLobbyManager.instance; if ((Object)(object)instance != (Object)null) { if (flag) { instance.UnlockLobby(true); } else { instance.LockLobby(); } } if (PhotonNetwork.CurrentRoom != null) { PhotonNetwork.CurrentRoom.IsOpen = flag; } } private static void PlayerSpawnHook(Action<PlayerAvatar, Vector3, Quaternion, bool> original, PlayerAvatar self, Vector3 position, Quaternion rotation, bool debug) { //IL_003c: 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) object obj = AccessTools.Field(typeof(PlayerAvatar), "spawned")?.GetValue(self); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) == 0) { original(self, position, rotation, debug); } } private static void LevelGeneratorStartHook(Action<LevelGenerator> original, LevelGenerator self) { if (PhotonNetwork.IsMasterClient && (SemiFunc.RunIsShop() || SemiFunc.RunIsLobby())) { PhotonNetwork.RemoveBufferedRPCs(self.PhotonView.ViewID, (string)null, (int[])null); } original(self); } private static void PlayerStartHook(Action<PlayerAvatar> original, PlayerAvatar self) { original(self); if ((PhotonNetwork.IsMasterClient || SemiFunc.RunIsLobby()) && SemiFunc.RunIsShop() && (Object)(object)self.photonView != (Object)null) { self.photonView.RPC("LoadingLevelAnimationCompletedRPC", (RpcTarget)3, Array.Empty<object>()); } } private static void ClearPhotonCache(PhotonView view) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) object? obj = removeFilterField?.GetValue(null); Hashtable val = (Hashtable)((obj is Hashtable) ? obj : null); if (val != null && keyByteSevenField?.GetValue(null) is byte b) { object? obj2 = serverCleanOptionsField?.GetValue(null); RaiseEventOptions val2 = (RaiseEventOptions)((obj2 is RaiseEventOptions) ? obj2 : null); if (val2 != null && !(raiseEventInternalMethod == null)) { val[b] = view.InstantiationId; val2.CachingOption = (EventCaching)6; raiseEventInternalMethod.Invoke(null, new object[4] { (byte)202, val, val2, SendOptions.SendReliable }); return; } } throw new MissingMemberException("Photon RPC cache cleanup members are unavailable."); } private static void DisposeHooks() { Hook? obj = changeLevelHook; if (obj != null) { obj.Dispose(); } Hook? obj2 = playerSpawnHook; if (obj2 != null) { obj2.Dispose(); } Hook? obj3 = levelGeneratorStartHook; if (obj3 != null) { obj3.Dispose(); } Hook? obj4 = playerStartHook; if (obj4 != null) { obj4.Dispose(); } changeLevelHook = null; playerSpawnHook = null; levelGeneratorStartHook = null; playerStartHook = null; installed = false; } } [HarmonyPatch(typeof(MenuManager))] public class MenuManagerPatches { public static MenuManager currentInstance; [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostFix(MenuManager __instance) { currentInstance = __instance; RepoSteamIdJoin.Logger.LogInfo((object)currentInstance); } [HarmonyPatch("Update")] [HarmonyPrefix] private static void UpdatePrefix(MenuManager __instance) { if ((Object)(object)currentInstance != (Object)(object)__instance) { currentInstance = __instance; } } public static void GeneratePopUp(string headerText, string bodyText, string buttonText) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) currentInstance.PagePopUp(headerText, Color.yellow, bodyText, buttonText, false); } } [HarmonyPatch(typeof(MenuPageLobby))] public class MenuPageLobbyPatches { private static MenuPageLobby currentInstance; [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostFix(MenuPageLobby __instance) { RepoSteamIdJoin.Logger.LogInfo((object)"MenuPageLobbyPatches started!"); currentInstance = __instance; ChangeChatHelpText("Press <u><b>T</b></u> to chat | Chat <u>/c</u> to copy Lobby ID"); } public static void ChangeChatHelpText(string targetText) { ((TMP_Text)currentInstance.chatPromptText).text = targetText; } [HarmonyPatch("PlayerAdd")] [HarmonyPrefix] private static void PlayerAddPostFix(MenuPageLobby __instance, PlayerAvatar player) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref SteamLobbyManager.instance.currentLobby)).IsOwnedBy(SteamClient.SteamId)) { if (ulong.TryParse(player.steamID, out var result) && !SteamManagerPatches.CheckPlayerJoin(result)) { player.playerName = "<color=#d60e54>" + player.playerName + "</color>"; } } else { RepoSteamIdJoin.Logger.LogInfo((object)"I am not the lobby owner, so no pre-processing player names"); } } } [HarmonyPatch(typeof(MenuPageMain))] public class MenuPageMainPatches { public static AssetBundle HoloCheckUIAssets; public static GameObject holoCheckUI; public static GameObject instantiatedUI; public static GameObject uiTarget; private static int easter; [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostFix() { RepoSteamIdJoin.Logger.LogInfo((object)"MenuPageMainPatches awoken!"); if (ulong.TryParse(GUIUtility.systemCopyBuffer, out var _)) { RepoSteamIdJoin.Logger.LogInfo((object)"Clipboard contains a valid lobby ID."); } else { RepoSteamIdJoin.Logger.LogDebug((object)"Clipboard does not contain a lobby ID."); } } [HarmonyPatch("ButtonEventJoinGame")] [HarmonyPrefix] private static bool ButtonEventJoinGamePreFix() { if (ulong.TryParse(GUIUtility.systemCopyBuffer, out var result)) { RepoSteamIdJoin.Logger.LogInfo((object)"Joining lobby from clipboard lobby ID."); SteamManagerPatches.RequestGameLobbyJoin(result); } else { RepoSteamIdJoin.Logger.LogWarning((object)"Clipboard does not contain a valid lobby ID."); easter++; if (RandomNumberGenerator.GetInt32(99) > 90) { MenuManagerPatches.GeneratePopUp("Balls", "Humongous balls", "Ok"); } else { MenuManagerPatches.GeneratePopUp("ERROR", "Clipboard does not contain a LobbyID", "wait what is this"); } } return false; } } [BepInPlugin("bricks04.RepoSteamIdJoin", "RepoSteamIdJoin", "1.2.0")] public class RepoSteamIdJoin : BaseUnityPlugin { public static string displayedLobbyId = ""; public static ulong joiningId = 0uL; internal static RepoSteamIdJoin Instance { get; private set; } = null; 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; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); LateJoinHooks.Install(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } [HarmonyPatch(typeof(SteamLobbyManager))] public static class SteamManagerPatches { public static string currentLobbyId = string.Empty; public static readonly Dictionary<ulong, int> playerJoinPair = new Dictionary<ulong, int>(); public static int maxPermittableJoins; public static bool CheckPlayerJoin(ulong steamId) { if (maxPermittableJoins <= 0) { return true; } if (playerJoinPair.TryGetValue(steamId, out var value)) { if (value >= maxPermittableJoins) { return false; } playerJoinPair[steamId] = value + 1; } else { playerJoinPair.Add(steamId, 1); } return true; } [HarmonyPatch("OnLobbyCreated")] [HarmonyPostfix] private unsafe static void OnLobbyCreatedPostfix(Result __0, Lobby __1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((int)__0 == 1) { SteamId id = ((Lobby)(ref __1)).Id; if (((SteamId)(ref id)).IsValid) { id = ((Lobby)(ref __1)).Id; currentLobbyId = ((object)(*(SteamId*)(&id))/*cast due to .constrained prefix*/).ToString(); RepoSteamIdJoin.displayedLobbyId = currentLobbyId; RepoSteamIdJoin.Logger.LogInfo((object)"Created lobby; lobby ID is ready to copy."); return; } } RepoSteamIdJoin.Logger.LogWarning((object)"Steam lobby creation did not return a valid lobby ID."); } [HarmonyPatch("LeaveLobby")] [HarmonyPostfix] private static void LeaveLobbyPostfix() { currentLobbyId = string.Empty; RepoSteamIdJoin.displayedLobbyId = string.Empty; playerJoinPair.Clear(); } public static void CopyLobbyId() { if (string.IsNullOrWhiteSpace(currentLobbyId)) { RepoSteamIdJoin.Logger.LogWarning((object)"There is no active lobby ID to copy."); return; } GUIUtility.systemCopyBuffer = currentLobbyId; RepoSteamIdJoin.Logger.LogInfo((object)"Copied the current lobby ID."); } public static void RequestGameLobbyJoin(ulong lobbyId) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (lobbyId == 0L) { RepoSteamIdJoin.Logger.LogWarning((object)"Refusing to join an empty lobby ID."); return; } SteamLobbyManager instance = SteamLobbyManager.instance; if ((Object)(object)instance == (Object)null) { RepoSteamIdJoin.Logger.LogError((object)"SteamLobbyManager is not ready; cannot join lobby."); } else { instance.JoinSteamLobby(new Lobby(SteamId.op_Implicit(lobbyId))); } } } }