Decompiled source of RiskOfWoke v1.0.0

RiskOfWoke.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RiskOfWoke")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RiskOfWoke")]
[assembly: AssemblyTitle("RiskOfWoke")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RiskOfWoke
{
	public sealed class Config
	{
		private readonly ConfigFile file;

		public ConfigEntry<bool> multipleSets;

		public ConfigEntry<bool> includeCommonPronouns;

		public ConfigEntry<int> maxSets;

		public ConfigEntry<string> setsSubject;

		public ConfigEntry<string> setsObject;

		public bool MultipleSets => multipleSets.Value;

		public int MaxSets => maxSets.Value;

		public bool IncludeCommonPronouns => includeCommonPronouns.Value;

		public string SetsSubject => setsSubject.Value;

		public string SetsObject => setsObject.Value;

		internal void Reload()
		{
			RiskOfWoke.Logger.LogDebug((object)("Reloading " + file.ConfigFilePath.Substring(file.ConfigFilePath.LastIndexOf(Path.DirectorySeparatorChar) + 1)));
			file.Reload();
		}

		public Config(ConfigFile config)
		{
			file = config;
			multipleSets = config.Bind<bool>("Generic", "Multiple Sets", false, "Changes to multiple sets of pronouns rather than subject/object\nEnabled: He/She/They/ect..\nDisabled: She/Her");
			maxSets = config.Bind<int>("Generic", "Max Sets", 3, "Caps the amount of sets used if multiple sets is enabled. Mod will try to set to a safe value if it exceeds the available list.");
			includeCommonPronouns = config.Bind<bool>("Generic", "Include Common Pronouns", true, "Includes the common, he/him, they/them, she/her pronouns, toggle off if you want to exclusively use your custom list.");
			setsSubject = config.Bind<string>("Generic", "Subject Sets", "it,xe,fae,ze", "Additional sets of subject pronouns to be used! Seperate with a comma.");
			setsObject = config.Bind<string>("Generic", "Object Sets", "its,xyr,faer,zyr", "Additional sets of object pronouns to be used! Seperate with a comma.");
			setsSubject.SettingChanged += RegeneratePronounSets;
			setsObject.SettingChanged += RegeneratePronounSets;
		}

		private void RegeneratePronounSets(object sender, EventArgs e)
		{
			RiskOfWoke.GeneratePronounSets();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("veryrealbat.RiskOfWoke", "RiskOfWoke", "1.0.0")]
	public class RiskOfWoke : BaseUnityPlugin
	{
		public const string PluginGUID = "veryrealbat.RiskOfWoke";

		public const string PluginAuthor = "veryrealbat";

		public const string PluginName = "RiskOfWoke";

		public const string PluginVersion = "1.0.0";

		public static List<string> pronounSetsSubject;

		public static List<string> pronounSetsObject;

		internal static ManualLogSource Logger { get; private set; }

		public static Config Config { get; private set; }

		private void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Logger.Sources.Remove((ILogSource)(object)((BaseUnityPlugin)this).Logger);
			Logger = Logger.CreateLogSource("veryrealbat.RiskOfWoke");
			Config = new Config(((BaseUnityPlugin)this).Config);
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
			GeneratePronounSets();
			CreateOptions();
		}

		public void CreateOptions()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_003a: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Config.multipleSets, false));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(Config.maxSets, new IntSliderConfig
			{
				min = 1,
				max = 10
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Config.includeCommonPronouns, false));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(Config.setsSubject, false));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(Config.setsObject, false));
		}

		public static void GeneratePronounSets()
		{
			StringBuilder stringBuilder = new StringBuilder(Config.SetsSubject);
			StringBuilder stringBuilder2 = new StringBuilder(Config.SetsObject);
			string[] array = stringBuilder.Replace(" ", "").ToString().Split(',');
			List<string> list = new List<string>(array.Length);
			list.AddRange(array);
			pronounSetsSubject = list;
			array = stringBuilder2.Replace(" ", "").ToString().Split(',');
			List<string> list2 = new List<string>(array.Length);
			list2.AddRange(array);
			pronounSetsObject = list2;
			if (Config.IncludeCommonPronouns)
			{
				pronounSetsSubject.Add("he");
				pronounSetsSubject.Add("she");
				pronounSetsSubject.Add("they");
				pronounSetsObject.Add("him");
				pronounSetsObject.Add("her");
				pronounSetsObject.Add("them");
			}
			Logger.Log((LogLevel)16, (object)"(re)generated list!");
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(AllyCardController), "UpdateInfo")]
		private static void AllyCardController_UpdateInfo(AllyCardController __instance)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.sourceMaster == (Object)null || ((Object)(object)__instance.sourceMaster.playerCharacterMasterController != (Object)null && Object.op_Implicit((Object)(object)__instance.sourceMaster.playerCharacterMasterController.networkUser)))
			{
				return;
			}
			NetworkInstanceId netId = ((NetworkBehaviour)__instance.sourceMaster).netId;
			Random random = new Random((int)((NetworkInstanceId)(ref netId)).Value);
			string text = "";
			if (RiskOfWoke.Config.MultipleSets)
			{
				int num = random.Next(2, RiskOfWoke.Config.MaxSets + 1);
				if (num > RiskOfWoke.pronounSetsSubject.Count)
				{
					RiskOfWoke.Logger.Log((LogLevel)4, (object)$"Sets to add is too high! ({num}), reducing to ({RiskOfWoke.pronounSetsSubject.Count})");
					Chat.AddMessage($"Sets to add is too high! ({num}), reducing to {RiskOfWoke.pronounSetsSubject.Count}");
					num = RiskOfWoke.pronounSetsSubject.Count;
					RiskOfWoke.Config.maxSets.Value = RiskOfWoke.pronounSetsSubject.Count;
				}
				string[] array = new string[RiskOfWoke.pronounSetsSubject.Count];
				RiskOfWoke.pronounSetsSubject.CopyTo(array);
				string[] array2 = array;
				List<string> list = new List<string>(array2.Length);
				list.AddRange(array2);
				List<string> list2 = list;
				for (int i = 0; i < num; i++)
				{
					int index = random.Next(list2.Count);
					text += list2[index];
					list2.RemoveAt(index);
					if (i + 1 < num)
					{
						text += "/";
					}
				}
			}
			else
			{
				text += RiskOfWoke.pronounSetsSubject[random.Next(RiskOfWoke.pronounSetsSubject.Count)];
				text += "/";
				text += RiskOfWoke.pronounSetsObject[random.Next(RiskOfWoke.pronounSetsObject.Count)];
			}
			TextMeshProUGUI nameLabel = __instance.nameLabel;
			((TMP_Text)nameLabel).text = ((TMP_Text)nameLabel).text + " (" + text + ")";
		}
	}
}