Decompiled source of WIP Impeakster Among Us v0.1.2

plugins/com.github.keveloper-yt.ImpeaksterAmongUs.dll

Decompiled a week ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Impeakster_Among_Us.Patches;
using Impeakster_Among_Us.Properties;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;

[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("com.github.keveloper-yt.ImpeaksterAmongUs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+9c73488b3604d6970201f4879e146fa95249af08")]
[assembly: AssemblyProduct("com.github.keveloper-yt.ImpeaksterAmongUs")]
[assembly: AssemblyTitle("Impeakster_Among_Us")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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")]
	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")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Impeakster_Among_Us
{
	[BepInPlugin("com.github.keveloper-yt.ImpeaksterAmongUs", "Impeakster_Among_Us", "0.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.keveloper-yt.ImpeaksterAmongUs");

		public const string Id = "com.github.keveloper-yt.ImpeaksterAmongUs";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "Impeakster_Among_Us";

		public static string Version => "0.1.2";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Harmony.CreateAndPatchAll(typeof(LocalizedTextPatch), (string)null);
		}
	}
}
namespace Impeakster_Among_Us.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("Impeakster_Among_Us.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static string Localized_Text => ResourceManager.GetString("Localized_Text", resourceCulture);

		internal Resources()
		{
		}
	}
}
namespace Impeakster_Among_Us.Patches
{
	[HarmonyPatch(typeof(Ascents))]
	public class AscentsPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static void CantRevive(ref bool __result)
		{
		}
	}
	public class ImpostorData
	{
		public static bool isImpostor;
	}
	[HarmonyPatch(typeof(Item))]
	public class ItemPatch
	{
		[HarmonyPatch("Consume")]
		[HarmonyPostfix]
		private static void ImposterFood(Item __instance)
		{
			if (ImpostorData.isImpostor)
			{
				__instance.holderCharacter.AddExtraStamina(0.05f);
			}
		}
	}
	[HarmonyPatch(typeof(LocalizedText))]
	[HarmonyWrapSafe]
	public static class LocalizedTextPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("LoadMainTable")]
		public static void LoadMainTable()
		{
			LoadLocalizedText();
		}

		public static void LoadLocalizedText()
		{
			Dictionary<string, List<string>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(Resources.Localized_Text);
			if (dictionary == null)
			{
				return;
			}
			Debug.Log((object)$"Loaded {dictionary.Count} localized text entries from embedded resource.");
			foreach (KeyValuePair<string, List<string>> item in dictionary)
			{
				List<string> value = item.Value;
				string firstValue = value[0];
				value = value.Select((string x) => (!string.IsNullOrEmpty(x)) ? x : firstValue).ToList();
				string key = ("Mod_Impeakster_" + item.Key).ToUpper();
				if (LocalizedText.MAIN_TABLE.ContainsKey(key))
				{
					LocalizedText.MAIN_TABLE[key] = value;
				}
				else
				{
					LocalizedText.MAIN_TABLE.Add(key, value);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MountainProgressHandler))]
	internal class MountainProgressPatch
	{
		public static Random seededRandom = new Random();

		public static bool seeded = false;

		[HarmonyPatch("TriggerReached")]
		[HarmonyPrefix]
		private static void PatchTitleText(MountainProgressHandler __instance)
		{
			if (!seeded)
			{
				int seed = DateTime.UtcNow.Year + DateTime.UtcNow.Day + DateTime.UtcNow.Hour + DateTime.UtcNow.Minute / 15;
				seededRandom = new Random(seed);
				seeded = true;
			}
			List<string> list = new List<string>();
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if (!allCharacter.data.dead)
				{
					list.Add(allCharacter.characterName);
				}
			}
			list.Sort();
			int count = Math.Max(1, list.Count / 4);
			List<string> list2 = list.OrderBy((string x) => seededRandom.Next()).Take(count).ToList();
			int num = seededRandom.Next();
			if (list2.Contains(Player.localPlayer.character.characterName))
			{
				ImpostorData.isImpostor = true;
				if (list2.Count > 1)
				{
					for (int i = 0; i < 6; i++)
					{
						__instance.progressPoints[i].title = "Impostors: " + string.Join(", ", list2);
					}
				}
				else
				{
					for (int j = 0; j < 6; j++)
					{
						__instance.progressPoints[j].title = "Mod_Impeakster_Impostor";
					}
				}
			}
			else
			{
				ImpostorData.isImpostor = false;
				for (int k = 0; k < 6; k++)
				{
					__instance.progressPoints[k].title = "Scout";
				}
			}
		}

		private static string GetText(string key, params object[] args)
		{
			return string.Format(LocalizedText.GetText(("Mod_Impeakster_" + key).ToUpper(), true), args);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}