Decompiled source of AnichanCommandoSkin v1.1.1

plugins/AnichanSkin.dll

Decompiled 9 months 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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.Rendering;

[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 = ".NET Standard 2.0")]
[assembly: AssemblyCompany("AnichanSkin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b5db60e0131a279a3ca0de367891b90ce2622687")]
[assembly: AssemblyProduct("AnichanSkin")]
[assembly: AssemblyTitle("AnichanSkin")]
[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 ExamplePlugin
{
	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 AnichanSkin
{
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.NotArme.AnichanSkin", "AnichanCommandoSkin", "1.1.1")]
	public class AnichanSkin : BaseUnityPlugin
	{
		private static AssetBundle skinAssetBundle;

		public void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AnichanSkin.anichan"))
			{
				skinAssetBundle = AssetBundle.LoadFromStream(stream);
			}
			SurvivorCatalog.Init += (hook_Init)delegate(orig_Init orig)
			{
				orig.Invoke();
				AddSkin();
			};
			LanguageAPI.Add("ANICHAN_SKIN", "Ani-chan", "en");
			LanguageAPI.Add("ANICHAN_2023", "Ani-chan 2023 uniform", "en");
			LanguageAPI.Add("ANICHAN_FURRY", "Furry Ani-chan", "en");
			LanguageAPI.Add("ANICHAN_COMMUNIST", "Communist Ani-chan", "en");
			LanguageAPI.Add("ANICHAN_SKIN", "Ani-chan", "pt-br");
			LanguageAPI.Add("ANICHAN_2023", "Ani-chan uniforme de 2023", "pt-br");
			LanguageAPI.Add("ANICHAN_FURRY", "Ani-chan furry", "pt-br");
			LanguageAPI.Add("ANICHAN_COMMUNIST", "Ani-chan comunista", "pt-br");
		}

		private void AddSkin()
		{
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody");
			ModelSkinController componentInChildren = val.GetComponentInChildren<ModelSkinController>();
			SkinDefinition skinDefinition = new SkinDefinition(val, skinAssetBundle);
			SkinDefInfo[] array = (SkinDefInfo[])(object)new SkinDefInfo[4]
			{
				skinDefinition.DefaultSkin(),
				skinDefinition.UniformSkin(),
				skinDefinition.CommunistSkin(),
				skinDefinition.FurrySkin()
			};
			SkinDefInfo[] array2 = array;
			foreach (SkinDefInfo val2 in array2)
			{
				Array.Resize(ref componentInChildren.skins, componentInChildren.skins.Length + 1);
				componentInChildren.skins[componentInChildren.skins.Length - 1] = Skins.CreateNewSkinDef(val2);
				SkinDef[][] fieldValue = Reflection.GetFieldValue<SkinDef[][]>(typeof(BodyCatalog), "skins");
				BodyCatalog.skins[BodyCatalog.FindBodyIndex(val)] = componentInChildren.skins;
				Reflection.SetFieldValue<SkinDef[][]>(typeof(BodyCatalog), "skins", fieldValue);
			}
		}
	}
	public class SkinDefinition
	{
		private GameObject bodyPrefab;

		private AssetBundle skinAssetBundle;

		private Renderer[] renderers;

		private ModelSkinController skinController;

		private GameObject mdl;

		public SkinDefinition(GameObject body, AssetBundle assetBundle)
		{
			bodyPrefab = body;
			skinAssetBundle = assetBundle;
			renderers = bodyPrefab.GetComponentsInChildren<Renderer>(true);
			skinController = bodyPrefab.GetComponentInChildren<ModelSkinController>();
			mdl = ((Component)skinController).gameObject;
		}

		public SkinDefInfo DefaultSkin()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			SkinDefInfo result = default(SkinDefInfo);
			result.Icon = Skins.CreateSkinIcon(Color.white, new Color(0f, 0.39f, 0.2f), Color.black, new Color(1f, 0.38f, 0f));
			result.Name = "AnichanDefault";
			result.NameToken = "ANICHAN_SKIN";
			result.RootObject = mdl;
			result.BaseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			result.GameObjectActivations = Array.Empty<GameObjectActivation>();
			result.RendererInfos = (RendererInfo[])(object)new RendererInfo[1]
			{
				new RendererInfo
				{
					defaultMaterial = skinAssetBundle.LoadAsset<Material>("Assets/AnichanDefaultMat.mat"),
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false,
					renderer = renderers[6]
				}
			};
			result.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
			{
				new MeshReplacement
				{
					mesh = skinAssetBundle.LoadAsset<Mesh>("Assets/AnichanMesh.mesh"),
					renderer = renderers[6]
				}
			};
			result.ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			result.MinionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			return result;
		}

		public SkinDefInfo UniformSkin()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			SkinDefInfo result = default(SkinDefInfo);
			result.Icon = Skins.CreateSkinIcon(Color.black, new Color(0f, 0.39f, 0.2f), Color.black, new Color(1f, 0.38f, 0f));
			result.Name = "Anichan2023";
			result.NameToken = "ANICHAN_2023";
			result.RootObject = mdl;
			result.BaseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			result.GameObjectActivations = Array.Empty<GameObjectActivation>();
			result.RendererInfos = (RendererInfo[])(object)new RendererInfo[1]
			{
				new RendererInfo
				{
					defaultMaterial = skinAssetBundle.LoadAsset<Material>("Assets/Anichan2023Mat.mat"),
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false,
					renderer = renderers[6]
				}
			};
			result.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
			{
				new MeshReplacement
				{
					mesh = skinAssetBundle.LoadAsset<Mesh>("Assets/AnichanMesh.mesh"),
					renderer = renderers[6]
				}
			};
			result.ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			result.MinionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			return result;
		}

		public SkinDefInfo CommunistSkin()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			SkinDefInfo result = default(SkinDefInfo);
			result.Icon = Skins.CreateSkinIcon(Color.yellow, Color.red, Color.red, Color.red);
			result.Name = "AnichanCommunist";
			result.NameToken = "ANICHAN_COMMUNIST";
			result.RootObject = mdl;
			result.BaseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			result.GameObjectActivations = Array.Empty<GameObjectActivation>();
			result.RendererInfos = (RendererInfo[])(object)new RendererInfo[1]
			{
				new RendererInfo
				{
					defaultMaterial = skinAssetBundle.LoadAsset<Material>("Assets/AnichanCommunistMat.mat"),
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false,
					renderer = renderers[6]
				}
			};
			result.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
			{
				new MeshReplacement
				{
					mesh = skinAssetBundle.LoadAsset<Mesh>("Assets/AnichanMesh.mesh"),
					renderer = renderers[6]
				}
			};
			result.ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			result.MinionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			return result;
		}

		public SkinDefInfo FurrySkin()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			SkinDefInfo result = default(SkinDefInfo);
			result.Icon = Skins.CreateSkinIcon(Color.white, new Color(1f, 0.75f, 0.6f), new Color(0f, 0.39f, 0.2f), new Color(1f, 0.38f, 0f));
			result.Name = "AnichanFurry";
			result.NameToken = "ANICHAN_FURRY";
			result.RootObject = mdl;
			result.BaseSkins = (SkinDef[])(object)new SkinDef[1] { skinController.skins[0] };
			result.GameObjectActivations = Array.Empty<GameObjectActivation>();
			result.RendererInfos = (RendererInfo[])(object)new RendererInfo[1]
			{
				new RendererInfo
				{
					defaultMaterial = skinAssetBundle.LoadAsset<Material>("Assets/AnichanFurryMat.mat"),
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false,
					renderer = renderers[6]
				}
			};
			result.MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[1]
			{
				new MeshReplacement
				{
					mesh = skinAssetBundle.LoadAsset<Mesh>("Assets/AnichanMesh.mesh"),
					renderer = renderers[6]
				}
			};
			result.ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>();
			result.MinionSkinReplacements = Array.Empty<MinionSkinReplacement>();
			return result;
		}
	}
}