Decompiled source of LemurianNames v1.0.2

LemurianNames.dll

Decompiled 3 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
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 Microsoft.CodeAnalysis;
using On;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LemurianNames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LemurianNames")]
[assembly: AssemblyTitle("LemurianNames")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LemurianNames
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("bouncyshield.LemurianNames", "LemurianNames", "1.0.2")]
	public class LemurianNames : BaseUnityPlugin
	{
		public class Sink : INetMessage, ISerializableObject
		{
			private NetworkInstanceId index;

			private string name;

			public Sink()
			{
			}

			public Sink(CharacterMaster charMas, string name)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				index = charMas.networkIdentity.netId;
				this.name = name;
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(index);
				writer.Write(name);
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: 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)
				index = reader.ReadNetworkId();
				name = reader.ReadString();
			}

			public void OnReceived()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (!NetworkServer.active)
				{
					Log.Info($"Recieved {index} to {name} from host");
					CharacterMaster key = CharacterMaster.instancesList.Find((CharacterMaster x) => x.networkIdentity.netId == index);
					if (friends.ContainsKey(key))
					{
						friends[key] = name;
					}
					else
					{
						friends.Add(key, name);
					}
				}
			}
		}

		public const string PluginGUID = "bouncyshield.LemurianNames";

		public const string PluginAuthor = "bouncyshield";

		public const string PluginName = "LemurianNames";

		public const string PluginVersion = "1.0.2";

		private Random random = new Random();

		private string[] prefixes = new string[14]
		{
			"Fat", "Big", "Large", "Huge", "Jumbo", "Heavy", "Serious", "Prime", "Super", "King",
			"Epic", "Grand", "Elder", "Evil"
		};

		private string[] fnames = new string[204]
		{
			"James", "Jamie", "Micheal", "Mike", "Mikey", "Robert", "Bob", "Bobby", "John", "Johnny",
			"David", "Dave", "Davie", "William", "Bill", "Will", "Billy", "Richard", "Dick", "Joseph",
			"Joe", "Joey", "Thomas", "Tom", "Tommy", "Christopher", "Chris", "Charles", "Charlie", "Daniel",
			"Dan", "Danny", "Matthew", "Matt", "Anthony", "Ant", "Tony", "Mark", "Donald", "Don",
			"Steven", "Steve", "Andrew", "Andy", "Paul", "Joshua", "Josh", "Kenneth", "Ken", "Kevin",
			"Kev", "Brian", "Timothy", "Tim", "Ronald", "Ron", "George", "Jason", "Edward", "Ed",
			"Eddie", "Jeffrey", "Geoffrey", "Jeff", "Geoff", "Ryan", "Jacob", "Nicholas", "Nick", "Gary",
			"Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon", "Benjamin", "Ben", "Samuel",
			"Sam", "Gregory", "Greg", "Alexander", "Alex", "Patrick", "Pat", "Frank", "Raymond", "Ray",
			"Jack", "Dennis", "Jerry", "Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Zachary",
			"Zach", "Douglas", "Doug", "Peter", "Pete", "Kyle", "Noah", "Ethan", "Jeremy", "Christian",
			"Walter", "Walt", "Keith", "Austin", "Roger", "Terry", "Sean", "Gerald", "Carl", "Dylan",
			"Harold", "Jordan", "Bryan", "Lawrence", "Arthur", "Gabriel", "Gabe", "Bruce", "Logan", "Billy",
			"Joe", "Alan", "Juan", "Elijah", "Willie", "Randy", "Mason", "Vincent", "Vince", "Liam",
			"Lee", "Roy", "Bobby", "Bradley", "Brad", "Russell", "Russ", "Lucas", "Luke", "Guy",
			"Friend", "Burger", "Martin", "Hugo", "Mateo", "Leo", "Manuel", "Pablo", "Enzo", "Alvaro",
			"Mario", "Adrian", "Diego", "Bruno", "Oliver", "Marco", "Antonio", "Miguel", "Javier", "Luca",
			"Liam", "Gael", "Carlos", "Jose", "Sergio", "Jorge", "Dario", "Hector", "Rodrigo", "Pau",
			"Jesus", "Guillermo", "Jaime", "Luis", "Ian", "Mohamed", "Pedro", "Amir", "Ruben", "Ivan",
			"Saul", "Raul", "Joel", "Alonso", "Fernando", "Isaac", "Fabio", "Ignacio", "Nacho", "Max",
			"Leonardo", "Donatello", "Raphael", "Michelangelo"
		};

		public static Dictionary<CharacterMaster, string> friends = new Dictionary<CharacterMaster, string>();

		public void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			NetworkingAPI.RegisterMessageType<Sink>();
			DevotedLemurianController.InitializeDevotedLemurian += new hook_InitializeDevotedLemurian(NameFriend);
			DevotionInventoryController.EvolveDevotedLumerian += new hook_EvolveDevotedLumerian(UpdateNameFriend);
			CharacterBody.GetDisplayName += new hook_GetDisplayName(EnforceNameFriend);
		}

		private void NameFriend(orig_InitializeDevotedLemurian orig, DevotedLemurianController self, ItemIndex x, DevotionInventoryController y)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			orig.Invoke(self, x, y);
			CharacterMaster lemurianMaster = self._lemurianMaster;
			string text = fnames[random.Next(fnames.Length)];
			friends.Add(lemurianMaster, text);
			if (NetworkServer.active)
			{
				NetMessageExtensions.Send((INetMessage)new Sink(lemurianMaster, text), (NetworkDestination)1);
			}
		}

		private void UpdateNameFriend(orig_EvolveDevotedLumerian orig, DevotionInventoryController self, DevotedLemurianController x)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			orig.Invoke(self, x);
			if (x.DevotedEvolutionLevel == 2)
			{
				CharacterMaster lemurianMaster = x._lemurianMaster;
				string text = prefixes[random.Next(prefixes.Length)] + " " + friends[lemurianMaster];
				if (text == "King Burger")
				{
					text = "Burger King";
				}
				friends[lemurianMaster] = text;
				if (NetworkServer.active)
				{
					NetMessageExtensions.Send((INetMessage)new Sink(lemurianMaster, text), (NetworkDestination)1);
				}
			}
		}

		private string EnforceNameFriend(orig_GetDisplayName orig, CharacterBody self)
		{
			try
			{
				return friends[self._master];
			}
			catch
			{
				return orig.Invoke(self);
			}
		}
	}
	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);
		}
	}
}
namespace LemurianNames.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("LemurianNames.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

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

		internal Resources()
		{
		}
	}
}