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 UnityEngine; [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: AssemblyCompany("Kai")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3fdfb87567933f230c30388f481a9b742fa79f04")] [assembly: AssemblyProduct("NoMap")] [assembly: AssemblyTitle("NoMap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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.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 NoMap { [HarmonyPatch(typeof(MapToolController), "Update")] internal static class MapToolController_Update_Patch { private static void Postfix(MapToolController __instance) { if (NoMap.EffectiveEnabled && !((Object)(object)__instance?.DisplayMesh == (Object)null)) { ((Renderer)__instance.DisplayMesh).enabled = false; } } } [HarmonyPatch(typeof(PunManager), "Awake")] internal static class PunManager_Awake_Patch { private static void Postfix(PunManager __instance) { if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] internal static class LevelGenerator_GenerateDone_Patch { private static void Postfix() { NoMap.Instance.ResetToLocal(); if (PhotonNetwork.IsMasterClient) { NoMap.Instance.SendHostSetting(); } } } [BepInPlugin("Kai.NoMap", "NoMap", "2.0.0")] public class NoMap : BaseUnityPlugin { private ConfigEntry _enabledConfig; private bool _localEnabled; private bool _effectiveEnabled; private bool _hostControlled; private bool _suppressConfigChange; internal static NoMap Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal static bool EffectiveEnabled => Instance._effectiveEnabled; private void Awake() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; _enabledConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "NoMapを有効化します。ホストにもNoMapが導入されている場合はホスト設定が優先されます。"); _localEnabled = _enabledConfig.Value; _effectiveEnabled = _localEnabled; _enabledConfig.SettingChanged += OnEnabledSettingChanged; new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded. Enabled={_localEnabled}"); } private void OnEnabledSettingChanged(object sender, EventArgs e) { if (_suppressConfigChange) { return; } if (SemiFunc.IsMainMenu()) { _hostControlled = false; } if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient && _hostControlled) { bool value = _enabledConfig.Value; _suppressConfigChange = true; _enabledConfig.Value = _localEnabled; _suppressConfigChange = false; return; } _localEnabled = _enabledConfig.Value; ApplyEnabled(_localEnabled); if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient) { SendHostSetting(); } } internal void ResetToLocal() { _hostControlled = false; ApplyEnabled(_localEnabled); } internal void ApplyHostSetting(bool enabled) { _hostControlled = true; ApplyEnabled(enabled); } internal void SendHostSetting() { if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && !((Object)(object)PunManager.instance == (Object)null)) { PhotonView component = ((Component)PunManager.instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.RPC("NoMapSyncEnabledRPC", (RpcTarget)1, new object[1] { _localEnabled }); } } } private void ApplyEnabled(bool enabled) { if (_effectiveEnabled != enabled) { _effectiveEnabled = enabled; if (!enabled) { RestoreMapDisplays(); } } } private static void RestoreMapDisplays() { MapToolController[] array = Object.FindObjectsOfType(); foreach (MapToolController val in array) { if ((Object)(object)val?.DisplayMesh != (Object)null) { ((Renderer)val.DisplayMesh).enabled = true; } } } } internal sealed class NoMapRpcReceiver : MonoBehaviour { [PunRPC] private void NoMapSyncEnabledRPC(bool enabled, PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { NoMap.Instance.ApplyHostSetting(enabled); } } } }