Decompiled source of MapSyncFix v1.0.0

MapSyncFix.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnboundLib.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 MapSyncFix
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.jeustice.rounds.mapsyncfix", "Map Sync Fix", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class MapSyncFix : BaseUnityPlugin
	{
		public const string ModId = "com.jeustice.rounds.mapsyncfix";

		public const string ModName = "Map Sync Fix";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.jeustice.rounds.mapsyncfix").PatchAll();
		}
	}
	[HarmonyPatch(typeof(MapManager), "RPCA_LoadLevel")]
	internal static class MapOrderFix
	{
		private static readonly FieldInfo ActiveLevels = AccessTools.Field(typeof(LevelManager), "activeLevels");

		private static void Prefix(MapManager __instance)
		{
			if (ActiveLevels?.GetValue(null) is IEnumerable<string> source && source.Any())
			{
				List<string> list = source.Distinct().ToList();
				list.Sort(string.CompareOrdinal);
				if (__instance.levels == null || !__instance.levels.SequenceEqual(list))
				{
					MapSyncFix.Log.LogInfo((object)$"Map order fixed ({list.Count} maps) so map numbers match the other players");
					__instance.levels = list.ToArray();
				}
			}
		}
	}
}