Decompiled source of Gabibbo Cosmetic v1.0.4

PippoLaPippa.dll

Decompiled a year ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MoreCompany.Cosmetics;
using MoreCompany.Utils;
using Test.Cosmetics;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fb6e6c68-72c9-48be-a4f8-8914138efdf4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Test
{
	[BepInPlugin("Pippo.PippoModel", "Pippo Model", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "Pippo.PippoModel";

		private const string modName = "Pippo Model";

		private const string modVersion = "1.0.0.0";

		private static Harmony _harmony;

		private bool _initialized;

		private static Plugin istance;

		public static ManualLogSource mls;

		static Plugin()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			mls = Logger.CreateLogSource("Pippo.PippoModel");
			_harmony = new Harmony("Pippo.PippoModel");
		}

		private void Awake()
		{
			if ((Object)(object)istance == (Object)null)
			{
				istance = this;
			}
			_harmony.PatchAll();
			mls.LogInfo((object)"Pippo Model loaded!");
		}

		public void Start()
		{
			if (_initialized)
			{
				_initialized = true;
				Init();
			}
		}

		public void OnDestroy()
		{
			if (!_initialized)
			{
				_initialized = true;
				Init();
			}
		}

		private void Init()
		{
			List<StreamCosmeticGeneric> cosmetics = new List<StreamCosmeticGeneric>
			{
				new Gabibbo(),
				new KrustyHatFixed(),
				new MortyHead(),
				new RickHead(),
				new Squidward(),
				new WalterWhite()
			};
			LoadAssets(cosmetics);
		}

		private void LoadAssets(IEnumerable<StreamCosmeticGeneric> cosmetics)
		{
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			mls.LogInfo((object)"Loading assets for LRCCosmetics");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			if ((object)executingAssembly == null)
			{
				mls.LogError((object)"Failed to get assemlby.");
			}
			foreach (StreamCosmeticGeneric cosmetic in cosmetics)
			{
				AssetBundle val = BundleUtilities.LoadBundleFromInternalAssembly(cosmetic.StreamingPath, executingAssembly);
				GameObject val2 = AssetBundleExtension.LoadPersistentAsset<GameObject>(val, ((CosmeticGeneric)cosmetic).gameObjectPath);
				if ((Object)(object)val2 == (Object)null)
				{
					mls.LogError((object)("Failed to find GameObject for cosmetic '" + ((CosmeticGeneric)cosmetic).cosmeticId + "' at path '" + ((CosmeticGeneric)cosmetic).gameObjectPath + "'"));
					continue;
				}
				Texture2D val3 = AssetBundleExtension.LoadPersistentAsset<Texture2D>(val, ((CosmeticGeneric)cosmetic).textureIconPath);
				if ((Object)(object)val3 == (Object)null)
				{
					mls.LogError((object)("Failed to find icon Texture2D for cosmetic '" + ((CosmeticGeneric)cosmetic).cosmeticId + " at path '" + ((CosmeticGeneric)cosmetic).textureIconPath + "'"));
				}
				else
				{
					CosmeticInstance val4 = val2.AddComponent<CosmeticInstance>();
					val4.cosmeticId = ((CosmeticGeneric)cosmetic).cosmeticId;
					val4.icon = val3;
					val4.cosmeticType = ((CosmeticGeneric)cosmetic).cosmeticType;
					CosmeticRegistry.cosmeticInstances.Add(((CosmeticGeneric)cosmetic).cosmeticId, val4);
					mls.LogInfo((object)("Successfully loaded cosmetic: " + ((CosmeticGeneric)cosmetic).cosmeticId));
				}
				string[] allAssetNames = val.GetAllAssetNames();
				string[] array = allAssetNames;
				foreach (string text in array)
				{
					mls.LogInfo((object)text);
				}
			}
		}
	}
}
namespace Test.Cosmetics
{
	public class KrustyHatFixed : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.krustyhat";

		public override string gameObjectPath => "Assets/Model/krusty_hat/krusty_hat.prefab";

		public override string textureIconPath => "Assets/Model/krusty_hat/krusty_hat_icon.png";

		public override string StreamingPath => "Test.Resources.krusty-hat";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public class WalterWhite : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.walter_white";

		public override string gameObjectPath => "Assets/Model/walter_white/walter_white.prefab";

		public override string textureIconPath => "Assets/Model/walter_white/walter_white_icon.png";

		public override string StreamingPath => "Test.Resources.walter-white";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public class RickHead : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.rick";

		public override string gameObjectPath => "Assets/Model/rick/rick.prefab";

		public override string textureIconPath => "Assets/Model/rick/rick_icon.png";

		public override string StreamingPath => "Test.Resources.rick";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public class MortyHead : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.morty";

		public override string gameObjectPath => "Assets/Model/morty/morty.prefab";

		public override string textureIconPath => "Assets/Model/morty/morty_icon.png";

		public override string StreamingPath => "Test.Resources.morty";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public class Gabibbo : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.gabibbo";

		public override string gameObjectPath => "Assets/Model/gabibbo/Gabibbo.prefab";

		public override string textureIconPath => "Assets/Model/gabibbo/gabibbo_icon.png";

		public override string StreamingPath => "Test.Resources.gabibbo";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public class Squidward : StreamCosmeticGeneric
	{
		public override string cosmeticId => "pippomodel.squidward";

		public override string gameObjectPath => "Assets/Model/squidward/squidward.prefab";

		public override string textureIconPath => "Assets/Model/squidward/squidward_icon.png";

		public override string StreamingPath => "Test.Resources.squidward";

		public override CosmeticType cosmeticType => (CosmeticType)0;
	}
	public abstract class StreamCosmeticGeneric : CosmeticGeneric
	{
		public virtual string StreamingPath => string.Empty;
	}
}