using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Managing.Logging;
using FishNet.Managing.Server;
using FishNet.Object;
using FishNet.Serializing;
using FishNet.Transporting;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[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("ArceDev.GameModeCore")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+bcd55e01063db96f81256e16fe63959268eda417")]
[assembly: AssemblyProduct("ArceDev.GameModeCore")]
[assembly: AssemblyTitle("Game Mode Core")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace GameModeCore
{
public enum GameModeStartupPolicy : byte
{
Native,
Managed
}
public sealed class GameModeDefinition
{
public string Id { get; }
public string DisplayName { get; }
public int NetworkVersion { get; }
public GameModeStartupPolicy StartupPolicy { get; }
public GameModeDefinition(string id, string displayName, int networkVersion = 1, GameModeStartupPolicy startupPolicy = GameModeStartupPolicy.Native)
{
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("A mode identifier is required.", "id");
}
if (string.IsNullOrWhiteSpace(displayName))
{
throw new ArgumentException("A display name is required.", "displayName");
}
if (networkVersion < 1)
{
throw new ArgumentOutOfRangeException("networkVersion");
}
if (!Enum.IsDefined(typeof(GameModeStartupPolicy), startupPolicy))
{
throw new ArgumentOutOfRangeException("startupPolicy");
}
Id = id;
DisplayName = displayName;
NetworkVersion = networkVersion;
StartupPolicy = startupPolicy;
}
}
public static class GameModeApi
{
public const string ClassicModeId = "ArceDev.GameModeCore.Classic";
private static readonly List<GameModeDefinition> Ordered;
private static readonly Dictionary<string, GameModeDefinition> Definitions;
private static readonly ReadOnlyCollection<GameModeDefinition> ReadOnlyModes;
private static string _selectedModeId;
private static string? _blockedReason;
public static IReadOnlyList<GameModeDefinition> Modes => ReadOnlyModes;
public static string ActiveModeId { get; private set; }
public static GameModeDefinition? ActiveMode => Get(ActiveModeId);
public static bool IsManagedStartupReady { get; private set; }
internal static string SelectedModeId => _selectedModeId;
public static event Action? ActiveModeChanged;
public static event Action? ManagedStartupReady;
static GameModeApi()
{
Ordered = new List<GameModeDefinition>();
Definitions = new Dictionary<string, GameModeDefinition>(StringComparer.Ordinal);
ReadOnlyModes = Ordered.AsReadOnly();
_selectedModeId = "ArceDev.GameModeCore.Classic";
ActiveModeId = "ArceDev.GameModeCore.Classic";
Add(new GameModeDefinition("ArceDev.GameModeCore.Classic", "Classic"));
}
public static void Register(GameModeDefinition definition)
{
if (definition == null)
{
throw new ArgumentNullException("definition");
}
if (definition.Id == "ArceDev.GameModeCore.Classic")
{
throw new InvalidOperationException("The built-in Classic mode cannot be replaced.");
}
Add(definition);
if (ActiveModeId == definition.Id)
{
_blockedReason = null;
GameModeApi.ActiveModeChanged?.Invoke();
}
GameModeUi.Refresh();
}
public static bool IsActive(string modeId)
{
if (Get(ActiveModeId) != null)
{
return string.Equals(ActiveModeId, modeId, StringComparison.Ordinal);
}
return false;
}
public static bool TryGet(string modeId, out GameModeDefinition definition)
{
return Definitions.TryGetValue(modeId, out definition);
}
public static bool IsClientValidated(int clientId)
{
return GameModeNetwork.IsClientValidated(clientId);
}
public static void StartManagedGameplay()
{
GameModeNetwork.StartManagedGameplay();
}
internal static void Select(string modeId)
{
if (!Definitions.ContainsKey(modeId))
{
throw new KeyNotFoundException("Game mode '" + modeId + "' is not registered.");
}
_selectedModeId = modeId;
GameModeUi.Refresh();
}
internal static void SelectClassic()
{
Select("ArceDev.GameModeCore.Classic");
}
internal static void Activate(string modeId, string? blockedReason = null)
{
bool flag = !string.Equals(ActiveModeId, modeId, StringComparison.Ordinal) || _blockedReason != blockedReason;
ActiveModeId = modeId;
_blockedReason = blockedReason ?? (Definitions.ContainsKey(modeId) ? null : ("Required game mode '" + modeId + "' is not installed."));
if (Definitions.ContainsKey(modeId))
{
_selectedModeId = modeId;
}
IsManagedStartupReady = false;
if (flag)
{
GameModeApi.ActiveModeChanged?.Invoke();
}
GameModeUi.Refresh();
}
internal static bool CanStart(out string reason)
{
reason = _blockedReason ?? "";
if (reason.Length == 0)
{
return Definitions.ContainsKey(ActiveModeId);
}
return false;
}
internal static GameModeDefinition? Get(string id)
{
if (!Definitions.TryGetValue(id, out GameModeDefinition value))
{
return null;
}
return value;
}
internal static void NotifyManagedStartupReady()
{
IsManagedStartupReady = true;
GameModeApi.ManagedStartupReady?.Invoke();
}
internal static void ResetManagedStartup()
{
IsManagedStartupReady = false;
}
internal static void Validate()
{
GameModeDefinition gameModeDefinition = new GameModeDefinition("test.native", "Native");
GameModeDefinition gameModeDefinition2 = new GameModeDefinition("test.managed", "Managed", 1, GameModeStartupPolicy.Managed);
if (gameModeDefinition.StartupPolicy != GameModeStartupPolicy.Native || gameModeDefinition2.StartupPolicy != GameModeStartupPolicy.Managed)
{
throw new InvalidOperationException("Game mode startup policy validation failed.");
}
}
private static void Add(GameModeDefinition definition)
{
if (!Definitions.TryAdd(definition.Id, definition))
{
throw new InvalidOperationException("Game mode '" + definition.Id + "' is already registered.");
}
Ordered.Add(definition);
}
}
internal readonly record struct ModeHello(string[] ModeIds, int[] NetworkVersions) : IBroadcast;
internal readonly record struct ModeReply(string ModeId, int NetworkVersion, bool Accepted, string Message) : IBroadcast;
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal readonly record struct ManagedGameplayStart : IBroadcast;
internal static class GameModeNetwork
{
private const int MaximumModes = 64;
private static readonly HashSet<int> ValidatedClients = new HashSet<int>();
private static readonly Dictionary<int, Action> PendingPlayerSpawns = new Dictionary<int, Action>();
private static readonly Action<NetworkConnection, ModeHello, Channel> ServerHelloHandler = OnServerHello;
private static readonly Action<ModeReply, Channel> ClientReplyHandler = OnClientReply;
private static readonly Action<ManagedGameplayStart, Channel> ManagedStartHandler = OnManagedStart;
private static bool _clientRegistered;
private static bool _serverRegistered;
private static bool _awaitingModeReply;
private static bool _openingPending;
private static bool _bypassOpening;
private static bool _bypassSpawn;
private static bool _managedGameplayStarted;
internal static bool IsServer
{
get
{
if (Object.op_Implicit((Object)(object)Server.Instance))
{
return ((NetworkBehaviour)Server.Instance).IsServerInitialized;
}
return false;
}
}
internal static bool IsClientValidated(int clientId)
{
return ValidatedClients.Contains(clientId);
}
internal static void Initialize()
{
GenericWriter<ModeHello>.SetWrite((Action<Writer, ModeHello>)WriteHello);
GenericReader<ModeHello>.SetRead((Func<Reader, ModeHello>)ReadHello);
GenericWriter<ModeReply>.SetWrite((Action<Writer, ModeReply>)delegate(Writer writer, ModeReply message)
{
writer.WriteString(message.ModeId);
writer.WriteInt32(message.NetworkVersion);
writer.WriteBoolean(message.Accepted);
writer.WriteString(message.Message);
});
GenericReader<ModeReply>.SetRead((Func<Reader, ModeReply>)((Reader reader) => new ModeReply(reader.ReadStringAllocated(), reader.ReadInt32(), reader.ReadBoolean(), reader.ReadStringAllocated())));
GenericWriter<ManagedGameplayStart>.SetWrite((Action<Writer, ManagedGameplayStart>)delegate
{
});
GenericReader<ManagedGameplayStart>.SetRead((Func<Reader, ManagedGameplayStart>)((Reader _) => default(ManagedGameplayStart)));
}
internal static void Register()
{
if (!_clientRegistered && Object.op_Implicit((Object)(object)InstanceFinder.ClientManager))
{
InstanceFinder.ClientManager.RegisterBroadcast<ModeReply>(ClientReplyHandler);
InstanceFinder.ClientManager.RegisterBroadcast<ManagedGameplayStart>(ManagedStartHandler);
_clientRegistered = true;
}
if (!_serverRegistered && Object.op_Implicit((Object)(object)InstanceFinder.ServerManager))
{
InstanceFinder.ServerManager.RegisterBroadcast<ModeHello>(ServerHelloHandler, true);
InstanceFinder.ServerManager.OnRemoteConnectionState += OnRemoteConnectionState;
_serverRegistered = true;
}
}
internal static void SendHello()
{
Register();
if (Object.op_Implicit((Object)(object)InstanceFinder.ClientManager))
{
int num = Math.Min(GameModeApi.Modes.Count, 64);
string[] array = new string[num];
int[] array2 = new int[num];
for (int i = 0; i < num; i++)
{
array[i] = GameModeApi.Modes[i].Id;
array2[i] = GameModeApi.Modes[i].NetworkVersion;
}
InstanceFinder.ClientManager.Broadcast<ModeHello>(new ModeHello(array, array2), (Channel)0);
}
}
internal static bool AllowOrDeferSpawn(NetworkConnection? connection, Action spawn)
{
if (_bypassSpawn)
{
return true;
}
if (GameModeApi.IsActive("ArceDev.GameModeCore.Classic"))
{
return true;
}
if (connection != null && IsManagedMode())
{
if (_managedGameplayStarted && ValidatedClients.Contains(connection.ClientId))
{
return true;
}
bool flag = !PendingPlayerSpawns.ContainsKey(connection.ClientId);
PendingPlayerSpawns[connection.ClientId] = spawn;
if (flag)
{
Plugin.Log.LogInfo((object)$"Deferred managed player spawn for client {connection.ClientId}.");
}
return false;
}
if (connection != null && ValidatedClients.Contains(connection.ClientId))
{
return true;
}
string text = "Game mode handshake failed for '" + GameModeApi.ActiveModeId + "'.";
Plugin.Log.LogWarning((object)text);
if (connection != null)
{
connection.Kick((KickReason)6, (LoggingType)2, text);
}
return false;
}
internal static bool AllowNativeOpening()
{
if (_bypassOpening)
{
return true;
}
if (!_awaitingModeReply && !IsManagedMode())
{
return true;
}
_openingPending = true;
return false;
}
internal static void ObserveClientState(ClientConnectionStateArgs args)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
if ((int)args.ConnectionState == 4)
{
_awaitingModeReply = true;
_openingPending = false;
_managedGameplayStarted = false;
GameModeApi.ResetManagedStartup();
}
else if ((int)args.ConnectionState == 1)
{
ResetClientStartup();
}
}
internal static void StartManagedGameplay()
{
if (!IsServer || !IsManagedMode())
{
throw new InvalidOperationException("Managed gameplay can only be started by the host of a managed game mode.");
}
if (_managedGameplayStarted)
{
return;
}
_managedGameplayStarted = true;
Plugin.Log.LogInfo((object)$"Starting managed gameplay with {PendingPlayerSpawns.Count} deferred player spawn(s).");
foreach (NetworkConnection value in InstanceFinder.ServerManager.Clients.Values)
{
if (value.IsAuthenticated && ValidatedClients.Contains(value.ClientId))
{
InstanceFinder.ServerManager.Broadcast<ManagedGameplayStart>(value, default(ManagedGameplayStart), true, (Channel)0);
}
}
ReleasePendingSpawns();
}
internal static void Reset()
{
ValidatedClients.Clear();
PendingPlayerSpawns.Clear();
_managedGameplayStarted = false;
ResetClientStartup();
if (!IsServer)
{
GameModeApi.Activate("ArceDev.GameModeCore.Classic");
}
}
private static void OnServerHello(NetworkConnection connection, ModeHello message, Channel _)
{
GameModeDefinition activeMode = GameModeApi.ActiveMode;
bool flag = activeMode != null && HasCompatibleMode(message, activeMode);
if (flag)
{
ValidatedClients.Add(connection.ClientId);
}
else
{
ValidatedClients.Remove(connection.ClientId);
PendingPlayerSpawns.Remove(connection.ClientId);
}
string message2 = (flag ? "" : ("The host requires " + GameModeApi.ActiveModeId + "."));
InstanceFinder.ServerManager.Broadcast<ModeReply>(connection, new ModeReply(GameModeApi.ActiveModeId, activeMode?.NetworkVersion ?? 0, flag, message2), true, (Channel)0);
if (flag && _managedGameplayStarted)
{
InstanceFinder.ServerManager.Broadcast<ManagedGameplayStart>(connection, default(ManagedGameplayStart), true, (Channel)0);
ReleasePendingSpawns();
}
}
private static void OnClientReply(ModeReply message, Channel _)
{
if (!message.Accepted)
{
Plugin.Log.LogError((object)message.Message);
GameModeApi.Activate(message.ModeId, message.Message);
_awaitingModeReply = false;
_openingPending = false;
return;
}
GameModeApi.Activate(message.ModeId);
_awaitingModeReply = false;
if (IsManagedMode())
{
GameModeApi.NotifyManagedStartupReady();
}
else
{
PlayPendingOpening();
}
}
private static bool HasCompatibleMode(ModeHello message, GameModeDefinition active)
{
int num = Math.Min(message.ModeIds.Length, message.NetworkVersions.Length);
for (int i = 0; i < num; i++)
{
if (message.ModeIds[i] == active.Id && message.NetworkVersions[i] == active.NetworkVersion)
{
return true;
}
}
return false;
}
private static void OnRemoteConnectionState(NetworkConnection connection, RemoteConnectionStateArgs args)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)args.ConnectionState == 0)
{
ValidatedClients.Remove(connection.ClientId);
PendingPlayerSpawns.Remove(connection.ClientId);
}
}
private static void OnManagedStart(ManagedGameplayStart _, Channel __)
{
if (!IsManagedMode())
{
return;
}
Plugin.Log.LogInfo((object)"Received managed gameplay start; leaving the menu without the native opening.");
_openingPending = false;
_bypassOpening = true;
try
{
MainMenuManager.CrashAnimation();
MainMenuManager.InstantCrash();
Player.ToggleLocalPlayer(true);
PlayerCamera.ToggleMouse(PauseManager.IsPaused || MainMenuManager.IsInMenu);
}
finally
{
_bypassOpening = false;
}
}
private static bool IsManagedMode()
{
GameModeDefinition? activeMode = GameModeApi.ActiveMode;
if (activeMode == null)
{
return false;
}
return activeMode.StartupPolicy == GameModeStartupPolicy.Managed;
}
private static void PlayPendingOpening()
{
if (!_openingPending)
{
return;
}
_openingPending = false;
_bypassOpening = true;
try
{
MainMenuManager.CrashAnimation();
}
finally
{
_bypassOpening = false;
}
}
private static void ReleasePendingSpawns()
{
Action[] array = (from pair in PendingPlayerSpawns
where ValidatedClients.Contains(pair.Key)
select pair.Value).ToArray();
int[] array2 = PendingPlayerSpawns.Keys.Where(ValidatedClients.Contains).ToArray();
foreach (int key in array2)
{
PendingPlayerSpawns.Remove(key);
}
_bypassSpawn = true;
try
{
Action[] array3 = array;
foreach (Action action in array3)
{
action();
}
}
finally
{
_bypassSpawn = false;
}
}
private static void ResetClientStartup()
{
_awaitingModeReply = false;
_openingPending = false;
_bypassOpening = false;
GameModeApi.ResetManagedStartup();
}
private static void WriteHello(Writer writer, ModeHello message)
{
int num = Math.Min(Math.Min(message.ModeIds.Length, message.NetworkVersions.Length), 64);
writer.WriteUInt8Unpacked((byte)num);
for (int i = 0; i < num; i++)
{
writer.WriteString(message.ModeIds[i]);
writer.WriteInt32(message.NetworkVersions[i]);
}
}
private static ModeHello ReadHello(Reader reader)
{
int num = Math.Min((int)reader.ReadUInt8Unpacked(), 64);
string[] array = new string[num];
int[] array2 = new int[num];
for (int i = 0; i < num; i++)
{
array[i] = reader.ReadStringAllocated();
array2[i] = reader.ReadInt32();
}
return new ModeHello(array, array2);
}
}
[HarmonyPatch(typeof(Client), "OnStartClient")]
internal static class ClientStartPatch
{
private static void Postfix(Client __instance)
{
if (((NetworkBehaviour)__instance).Owner.IsLocalClient)
{
GameModeNetwork.SendHello();
}
}
}
[HarmonyPatch(typeof(Server), "OnStartClient")]
internal static class ServerStartPatch
{
private static void Postfix()
{
GameModeNetwork.Register();
}
}
[HarmonyPatch(typeof(Server), "OnStopClient")]
internal static class ServerStopPatch
{
private static void Prefix()
{
GameModeNetwork.Reset();
}
}
[HarmonyPatch(typeof(Server), "RpcLogic___SpawnPlayer___1871804056")]
internal static class SpawnPlayerPatch
{
private static bool Prefix(Vector3 __0, Vector3 __1, Vector3 __2, Vector3 __3, Vector3 __4, Vector3 __5, Vector3 __6, Vector3 __7, Vector3 __8, Vector3 __9, byte __10, byte __11, byte __12, bool __13, NetworkConnection __14)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
return GameModeNetwork.AllowOrDeferSpawn(__14, delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
Server.Instance.RpcLogic___SpawnPlayer___1871804056(__0, __1, __2, __3, __4, __5, __6, __7, __8, __9, __10, __11, __12, __13, __14);
});
}
}
[HarmonyPatch(typeof(MainMenuManager), "CrashAnimation")]
internal static class NativeOpeningPatch
{
private static bool Prefix()
{
return GameModeNetwork.AllowNativeOpening();
}
}
[HarmonyPatch(typeof(ConnectionManager), "OnClientConnectionState")]
internal static class ClientConnectionStatePatch
{
private static void Prefix(ClientConnectionStateArgs __0)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
GameModeNetwork.ObserveClientState(__0);
}
}
[Serializable]
internal sealed class GameModeSidecar
{
public int SchemaVersion;
public string SaveName = "";
public string ModeId = "";
}
internal static class GameModePersistence
{
private const int SchemaVersion = 1;
private const string Suffix = ".gamemodecore.json";
private static readonly FieldInfo SaveFolderField = AccessTools.Field(typeof(SaveSystem), "_saveFolder");
private static string? _loadedSave;
internal static void CreateFresh()
{
string text = SaveManager.CurServerSave?.Name;
if (!string.IsNullOrWhiteSpace(text))
{
_loadedSave = text;
GameModeApi.Activate(GameModeApi.SelectedModeId);
Write(text, GameModeApi.ActiveModeId);
}
}
internal static void LoadSelected()
{
string text = SaveManager.CurServerSave?.Name;
if (string.IsNullOrWhiteSpace(text))
{
Reset();
return;
}
_loadedSave = text;
string text2 = PathFor(text);
GameModeSidecar sidecar;
if (!File.Exists(text2) && !File.Exists(text2 + ".backup"))
{
GameModeApi.Activate("ArceDev.GameModeCore.Classic");
}
else if (TryRead(text2, text, out sidecar) || TryRead(text2 + ".backup", text, out sidecar))
{
GameModeApi.Activate(sidecar.ModeId);
}
else
{
GameModeApi.Activate("ArceDev.GameModeCore.Classic", "Game mode metadata for save '" + text + "' is invalid.");
}
}
internal static void Save()
{
string text = SaveManager.CurServerSave?.Name;
if (!string.IsNullOrWhiteSpace(text) && GameModeNetwork.IsServer)
{
if (_loadedSave != text)
{
LoadSelected();
}
if (GameModeApi.CanStart(out string _))
{
Write(text, GameModeApi.ActiveModeId);
}
}
}
internal static void DeleteCurrent()
{
string text = SaveManager.CurServerSave?.Name;
if (!string.IsNullOrWhiteSpace(text))
{
string text2 = PathFor(text);
string[] array = new string[3]
{
text2,
text2 + ".backup",
text2 + ".tmp"
};
foreach (string path in array)
{
if (File.Exists(path))
{
File.Delete(path);
}
}
}
Reset();
}
internal static void Reset()
{
_loadedSave = null;
GameModeApi.Activate("ArceDev.GameModeCore.Classic");
GameModeApi.SelectClassic();
}
internal static void Validate()
{
GameModeSidecar gameModeSidecar = new GameModeSidecar
{
SchemaVersion = 1,
SaveName = "test",
ModeId = "example.mode"
};
string text = JsonConvert.SerializeObject((object)gameModeSidecar);
GameModeSidecar gameModeSidecar2 = JsonConvert.DeserializeObject<GameModeSidecar>(text);
if (gameModeSidecar2?.SaveName != gameModeSidecar.SaveName || gameModeSidecar2.ModeId != gameModeSidecar.ModeId)
{
throw new InvalidOperationException("GameModeCore sidecar validation failed.");
}
}
private static bool TryRead(string path, string expectedSave, out GameModeSidecar sidecar)
{
sidecar = new GameModeSidecar();
if (!File.Exists(path))
{
return false;
}
try
{
GameModeSidecar gameModeSidecar = JsonConvert.DeserializeObject<GameModeSidecar>(File.ReadAllText(path));
if (gameModeSidecar == null || gameModeSidecar.SchemaVersion != 1 || gameModeSidecar.SaveName != expectedSave || string.IsNullOrWhiteSpace(gameModeSidecar.ModeId))
{
return false;
}
sidecar = gameModeSidecar;
return true;
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Could not read game mode sidecar '" + path + "': " + ex.Message));
return false;
}
}
private static void Write(string saveName, string modeId)
{
string text = PathFor(saveName);
string text2 = text + ".tmp";
string destinationBackupFileName = text + ".backup";
try
{
string contents = JsonConvert.SerializeObject((object)new GameModeSidecar
{
SchemaVersion = 1,
SaveName = saveName,
ModeId = modeId
}, (Formatting)1);
File.WriteAllText(text2, contents);
if (!TryRead(text2, saveName, out GameModeSidecar _))
{
throw new InvalidDataException("Temporary sidecar failed validation.");
}
if (File.Exists(text))
{
File.Replace(text2, text, destinationBackupFileName);
}
else
{
File.Move(text2, text);
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Could not safely save game mode metadata: {arg}");
}
finally
{
if (File.Exists(text2))
{
File.Delete(text2);
}
}
}
private static string PathFor(string saveName)
{
string text = SaveFolderField.GetValue(null) as string;
if (string.IsNullOrWhiteSpace(text))
{
throw new InvalidOperationException("The native save folder is not initialized.");
}
return Path.Combine(text, saveName + ".gamemodecore.json");
}
}
[HarmonyPatch(typeof(SaveManager), "CreateServer")]
internal static class CreateSavePatch
{
private static void Postfix()
{
GameModePersistence.CreateFresh();
}
}
[HarmonyPatch(typeof(SaveManager), "SelectServer")]
internal static class SelectSavePatch
{
private static void Postfix()
{
GameModePersistence.LoadSelected();
}
}
[HarmonyPatch(typeof(SaveManager), "SaveServer")]
internal static class SavePatch
{
private static void Postfix()
{
GameModePersistence.Save();
}
}
[HarmonyPatch(typeof(SaveManager), "DeleteServer")]
internal static class DeleteSavePatch
{
private static void Postfix()
{
GameModePersistence.DeleteCurrent();
}
}
[HarmonyPatch(typeof(SaveManager), "LoadAllServers")]
internal static class ResetAtMenuPatch
{
private static void Postfix()
{
GameModePersistence.Reset();
}
}
internal static class GameModeUi
{
private static ModeSelector? _selector;
private static TextMeshProUGUI? _loadedMode;
private static Button? _loadButton;
internal static void Attach(ButtonManager manager)
{
_selector = CreateSelector(manager);
_loadedMode = CreateLoadedMode(manager);
_loadButton = FindButton(manager, "LoadServerButton");
Refresh();
Plugin.Log.LogInfo((object)$"Attached game mode UI with {GameModeApi.Modes.Count} registered modes.");
}
internal static void Refresh()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
_selector?.Render();
if (Object.op_Implicit((Object)(object)_loadedMode))
{
GameModeDefinition activeMode = GameModeApi.ActiveMode;
((TMP_Text)_loadedMode).text = activeMode?.DisplayName ?? ("Missing: " + GameModeApi.ActiveModeId);
((Graphic)_loadedMode).color = (Color)((activeMode == null) ? new Color(1f, 0.35f, 0.35f) : Color.white);
if (Object.op_Implicit((Object)(object)_loadButton))
{
((Selectable)_loadButton).interactable = GameModeApi.CanStart(out string _);
}
}
}
internal static void ValidateLoad()
{
if (!GameModeApi.CanStart(out string reason))
{
Plugin.Log.LogError((object)reason);
}
}
private static ModeSelector CreateSelector(ButtonManager manager)
{
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
GameObject val = Field<GameObject>(manager, "_createDefaultDifficultyText");
GameObject val2 = Field<GameObject>(manager, "_createEasyDifficultyText");
GameObject val3 = Field<GameObject>(manager, "_createHardDifficultyText");
GameObject val4 = Field<GameObject>(manager, "_createInviteOnlyText");
Transform val5 = FindButtonRow(val.transform);
Transform val6 = FindButtonRow(val4.transform);
Plugin.Log.LogInfo((object)("Using native create row '" + HierarchyPath(val5) + "'."));
GameObject val7 = Object.Instantiate<GameObject>(((Component)val5).gameObject, val5.parent);
((Object)val7).name = "GameModeCore_CreateMode";
val7.transform.SetSiblingIndex(val6.GetSiblingIndex());
TextMeshProUGUI[] componentsInChildren = ((Component)val5).GetComponentsInChildren<TextMeshProUGUI>(true);
TextMeshProUGUI[] componentsInChildren2 = val7.GetComponentsInChildren<TextMeshProUGUI>(true);
TextMeshProUGUI val8 = CloneOf<TextMeshProUGUI>(val.GetComponent<TextMeshProUGUI>(), componentsInChildren, componentsInChildren2);
((Component)CloneOf<TextMeshProUGUI>(val2.GetComponent<TextMeshProUGUI>(), componentsInChildren, componentsInChildren2)).gameObject.SetActive(false);
((Component)CloneOf<TextMeshProUGUI>(val3.GetComponent<TextMeshProUGUI>(), componentsInChildren, componentsInChildren2)).gameObject.SetActive(false);
((Component)val8).gameObject.SetActive(true);
RemoveLocalization(((Component)val8).gameObject);
SetLabel(val7, val8, "Game Mode");
Button[] array = (from button in val7.GetComponentsInChildren<Button>(true)
orderby ((Component)button).transform.position.x
select button).ToArray();
if (array.Length < 2)
{
throw new InvalidOperationException("Could not find both difficulty arrows to clone.");
}
Button[] array2 = array;
foreach (Button val9 in array2)
{
val9.onClick = new ButtonClickedEvent();
}
ModeSelector modeSelector = val7.AddComponent<ModeSelector>();
modeSelector.Initialize(val8, array[0], array[^1], val5.parent);
return modeSelector;
}
private static TextMeshProUGUI CreateLoadedMode(ButtonManager manager)
{
TextMeshProUGUI val = Field<TextMeshProUGUI>(manager, "_islandText");
Transform val2 = FindTextRow(((TMP_Text)val).transform);
Plugin.Log.LogInfo((object)("Using native save-info row '" + HierarchyPath(val2) + "'."));
GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val2.parent);
((Object)val3).name = "GameModeCore_LoadedMode";
val3.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1);
TextMeshProUGUI[] componentsInChildren = ((Component)val2).GetComponentsInChildren<TextMeshProUGUI>(true);
TextMeshProUGUI[] componentsInChildren2 = val3.GetComponentsInChildren<TextMeshProUGUI>(true);
TextMeshProUGUI val4 = CloneOf<TextMeshProUGUI>(val, componentsInChildren, componentsInChildren2);
RemoveLocalization(((Component)val4).gameObject);
SetLabel(val3, val4, "Game Mode");
Button[] componentsInChildren3 = val3.GetComponentsInChildren<Button>(true);
foreach (Button val5 in componentsInChildren3)
{
((Component)val5).gameObject.SetActive(false);
}
return val4;
}
private static Transform FindButtonRow(Transform start)
{
for (Transform parent = start.parent; parent != null; parent = parent.parent)
{
if (((Component)parent).GetComponentsInChildren<Button>(true).Length >= 2)
{
return parent;
}
}
throw new InvalidOperationException("Could not locate the native difficulty row.");
}
private static Transform FindTextRow(Transform start)
{
for (Transform parent = start.parent; parent != null; parent = parent.parent)
{
if (((Component)parent).GetComponentsInChildren<TextMeshProUGUI>(true).Length >= 2)
{
return parent;
}
}
throw new InvalidOperationException("Could not locate the native save-information row.");
}
private static void SetLabel(GameObject row, TextMeshProUGUI value, string text)
{
TextMeshProUGUI val = ((IEnumerable<TextMeshProUGUI>)row.GetComponentsInChildren<TextMeshProUGUI>(true)).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI candidate) => (Object)(object)candidate != (Object)(object)value && ((Component)candidate).GetComponentInParent<Button>() == null && ((Component)candidate).gameObject.activeSelf));
if (Object.op_Implicit((Object)(object)val))
{
RemoveLocalization(((Component)val).gameObject);
((TMP_Text)val).text = text;
}
}
private static void RemoveLocalization(GameObject target)
{
MonoBehaviour[] components = target.GetComponents<MonoBehaviour>();
foreach (MonoBehaviour val in components)
{
string? text = ((object)val).GetType().Namespace;
if (text != null && text.StartsWith("UnityEngine.Localization", StringComparison.Ordinal))
{
Object.Destroy((Object)(object)val);
}
}
}
private static T CloneOf<T>(T source, T[] sourceComponents, T[] clonedComponents) where T : Component
{
int num = Array.IndexOf(sourceComponents, source);
if (num < 0 || num >= clonedComponents.Length)
{
throw new InvalidOperationException("The native UI hierarchy changed while cloning.");
}
return clonedComponents[num];
}
private static T Field<T>(ButtonManager manager, string name) where T : class
{
return (AccessTools.Field(typeof(ButtonManager), name).GetValue(manager) as T) ?? throw new MissingFieldException(typeof(ButtonManager).FullName, name);
}
private static Button FindButton(ButtonManager manager, string methodName)
{
Button[] componentsInChildren = ((Component)manager).GetComponentsInChildren<Button>(true);
foreach (Button val in componentsInChildren)
{
for (int j = 0; j < ((UnityEventBase)val.onClick).GetPersistentEventCount(); j++)
{
if (((UnityEventBase)val.onClick).GetPersistentMethodName(j) == methodName)
{
return val;
}
}
}
throw new InvalidOperationException("Could not locate the native button for '" + methodName + "'.");
}
internal static void FitVerticalLayout(Transform layoutTransform)
{
//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)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = (RectTransform)(object)((layoutTransform is RectTransform) ? layoutTransform : null);
if (val == null)
{
return;
}
Transform parent = ((Transform)val).parent;
RectTransform container = (RectTransform)(object)((parent is RectTransform) ? parent : null);
VerticalLayoutGroup val2 = default(VerticalLayoutGroup);
if (container == null || !((Component)val).TryGetComponent<VerticalLayoutGroup>(ref val2))
{
return;
}
Canvas.ForceUpdateCanvases();
LayoutRebuilder.ForceRebuildLayoutImmediate(val);
RectTransform[] array = (from Transform child in (IEnumerable)layoutTransform
where ((Component)child).gameObject.activeSelf
select child).OfType<RectTransform>().ToArray();
if (array.Length >= 2)
{
float num = array.Min(delegate(RectTransform child)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = container;
Rect rect2 = child.rect;
return ((Transform)obj).InverseTransformPoint(((Transform)child).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).min))).y;
});
float num2 = array.Max(delegate(RectTransform child)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = container;
Rect rect2 = child.rect;
return ((Transform)obj).InverseTransformPoint(((Transform)child).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect2)).max))).y;
});
Rect rect = container.rect;
float num3 = Mathf.Max(0f, ((Rect)(ref rect)).yMin + 6f - num);
rect = container.rect;
float num4 = num3 + Mathf.Max(0f, num2 - ((Rect)(ref rect)).yMax + 6f);
if (!(num4 <= 0f))
{
((HorizontalOrVerticalLayoutGroup)val2).spacing = Mathf.Max(0f, ((HorizontalOrVerticalLayoutGroup)val2).spacing - (num4 + 4f) / (float)(array.Length - 1));
LayoutRebuilder.ForceRebuildLayoutImmediate(val);
Plugin.Log.LogInfo((object)$"Reduced create-form spacing to {((HorizontalOrVerticalLayoutGroup)val2).spacing:F2} to fit the mode row.");
}
}
}
private static string HierarchyPath(Transform transform)
{
if (!Object.op_Implicit((Object)(object)transform.parent))
{
return ((Object)transform).name;
}
return HierarchyPath(transform.parent) + "/" + ((Object)transform).name;
}
}
internal sealed class ModeSelector : MonoBehaviour
{
private TextMeshProUGUI _value;
private Transform _layout;
private bool _initialized;
private bool _layoutFitted;
internal void Initialize(TextMeshProUGUI value, Button previous, Button next, Transform layout)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
_value = value;
_layout = layout;
((UnityEvent)previous.onClick).AddListener((UnityAction)delegate
{
Move(-1);
});
((UnityEvent)next.onClick).AddListener((UnityAction)delegate
{
Move(1);
});
_initialized = true;
GameModeApi.SelectClassic();
Render();
}
internal void Render()
{
if (_initialized)
{
GameModeDefinition gameModeDefinition = GameModeApi.Get(GameModeApi.SelectedModeId) ?? GameModeApi.Get("ArceDev.GameModeCore.Classic");
((TMP_Text)_value).text = gameModeDefinition.DisplayName;
}
}
private void OnEnable()
{
if (_initialized)
{
GameModeApi.SelectClassic();
if (!_layoutFitted)
{
GameModeUi.FitVerticalLayout(_layout);
_layoutFitted = true;
}
}
}
private void Move(int delta)
{
int num = GameModeApi.Modes.ToList().FindIndex((GameModeDefinition mode) => mode.Id == GameModeApi.SelectedModeId);
num = (num + delta + GameModeApi.Modes.Count) % GameModeApi.Modes.Count;
GameModeApi.Select(GameModeApi.Modes[num].Id);
}
}
[HarmonyPatch(typeof(ButtonManager), "Start")]
internal static class ButtonManagerStartPatch
{
private static void Postfix(ButtonManager __instance)
{
try
{
GameModeUi.Attach(__instance);
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Could not attach game mode UI: {arg}");
}
}
}
[HarmonyPatch(typeof(ButtonManager), "SelectServer")]
internal static class SelectedSaveUiPatch
{
private static void Postfix()
{
GameModeUi.Refresh();
}
}
[HarmonyPatch(typeof(ButtonManager), "LoadServerButton")]
internal static class LoadServerGuardPatch
{
private static bool Prefix()
{
GameModeUi.ValidateLoad();
string reason;
return GameModeApi.CanStart(out reason);
}
}
[BepInPlugin("ArceDev.GameModeCore", "Game Mode Core", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
public const string Id = "ArceDev.GameModeCore";
internal static ManualLogSource Log { get; private set; }
public static string Name => "Game Mode Core";
public static string Version => "0.1.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
GameModeApi.Validate();
GameModePersistence.Validate();
GameModeNetwork.Initialize();
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, "ArceDev.GameModeCore");
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}