Decompiled source of Sex Mod Pre Alpha v0.1.9

SexMod.dll

Decompiled 2 weeks ago
using System;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+839c39b4f3c608370945bef93fd15f8e60b2d3e0")]
[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(':');
					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.*/)]
	[BepInPlugin("Pocor.SexMod", "SexMod", "0.1.8")]
	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.7";

		private Transform sexLocation;

		private GameObject sexObject;

		private GameObject[] candidates;

		private GameObject player;

		private GameObject playerAnimator;

		private GameObject temphurtbox;

		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 bool alignEnemy;

		public List<GameObject> enemies = new List<GameObject>();

		public static PluginInfo PInfo { get; private set; }

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

		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;
				}
			}
		}

		public void Update()
		{
			CheckForGameStarted();
			LookForPlayer();
			UpdatePlayerHealth();
		}

		private void LookForPlayer()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			try
			{
				if (gameStarted)
				{
					return;
				}
				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)
			{
			}
		}

		private void CheckForGameStarted()
		{
			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");
			}
		}

		private void UpdatePlayerHealth()
		{
			if (gameStarted && Object.op_Implicit((Object)(object)player))
			{
				HealthComponent component = player.GetComponent<HealthComponent>();
				if ((Object)(object)component != (Object)null)
				{
					healthLow = component.isHealthLow;
				}
				if (healthLow && !weak)
				{
					SexModAtPlay();
				}
				else if (weak && !healthLow)
				{
					UnStunned();
					Sexnt();
					UnStunned();
				}
			}
		}

		public void LoadBundle()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			Assets.LoadAssetBundlesFromFolder("assets");
			foreach (AssetBundle assetBundle in Assets.AssetBundles)
			{
				Debug.LogWarning((object)"--- Bundle Contents ---");
				string[] allAssetNames = assetBundle.GetAllAssetNames();
				string[] array = allAssetNames;
				foreach (string text in array)
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
					Debug.LogWarning((object)("Asset path: " + text));
					Debug.LogWarning((object)("Asset name: " + fileNameWithoutExtension));
				}
			}
			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);
			val.animationClip = (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("@Pocor-Sex_Mod_Pre_Alpha:Assets/Animations/TopPress.anim") };
			val.looping = true;
			CustomEmotesAPI.AddCustomAnimation(val);
			val.animationClip = (AnimationClip[])(object)new AnimationClip[1] { Assets.Load<AnimationClip>("@Pocor-Sex_Mod_Pre_Alpha:Assets/Animations/BottomPress.anim") };
			val.looping = true;
			CustomEmotesAPI.AddCustomAnimation(val);
		}

		private void 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;
			Debug.LogWarning((object)"stunned");
		}

		public void 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;
			Debug.LogWarning((object)"unstunned");
		}

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

		public void SpawnSexMate()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			GameObject val = Assets.Load<GameObject>("assets/humancharacterdummy_f.prefab");
			AnimationClip val2 = Assets.Load<AnimationClip>("assets/animations/toppress.anim");
			if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
			{
				GameObject val3 = Object.Instantiate<GameObject>(val, new Vector3(player.transform.position.x, player.transform.position.y - 0.7f, player.transform.position.z), Quaternion.identity);
				Animator component = val3.GetComponent<Animator>();
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogError((object)"No Animator on dummy prefab!");
					return;
				}
				AnimatorOverrideController val4 = new AnimatorOverrideController(component.runtimeAnimatorController);
				val4["DefaultAnimation"] = val2;
				component.runtimeAnimatorController = (RuntimeAnimatorController)(object)val4;
				component.Play("DefaultAnimation");
			}
			else
			{
				Debug.LogError((object)"Failed to load dummy prefab or animation clip.");
			}
		}

		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("BottomPress", playerSkeleton, 0);
			}
			else
			{
				Debug.LogError((object)"Player's BoneMapper is null.");
			}
			playerSkeleton.AssignParentGameObject(sexObject, true, true, false, false, true);
		}

		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, 0);
				alignEnemy = false;
			}
			else
			{
				Debug.LogError((object)"Player's BoneMapper is null.");
			}
			weak = false;
			Debug.LogWarning((object)"sexen'ted");
		}

		public void EXTERMINATUS()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			BoneMapper[] allBoneMappers = CustomEmotesAPI.GetAllBoneMappers();
			BoneMapper[] array = allBoneMappers;
			foreach (BoneMapper val in array)
			{
				if ((int)((Component)val.mapperBody).GetComponent<TeamComponent>().teamIndex != 1)
				{
					((Component)val.mapperBody).GetComponent<HealthComponent>().health = 0f;
				}
			}
		}
	}
}