Decompiled source of Sex Mod Pre Alpha v0.1.6

SexMod.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
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 EmotesAPI;
using Microsoft.CodeAnalysis;
using RoR2;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b0f55d2d64aa410c9eb3a7eafe3a0480f516c06f")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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 SexMod
{
	internal static class Assets
	{
		internal static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>();

		private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>();

		internal static void LoadAssetBundlesFromFolder(string folderName)
		{
			folderName = Path.Combine(Path.GetDirectoryName(SexMod.PInfo.Location), folderName);
			string[] files = Directory.GetFiles(folderName);
			foreach (string text in files)
			{
				AssetBundle val = AssetBundle.LoadFromFile(text);
				int count = AssetBundles.Count;
				AssetBundles.Add(val);
				string[] allAssetNames = val.GetAllAssetNames();
				foreach (string text2 in allAssetNames)
				{
					string text3 = text2.ToLowerInvariant();
					if (text3.StartsWith("assets/"))
					{
						text3 = text3.Remove(0, "assets/".Length);
					}
					AssetIndices[text3] = count;
				}
				DebugClass.Log((object)("Loaded AssetBundle: " + Path.GetFileName(text)));
			}
		}

		internal static T Load<T>(string assetName) where T : Object
		{
			try
			{
				assetName = assetName.ToLowerInvariant();
				if (assetName.Contains(":"))
				{
					string[] array = assetName.Split(new char[1] { ':' });
					assetName = array[1].ToLowerInvariant();
				}
				if (assetName.StartsWith("assets/"))
				{
					assetName = assetName.Remove(0, "assets/".Length);
				}
				int index = AssetIndices[assetName];
				return AssetBundles[index].LoadAsset<T>("assets/" + assetName);
			}
			catch (Exception arg)
			{
				DebugClass.Log((object)$"Couldn't load asset [{assetName}] reason: {arg}");
				return default(T);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Pocor.SexMod", "SexMod", "0.1.4")]
	public class SexMod : BaseUnityPlugin
	{
		public static SexMod Instance;

		public const string PluginGUID = "Pocor.SexMod";

		public const string PluginAuthor = "Pocor";

		public const string PluginName = "SexMod";

		public const string PluginVersion = "0.1.4";

		private GameObject[] candidates;

		private GameObject player;

		private GameObject playerAnimator;

		private GameObject temphurtbox;

		private GameObject mate;

		private BoneMapper playerSkeleton;

		private BoneMapper mateSkeleton;

		private AssetBundle downedBundle;

		private bool healthLow = false;

		private bool weak = false;

		private bool sexed = false;

		private bool gameStarted = false;

		private bool stunned = false;

		private Vector3 direction;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			PInfo = ((BaseUnityPlugin)this).Info;
			LoadBundle();
		}

		public void Update()
		{
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Invalid comparison between Unknown and I4
			if ((Object)(object)player != (Object)null && !gameStarted)
			{
				gameStarted = true;
				OnGameStart();
			}
			else if (gameStarted && (Object)(object)player == (Object)null)
			{
				gameStarted = false;
				Debug.LogWarning((object)"Game Off");
			}
			if (gameStarted)
			{
				UpdatePlayerHealth();
			}
			if (healthLow && !weak)
			{
				SexModAtPlay();
			}
			if (weak && !healthLow)
			{
				UnStunned();
				Sexnt();
				UnStunned();
			}
			if (Object.op_Implicit((Object)(object)mate) && mate.gameObject.GetComponent<HealthComponent>().health <= 0f)
			{
				Object.Destroy((Object)(object)mate.gameObject);
			}
			try
			{
				if (!gameStarted)
				{
					candidates = GameObject.FindGameObjectsWithTag("Player");
					GameObject[] array = candidates;
					GameObject[] array2 = array;
					foreach (GameObject val in array2)
					{
						if ((int)val.GetComponent<TeamComponent>().teamIndex == 1)
						{
							player = val.gameObject;
							temphurtbox = GameObject.Find("TempHurtbox");
						}
					}
					if ((Object)(object)player == (Object)null)
					{
						player = GameObject.Find("CrocoBody(Clone)");
					}
				}
			}
			catch (NullReferenceException)
			{
			}
			try
			{
				if ((Object)(object)player != (Object)null)
				{
					UpdatePlayerHealth();
				}
			}
			catch (IndexOutOfRangeException)
			{
			}
		}

		public void OnGameStart()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			UpdatePlayerHealth();
			Debug.LogWarning((object)"Game On");
			BoneMapper[] allBoneMappers = CustomEmotesAPI.GetAllBoneMappers();
			BoneMapper[] array = allBoneMappers;
			foreach (BoneMapper val in array)
			{
				if ((int)((Component)val.mapperBody).GetComponentInParent<TeamComponent>().teamIndex == 1)
				{
					playerSkeleton = val;
				}
			}
		}

		private void UpdatePlayerHealth()
		{
			if ((Object)(object)player != (Object)null)
			{
				HealthComponent component = player.GetComponent<HealthComponent>();
				if ((Object)(object)component != (Object)null)
				{
					healthLow = component.isHealthLow;
				}
			}
		}

		public void LoadBundle()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Assets.LoadAssetBundlesFromFolder("assets");
			AnimationClipParams val = new AnimationClipParams();
			val.animationClip = (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("@Pocor-Sex_Mod_Pre_Alpha:assets/Animations/downed.anim") };
			val.looping = true;
			CustomEmotesAPI.AddCustomAnimation(val);
			val.animationClip = (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("@Pocor-Sex_Mod_Pre_Alpha:assets/Animations/falling.anim") };
			val.looping = true;
			CustomEmotesAPI.AddCustomAnimation(val);
		}

		public void Stunned()
		{
			Debug.LogWarning((object)"stunned");
			player.GetComponent<HealthComponent>().godMode = false;
			((Behaviour)player.GetComponent<CharacterMotor>()).enabled = true;
			player.GetComponent<HealthComponent>().godMode = true;
			((Behaviour)player.GetComponent<CharacterMotor>()).enabled = false;
			((Behaviour)player.GetComponent<CharacterDirection>()).enabled = false;
			stunned = true;
		}

		public void UnStunned()
		{
			Debug.LogWarning((object)"unstunned");
			player.GetComponent<HealthComponent>().godMode = true;
			((Behaviour)player.GetComponent<CharacterMotor>()).enabled = false;
			player.GetComponent<HealthComponent>().godMode = false;
			((Behaviour)player.GetComponent<CharacterMotor>()).enabled = true;
			((Behaviour)player.GetComponent<CharacterDirection>()).enabled = true;
			stunned = false;
		}

		public void SexModAtPlay()
		{
			Stunned();
			Sex();
			EXTERMINATUS();
			MateSex();
			Stunned();
		}

		public void MateSex()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			mate = player.GetComponent<HealthComponent>().lastHitAttacker;
			if (Object.op_Implicit((Object)(object)mate))
			{
				((Behaviour)mate.GetComponent<CharacterMotor>()).enabled = false;
				BoneMapper[] allBoneMappers = CustomEmotesAPI.GetAllBoneMappers();
				BoneMapper[] array = allBoneMappers;
				foreach (BoneMapper val in array)
				{
					if ((Object)(object)((Component)val.mapperBody).gameObject == (Object)(object)player.GetComponent<HealthComponent>().lastHitAttacker && (int)((Component)val.mapperBody).GetComponent<TeamComponent>().teamIndex != 1)
					{
						mateSkeleton = val;
					}
				}
			}
			else
			{
				Debug.LogWarning((object)"Mate Not Found");
			}
			((MonoBehaviour)this).StartCoroutine(TeleportAndPlayAnimation());
		}

		private IEnumerator TeleportAndPlayAnimation()
		{
			direction = player.GetComponent<CharacterDirection>().forward;
			yield return (object)new WaitForSeconds(0.2f);
			((Behaviour)mate.GetComponent<CharacterDirection>()).enabled = false;
			yield return (object)new WaitForSeconds(0.2f);
			Vector3 teleportPosition = player.GetComponent<CharacterBody>().footPosition;
			TeleportHelper.TeleportBody(mate.GetComponent<CharacterBody>(), teleportPosition);
			yield return (object)new WaitForSeconds(0.1f);
			if (Object.op_Implicit((Object)(object)mate) && Object.op_Implicit((Object)(object)mateSkeleton))
			{
				try
				{
					((Collider)mate.gameObject.GetComponent<CapsuleCollider>()).enabled = false;
					((Behaviour)mate.GetComponent<CharacterDirection>()).enabled = false;
					CustomEmotesAPI.PlayAnimation("JackOPose", mateSkeleton, -2);
					((Collider)mate.gameObject.GetComponent<CapsuleCollider>()).enabled = false;
					((Behaviour)mate.gameObject.GetComponent<CharacterMotor>()).enabled = false;
					((Behaviour)mate.gameObject.GetComponent<CharacterDirection>()).enabled = false;
					mate.gameObject.SetActive(false);
				}
				catch (NullReferenceException)
				{
					Debug.LogWarning((object)"Couldn't Freeze");
				}
			}
		}

		public void EXTERMINATUS()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			BoneMapper[] allBoneMappers = CustomEmotesAPI.GetAllBoneMappers();
			BoneMapper[] array = allBoneMappers;
			foreach (BoneMapper val in array)
			{
				if ((Object)(object)((Component)val.mapperBody).gameObject != (Object)(object)player.GetComponent<HealthComponent>().lastHitAttacker && (int)((Component)val.mapperBody).GetComponent<TeamComponent>().teamIndex != 1)
				{
					((Component)val.mapperBody).GetComponent<HealthComponent>().health = 0f;
				}
				else if ((Object)(object)((Component)val.mapperBody).gameObject == (Object)(object)player.GetComponent<HealthComponent>().lastHitAttacker)
				{
					mateSkeleton = val;
				}
			}
			if (((Object)((Component)mateSkeleton.mapperBody).gameObject).name == "WispBody(Clone)")
			{
				((Component)mateSkeleton.mapperBody).GetComponent<HealthComponent>().health = 0f;
				return;
			}
			mate = player.GetComponent<HealthComponent>().lastHitAttacker;
			Debug.LogWarning((object)mate);
		}

		public void Sex()
		{
			Chat.AddMessage("<color=#FF69B4>You feel Weak and Breedable</color>");
			weak = true;
			if ((Object)(object)temphurtbox != (Object)null)
			{
				temphurtbox.SetActive(false);
			}
			else if ((Object)(object)temphurtbox == (Object)null)
			{
				temphurtbox = GameObject.Find("TemporaryHurtbox");
				Debug.Log((object)temphurtbox);
			}
			GenericSkill[] components = player.GetComponents<GenericSkill>();
			GenericSkill[] array = components;
			foreach (GenericSkill val in array)
			{
				if (val.stock >= 0)
				{
					val.stock = 0;
				}
				((Behaviour)val).enabled = false;
			}
			if ((Object)(object)playerSkeleton != (Object)null)
			{
				CustomEmotesAPI.PlayAnimation("falling", playerSkeleton, -2);
			}
			else
			{
				Debug.LogError((object)"Player's BoneMapper is null.");
			}
		}

		public void Sexnt()
		{
			Chat.AddMessage("<color=#FF69B4>finally recovered</color>");
			if ((Object)(object)temphurtbox != (Object)null)
			{
				temphurtbox.SetActive(true);
			}
			GenericSkill[] components = player.GetComponents<GenericSkill>();
			GenericSkill[] array = components;
			foreach (GenericSkill val in array)
			{
				((Behaviour)val).enabled = true;
			}
			if ((Object)(object)playerSkeleton != (Object)null)
			{
				CustomEmotesAPI.PlayAnimation("none", playerSkeleton, -2);
			}
			else
			{
				Debug.LogError((object)"Player's BoneMapper is null.");
			}
			weak = false;
			Debug.LogWarning((object)"sexen'ted");
			if (Object.op_Implicit((Object)(object)mate))
			{
				Object.Destroy((Object)(object)mate.gameObject);
			}
		}
	}
}