Decompiled source of TossedInTransit v1.1.0

TossedInTransit.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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("TossedInTransit")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+23ea7e10894255552568fa9c678395df455738b0")]
[assembly: AssemblyProduct("TossedInTransit")]
[assembly: AssemblyTitle("TossedInTransit")]
[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 TossedInTransit
{
	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);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("swuff.TossedInTransit", "TossedInTransit", "1.1.0")]
	public class TossedInTransitPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "swuff.TossedInTransit";

		public const string PluginAuthor = "swuff";

		public const string PluginName = "TossedInTransit";

		public const string PluginVersion = "1.1.0";

		public static List<GameObject> ungrabbables = new List<GameObject>();

		public static ConfigEntry<bool> GrabbableBosses { get; set; }

		public static ConfigEntry<string> BlacklistBodies { get; set; }

		public static ConfigEntry<bool> AllBodiesGrabbable { get; set; }

		public static ConfigEntry<bool> WarbannerConfig { get; set; }

		public static ConfigEntry<bool> WarbannerWardConfig { get; set; }

		public static ConfigEntry<bool> EffigyConfig { get; set; }

		public static ConfigEntry<bool> EffigyWardConfig { get; set; }

		public static ConfigEntry<bool> RachisConfig { get; set; }

		public static ConfigEntry<bool> RachisWardConfig { get; set; }

		public static ConfigEntry<bool> VendingMachineConfig { get; set; }

		public void Awake()
		{
			MakeConfig();
			ModifyObjects();
		}

		private void OutsideInteractableLocker_LockLemurianEgg(orig_LockLemurianEgg orig, OutsideInteractableLocker self, LemurianEggController egg)
		{
			orig.Invoke(self, egg);
			SpecialObjectAttributes val = default(SpecialObjectAttributes);
			if (((Component)egg).TryGetComponent<SpecialObjectAttributes>(ref val))
			{
				val.locked = false;
			}
		}

		private void OutsideInteractableLocker_LockPurchasable(orig_LockPurchasable orig, OutsideInteractableLocker self, PurchaseInteraction purchaseInteraction)
		{
			orig.Invoke(self, purchaseInteraction);
			SpecialObjectAttributes val = default(SpecialObjectAttributes);
			if (((Component)purchaseInteraction).TryGetComponent<SpecialObjectAttributes>(ref val))
			{
				val.locked = false;
			}
		}

		private void OutsideInteractableLocker_LockInteractable(orig_LockInteractable orig, OutsideInteractableLocker self, IInteractableLockable lockableInteraction)
		{
			orig.Invoke(self, lockableInteraction);
			SpecialObjectAttributes val = default(SpecialObjectAttributes);
			if (lockableInteraction.GetGameObject().TryGetComponent<SpecialObjectAttributes>(ref val))
			{
				val.locked = false;
			}
		}

		public void MakeConfig()
		{
			WarbannerConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Warbanner", "Grabbable", true, "Make Warbanner wards grabbable?");
			WarbannerWardConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Warbanner", "Enable While Bagged", false, "If Warbanner's ward should be enabled while bagged.");
			EffigyConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Effigy of Grief", "Grabbable", true, "Make Effigy of Grief wards grabbable?");
			EffigyWardConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Effigy of Grief", "Enable While Bagged", false, "If Effigy of Grief's ward should be enabled while bagged.");
			RachisConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Mercurial Rachis", "Grabbable", true, "Make Mercurial Rachis wards grabbable?");
			RachisWardConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Mercurial Rachis", "Enable While Bagged", false, "If Mercurial Rachis' ward should be enabled while bagged.");
			VendingMachineConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Eclipse Zero", "Grabbable", true, "Make Eclipse Zero vending machines grabbable?");
			GrabbableBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("Bosses", "Grabbable", false, "Allow grabbing of regular bosses?");
			AllBodiesGrabbable = ((BaseUnityPlugin)this).Config.Bind<bool>("All Bodies", "Grabbable", false, "Allow grabbing of all bodies? WARNING: Untested. Most bodies are that are non-grabbable are marked as such for a reason.");
			BlacklistBodies = ((BaseUnityPlugin)this).Config.Bind<string>("All Bodies", "Blacklist", "BrotherBody,BrotherHurtBody,VoidRaidCrabBody,FalseSonBossBody,MiniVoidRaidCrabBody,MiniVoidRaidCrabBodyPhase1,MiniVoidRaidCrabBodyPhase2,MiniVoidRaidCrabBodyPhase3,ShopkeeperBody,FalseSonBossBody,SolusWingBody,SolusHeartBody", "A list of bodies that won't be made grabbable, even if other settings are changed.");
		}

		public void ModifyObjects()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			if (WarbannerConfig.Value)
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"edc41add154bedd4dae64def5c85e10f").WaitForCompletion();
				if ((Object)(object)val != (Object)null)
				{
					SpecialObjectAttributes val2 = val.AddComponent<SpecialObjectAttributes>();
					val2.renderersToDisable = new List<Renderer>();
					val2.behavioursToDisable = new List<MonoBehaviour>();
					val2.grabbable = true;
					val2.massOverride = 30f;
					if ((Object)(object)val.transform.Find("mdlWarbanner") != (Object)null)
					{
						Transform val3 = val.transform.Find("mdlWarbanner");
						if ((Object)(object)((Component)val3).transform.Find("Cylinder") != (Object)null)
						{
							Transform val4 = ((Component)val3).transform.Find("Cylinder");
							MeshRenderer item = default(MeshRenderer);
							if (((Component)val4).TryGetComponent<MeshRenderer>(ref item))
							{
								val2.renderersToDisable.Add((Renderer)(object)item);
							}
						}
						if ((Object)(object)val3.Find("Plane") != (Object)null)
						{
							Transform val5 = val3.Find("Plane");
							SkinnedMeshRenderer item2 = default(SkinnedMeshRenderer);
							if (((Component)val5).TryGetComponent<SkinnedMeshRenderer>(ref item2))
							{
								val2.renderersToDisable.Add((Renderer)(object)item2);
							}
						}
					}
					val2.maxDurability = 8;
					val2.bestName = "ITEM_WARDONLEVEL_NAME";
					val2.portraitIcon = (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"995feee7dc6193049b86bcf709bb749e").WaitForCompletion();
					BuffWard item3 = default(BuffWard);
					if (val.TryGetComponent<BuffWard>(ref item3) && !WarbannerWardConfig.Value)
					{
						val2.behavioursToDisable.Add((MonoBehaviour)(object)item3);
					}
				}
			}
			if (EffigyConfig.Value)
			{
				GameObject val6 = Addressables.LoadAssetAsync<GameObject>((object)"cc9acad8def435a4b90a2db0cf3c7f0b").WaitForCompletion();
				if ((Object)(object)val6 != (Object)null)
				{
					SpecialObjectAttributes val7 = val6.AddComponent<SpecialObjectAttributes>();
					val7.renderersToDisable = new List<Renderer>();
					val7.behavioursToDisable = new List<MonoBehaviour>();
					val7.collisionToDisable = new List<GameObject>();
					val7.objectsToDetach = new List<GameObject>();
					val7.lightsToDisable = new List<Light>();
					val7.grabbable = true;
					val7.massOverride = 200f;
					if ((Object)(object)val6.transform.Find("Totem") != (Object)null)
					{
						Transform val8 = val6.transform.Find("Totem");
						if ((Object)(object)val8.Find("Mesh") != (Object)null)
						{
							Transform val9 = val8.Find("Mesh");
							MeshRenderer item4 = default(MeshRenderer);
							if (((Component)val9).TryGetComponent<MeshRenderer>(ref item4))
							{
								val7.renderersToDisable.Add((Renderer)(object)item4);
							}
							val7.collisionToDisable.Add(((Component)val9).gameObject);
						}
						if ((Object)(object)val8.Find("Infection") != (Object)null)
						{
							Transform val10 = val8.Find("Infection");
							ParticleSystemRenderer item5 = default(ParticleSystemRenderer);
							if (((Component)val10).TryGetComponent<ParticleSystemRenderer>(ref item5))
							{
								val7.renderersToDisable.Add((Renderer)(object)item5);
							}
						}
						if ((Object)(object)val8.Find("Point Light") != (Object)null)
						{
							Transform val11 = val8.Find("Point Light");
							Light item6 = default(Light);
							if (((Component)val11).TryGetComponent<Light>(ref item6))
							{
								val7.lightsToDisable.Add(item6);
							}
						}
					}
					if ((Object)(object)val6.transform.Find("Decal") != (Object)null)
					{
						Transform val12 = val6.transform.Find("Decal");
						val7.objectsToDetach.Add(((Component)val12).gameObject);
					}
					val7.maxDurability = 8;
					val7.bestName = "EQUIPMENT_CRIPPLEWARD_NAME";
					val7.portraitIcon = (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"33fababb1ef4aaa42866994ca7b34b9e").WaitForCompletion();
					BuffWard item7 = default(BuffWard);
					if (val6.TryGetComponent<BuffWard>(ref item7) && !EffigyWardConfig.Value)
					{
						val7.behavioursToDisable.Add((MonoBehaviour)(object)item7);
					}
				}
			}
			if (RachisConfig.Value)
			{
				GameObject val13 = Addressables.LoadAssetAsync<GameObject>((object)"5e7e9975e0bdf354aa901348f9b182e7").WaitForCompletion();
				if ((Object)(object)val13 != (Object)null)
				{
					SpecialObjectAttributes val14 = val13.AddComponent<SpecialObjectAttributes>();
					val14.renderersToDisable = new List<Renderer>();
					val14.behavioursToDisable = new List<MonoBehaviour>();
					val14.collisionToDisable = new List<GameObject>();
					val14.objectsToDetach = new List<GameObject>();
					val14.lightsToDisable = new List<Light>();
					val14.grabbable = true;
					val14.massOverride = 400f;
					if ((Object)(object)val13.transform.Find("Shrinker").Find("Totem") != (Object)null)
					{
						Transform val15 = val13.transform.Find("Shrinker").Find("Totem");
						if ((Object)(object)val15.Find("Mesh") != (Object)null)
						{
							Transform val16 = val15.Find("Mesh");
							MeshRenderer item8 = default(MeshRenderer);
							if (((Component)val16).TryGetComponent<MeshRenderer>(ref item8))
							{
								val14.renderersToDisable.Add((Renderer)(object)item8);
							}
						}
						if ((Object)(object)val15.Find("ColoredLightShafts") != (Object)null)
						{
							Transform val17 = val15.Find("ColoredLightShafts");
							ParticleSystemRenderer item9 = default(ParticleSystemRenderer);
							if (((Component)val17).TryGetComponent<ParticleSystemRenderer>(ref item9))
							{
								val14.renderersToDisable.Add((Renderer)(object)item9);
							}
						}
						if ((Object)(object)val15.Find("FlamePerst_Ps") != (Object)null)
						{
							Transform val18 = val15.Find("FlamePerst_Ps");
							ParticleSystemRenderer item10 = default(ParticleSystemRenderer);
							if (((Component)val18).TryGetComponent<ParticleSystemRenderer>(ref item10))
							{
								val14.renderersToDisable.Add((Renderer)(object)item10);
							}
						}
						if ((Object)(object)val15.Find("Point Light") != (Object)null)
						{
							Transform val19 = val15.Find("Point Light");
							Light item11 = default(Light);
							if (((Component)val19).TryGetComponent<Light>(ref item11))
							{
								val14.lightsToDisable.Add(item11);
							}
						}
					}
					if ((Object)(object)val13.transform.Find("Shrinker").Find("Decal") != (Object)null)
					{
						Transform val20 = val13.transform.Find("Shrinker").Find("Decal");
						val14.objectsToDetach.Add(((Component)val20).gameObject);
					}
					val14.maxDurability = 8;
					val14.bestName = "ITEM_RANDOMDAMAGEZONE_NAME";
					val14.portraitIcon = (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"e762971bda5f0ad46b15669f6365a5de").WaitForCompletion();
					BuffWard item12 = default(BuffWard);
					if (val13.TryGetComponent<BuffWard>(ref item12) && !RachisWardConfig.Value)
					{
						val14.behavioursToDisable.Add((MonoBehaviour)(object)item12);
					}
				}
			}
			if (!VendingMachineConfig.Value)
			{
				return;
			}
			GameObject val21 = Addressables.LoadAssetAsync<GameObject>((object)"e69e4c37270ee1f4a8ecd2e60c03faad").WaitForCompletion();
			if (!((Object)(object)val21 != (Object)null))
			{
				return;
			}
			SpecialObjectAttributes val22 = val21.AddComponent<SpecialObjectAttributes>();
			val22.renderersToDisable = new List<Renderer>();
			val22.behavioursToDisable = new List<MonoBehaviour>();
			val22.collisionToDisable = new List<GameObject>();
			val22.objectsToDetach = new List<GameObject>();
			val22.grabbable = true;
			val22.massOverride = 250f;
			PurchaseInteraction item13 = default(PurchaseInteraction);
			if (val21.TryGetComponent<PurchaseInteraction>(ref item13))
			{
				val22.behavioursToDisable.Add((MonoBehaviour)(object)item13);
			}
			Highlight item14 = default(Highlight);
			if (val21.TryGetComponent<Highlight>(ref item14))
			{
				val22.behavioursToDisable.Add((MonoBehaviour)(object)item14);
			}
			if ((Object)(object)val21.transform.Find("Terrain (1)") != (Object)null)
			{
				val22.objectsToDetach.Add(((Component)val21.transform.Find("Terrain (1)")).gameObject);
			}
			if ((Object)(object)val21.transform.Find("Terrain (2)") != (Object)null)
			{
				val22.objectsToDetach.Add(((Component)val21.transform.Find("Terrain (2)")).gameObject);
			}
			if ((Object)(object)val21.transform.Find("mdlVendingMachine") != (Object)null)
			{
				Transform val23 = val21.transform.Find("mdlVendingMachine");
				val22.collisionToDisable.Add(((Component)val23).gameObject);
				MeshRenderer item15 = default(MeshRenderer);
				if (((Component)val23).TryGetComponent<MeshRenderer>(ref item15))
				{
					val22.renderersToDisable.Add((Renderer)(object)item15);
				}
				MeshRenderer item16 = default(MeshRenderer);
				if (((Component)val23.Find("mdlVendingMachineGlass")).TryGetComponent<MeshRenderer>(ref item16))
				{
					val22.renderersToDisable.Add((Renderer)(object)item16);
				}
				MeshRenderer item17 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (1)")).TryGetComponent<MeshRenderer>(ref item17))
				{
					val22.renderersToDisable.Add((Renderer)(object)item17);
				}
				MeshRenderer item18 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (2)")).TryGetComponent<MeshRenderer>(ref item18))
				{
					val22.renderersToDisable.Add((Renderer)(object)item18);
				}
				MeshRenderer item19 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (3)")).TryGetComponent<MeshRenderer>(ref item19))
				{
					val22.renderersToDisable.Add((Renderer)(object)item19);
				}
				MeshRenderer item20 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (4)")).TryGetComponent<MeshRenderer>(ref item20))
				{
					val22.renderersToDisable.Add((Renderer)(object)item20);
				}
				MeshRenderer item21 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (5)")).TryGetComponent<MeshRenderer>(ref item21))
				{
					val22.renderersToDisable.Add((Renderer)(object)item21);
				}
				MeshRenderer item22 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (6)")).TryGetComponent<MeshRenderer>(ref item22))
				{
					val22.renderersToDisable.Add((Renderer)(object)item22);
				}
				MeshRenderer item23 = default(MeshRenderer);
				if (((Component)val23.Find("mdlSodaPhoneCan (7)")).TryGetComponent<MeshRenderer>(ref item23))
				{
					val22.renderersToDisable.Add((Renderer)(object)item23);
				}
			}
			val22.maxDurability = 12;
			val22.bestName = "VENDING_MACHINE_NAME";
			val22.portraitIcon = (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"6673d9ce7b0a3224b8c555bcb4173049").WaitForCompletion();
		}

		public void ModifyBodies()
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string[] collection = BlacklistBodies.Value.Split(",");
				List<string> list = new List<string>(collection);
				foreach (string item in list)
				{
					GameObject val = BodyCatalog.FindBodyPrefab(item);
					if ((Object)(object)val != (Object)null)
					{
						ungrabbables.Add(val);
					}
				}
			}
			catch
			{
				Debug.LogError((object)"ModifyBodies : Failed to create blacklist.");
			}
			if (!GrabbableBosses.Value && !AllBodiesGrabbable.Value)
			{
				return;
			}
			foreach (CharacterBody allBodyPrefabBodyBodyComponent in BodyCatalog.allBodyPrefabBodyBodyComponents)
			{
				if (ungrabbables.Contains(((Component)allBodyPrefabBodyBodyComponent).gameObject))
				{
					break;
				}
				if (GrabbableBosses.Value && (allBodyPrefabBodyBodyComponent.isChampion || allBodyPrefabBodyBodyComponent.isBoss))
				{
					allBodyPrefabBodyBodyComponent.bodyFlags = (BodyFlags)(allBodyPrefabBodyBodyComponent.bodyFlags & -524289);
				}
				else if (AllBodiesGrabbable.Value)
				{
					allBodyPrefabBodyBodyComponent.bodyFlags = (BodyFlags)(allBodyPrefabBodyBodyComponent.bodyFlags & -524289);
				}
			}
		}
	}
}