Decompiled source of FriendlyFaces v1.0.2

Xelf.FriendlyFaces.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("Xelf.FriendlyFaces")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+df82d7a746d78d366f0e33c15016f95790faf6e9")]
[assembly: AssemblyProduct("FriendlyFaces")]
[assembly: AssemblyTitle("Xelf.FriendlyFaces")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 FriendlyFaces
{
	[BepInPlugin("Xelf.FriendlyFaces", "FriendlyFaces", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class FriendlyFaces : BaseUnityPlugin
	{
		public static AssetBundle CustomAssets;

		public static ConfigFile MyConfig;

		public static FriendlyFaces Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			int rarity = 30;
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			MyConfig = ((BaseUnityPlugin)this).Config;
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("FriendlyFaces.assets.friendlyfaces");
			CustomAssets = AssetBundle.LoadFromStream(manifestResourceStream);
			if ((Object)(object)CustomAssets == (Object)null)
			{
				Logger.LogError((object)"Xelf.FriendlyFaces v1.0.2 failed loading assets!");
				return;
			}
			MyConfig.SaveOnConfigSet = false;
			string[] names = new string[3] { "Honza", "Jirka", "Mára" };
			string[] paths = new string[3] { "assets/models/Honza.asset", "assets/models/Jirka.asset", "assets/models/Mára.asset" };
			RegisterItems(rarity, names, paths);
			MyConfig.Save();
			MyConfig.SaveOnConfigSet = true;
			Patch();
			Logger.LogInfo((object)"Xelf.FriendlyFaces v1.0.2 has loaded!\n\nKdybych měl lopatu, tak ti rozmlátím držku!\n");
		}

		internal static void RegisterItems(int rarity, string[] names, string[] paths)
		{
			for (int i = 0; i < names.Length; i++)
			{
				Instance.RegisterHead(names[i], paths[i], rarity);
			}
		}

		internal void RegisterHead(string name, string path, int rarity)
		{
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("General", name + " Rarity", rarity, $"{name}'s item rarity. Default: {rarity}");
			Item val2 = CustomAssets.LoadAsset<Item>(path);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Items.RegisterScrap(val2, val.Value, (LevelTypes)(-1));
		}

		internal static void Patch()
		{
			//IL_000d: 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: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Xelf.FriendlyFaces");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Xelf.FriendlyFaces";

		public const string PLUGIN_NAME = "FriendlyFaces";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}