Decompiled source of AccessoryBending v1.0.0

Mods/AccessoryBending.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using AccessoryBending;
using HarmonyLib;
using Il2CppExitGames.Client.Photon;
using Il2CppPhoton.Pun;
using Il2CppPhoton.Realtime;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem;
using MelonLoader;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "AccessoryBending", "1.0.0", "UlvakSkillz", "https://thunderstore.io/c/rumble/p/UlvakSkillz/AccessoryBending/")]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 6, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AccessoryBending")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AccessoryBending")]
[assembly: AssemblyTitle("AccessoryBending")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AccessoryBending;

public static class BuildInfo
{
	public const string ModName = "AccessoryBending";

	public const string ModVersion = "1.0.0";

	public const string Author = "UlvakSkillz";
}
public class AssetInfo
{
	private GameObject assetToUse;

	private string boneToAttachTo;

	private Vector3 positionOffset;

	private Quaternion rotationOffset;

	private Vector3 localScale;

	private int layer;

	private string childPath;

	public AssetInfo(GameObject asset, string bone, Vector3 pOffset, Quaternion rOffset, Vector3 scale, int chosenLayer, string childsPath = "")
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		childPath = childsPath;
		assetToUse = asset;
		boneToAttachTo = bone;
		positionOffset = pOffset;
		rotationOffset = rOffset;
		localScale = scale;
		layer = chosenLayer;
	}

	public GameObject GetAssetToUse()
	{
		return assetToUse;
	}

	public string GetBoneToAttachTo()
	{
		return boneToAttachTo;
	}

	public Vector3 GetPositionOffset()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return positionOffset;
	}

	public Quaternion GetRotationOffset()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return rotationOffset;
	}

	public Vector3 GetLocalScale()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return localScale;
	}

	public int GetLayer()
	{
		return layer;
	}

	public string GetChildsPath()
	{
		return childPath;
	}

	public string GetAssetInfo()
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_0136: Unknown result type (might be due to invalid IL or missing references)
		return $"{((Object)assetToUse).name}|{boneToAttachTo}|{positionOffset.x.ToString(CultureInfo.InvariantCulture)}:{positionOffset.y.ToString(CultureInfo.InvariantCulture)}:{positionOffset.z.ToString(CultureInfo.InvariantCulture)}|{((Quaternion)(ref rotationOffset)).eulerAngles.x.ToString(CultureInfo.InvariantCulture)}:{((Quaternion)(ref rotationOffset)).eulerAngles.y.ToString(CultureInfo.InvariantCulture)}:{((Quaternion)(ref rotationOffset)).eulerAngles.z.ToString(CultureInfo.InvariantCulture)}|{localScale.x.ToString(CultureInfo.InvariantCulture)}:{localScale.y.ToString(CultureInfo.InvariantCulture)}:{localScale.z.ToString(CultureInfo.InvariantCulture)}|0|{childPath}";
	}
}
public class Main : MelonMod
{
	[HarmonyPatch(typeof(PlayerController), "Initialize", new Type[] { typeof(Player) })]
	public static class playerSpawn
	{
		private static void Postfix(ref PlayerController __instance, ref Player player)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)__instance.controllerType == 1)
			{
				for (int i = 0; i < assetInfos.Count; i++)
				{
					if (enabled[i])
					{
						PlaceAsset(__instance, assetInfos[i]);
					}
				}
			}
			else
			{
				SendRPCString();
			}
		}
	}

	[HarmonyPatch(typeof(PlayerManager), "RemovePlayer", new Type[] { typeof(Player) })]
	public static class playerLeave
	{
		private static void Prefix(ref Player player)
		{
			Player playerByActorNo = Players.GetPlayerByActorNo(player.ActorNumber);
			for (int i = 0; i < playersLoaded.Count; i++)
			{
				if (!(playersLoaded[i] == playerByActorNo.Data.GeneralData.PlayFabMasterId))
				{
					continue;
				}
				while (accessoriesToNuke[i].Count != 0)
				{
					if ((Object)(object)accessoriesToNuke[i][0] != (Object)null)
					{
						Log("Removing Their Accessory: " + ((Object)accessoriesToNuke[i][0]).name);
						Object.Destroy((Object)(object)accessoriesToNuke[i][0]);
					}
					accessoriesToNuke[i].RemoveAt(0);
				}
				playersLoaded.RemoveAt(i);
				accessoriesToNuke.RemoveAt(i);
				break;
			}
		}
	}

	[CompilerGenerated]
	private sealed class <ProcessItems>d__17 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public string[] processedString;

		public Main <>4__this;

		private int <i>5__1;

		private PlayerController <controller>5__2;

		private string[] <>s__3;

		private int <>s__4;

		private string <assetStringToLoad>5__5;

		private string[] <assetInfo>5__6;

		private bool <assetFound>5__7;

		private int <j>5__8;

		private GameObject <asset>5__9;

		private string <bone>5__10;

		private string[] <pOffsetString>5__11;

		private string[] <rOffsetString>5__12;

		private string[] <scaleString>5__13;

		private Vector3 <pOffset>5__14;

		private Quaternion <rOffset>5__15;

		private Vector3 <scale>5__16;

		private int <layer>5__17;

		private string <childsPath>5__18;

		private AssetInfo <newAsset>5__19;

		private string[] <child>5__20;

		private Exception <e>5__21;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ProcessItems>d__17(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<controller>5__2 = null;
			<>s__3 = null;
			<assetStringToLoad>5__5 = null;
			<assetInfo>5__6 = null;
			<asset>5__9 = null;
			<bone>5__10 = null;
			<pOffsetString>5__11 = null;
			<rOffsetString>5__12 = null;
			<scaleString>5__13 = null;
			<childsPath>5__18 = null;
			<newAsset>5__19 = null;
			<child>5__20 = null;
			<e>5__21 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<i>5__1 = 1;
				while (<i>5__1 < Singleton<PlayerManager>.instance.AllPlayers.Count)
				{
					if (Singleton<PlayerManager>.instance.AllPlayers[<i>5__1].Data.GeneralData.PlayFabMasterId == processedString[0])
					{
						<controller>5__2 = Singleton<PlayerManager>.instance.AllPlayers[<i>5__1].Controller;
						<>s__3 = processedString;
						for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
						{
							<assetStringToLoad>5__5 = <>s__3[<>s__4];
							if (processedString[0] == <assetStringToLoad>5__5)
							{
								Log("Processing For: " + <assetStringToLoad>5__5 + " " + <controller>5__2.assignedPlayer.Data.GeneralData.PublicUsername);
								accessoriesToNuke.Add(new List<GameObject>());
							}
							else
							{
								<assetInfo>5__6 = <assetStringToLoad>5__5.Split("|");
								if (<assetInfo>5__6[0].Length != 0)
								{
									<assetFound>5__7 = false;
									<j>5__8 = 0;
									while (<j>5__8 < assetInfos.Count)
									{
										if (((Object)assetInfos[<j>5__8].GetAssetToUse()).name == <assetInfo>5__6[0])
										{
											<assetFound>5__7 = true;
											<asset>5__9 = assetInfos[<j>5__8].GetAssetToUse();
											<bone>5__10 = <assetInfo>5__6[1];
											try
											{
												<pOffsetString>5__11 = <assetInfo>5__6[2].Split(":");
												<rOffsetString>5__12 = <assetInfo>5__6[3].Split(":");
												<scaleString>5__13 = <assetInfo>5__6[4].Split(":");
												<pOffset>5__14 = new Vector3(float.Parse(<pOffsetString>5__11[0], CultureInfo.InvariantCulture), float.Parse(<pOffsetString>5__11[1], CultureInfo.InvariantCulture), float.Parse(<pOffsetString>5__11[2], CultureInfo.InvariantCulture));
												<rOffset>5__15 = Quaternion.Euler(float.Parse(<rOffsetString>5__12[0], CultureInfo.InvariantCulture), float.Parse(<rOffsetString>5__12[1], CultureInfo.InvariantCulture), float.Parse(<rOffsetString>5__12[2], CultureInfo.InvariantCulture));
												<scale>5__16 = new Vector3(float.Parse(<scaleString>5__13[0], CultureInfo.InvariantCulture), float.Parse(<scaleString>5__13[1], CultureInfo.InvariantCulture), float.Parse(<scaleString>5__13[2], CultureInfo.InvariantCulture));
												<layer>5__17 = int.Parse(<assetInfo>5__6[5]);
												<childsPath>5__18 = ((<assetInfo>5__6.Length == 7) ? <assetInfo>5__6[6] : "");
												<newAsset>5__19 = new AssetInfo(<asset>5__9, <bone>5__10, <pOffset>5__14, <rOffset>5__15, <scale>5__16, 0, <childsPath>5__18);
												PlaceAsset(<controller>5__2, <newAsset>5__19);
												<child>5__20 = <childsPath>5__18.Split("/");
												Log("Accessory" + <assetInfo>5__6[0] + "Placed on " + <child>5__20[<child>5__20.Length - 1]);
												<pOffsetString>5__11 = null;
												<rOffsetString>5__12 = null;
												<scaleString>5__13 = null;
												<childsPath>5__18 = null;
												<newAsset>5__19 = null;
												<child>5__20 = null;
											}
											catch (Exception ex)
											{
												<e>5__21 = ex;
												MelonLogger.Error("ERROR READING INCOMING STRING FOR PLAYER: " + processedString[0]);
												MelonLogger.Error((object)<e>5__21);
											}
											break;
										}
										<j>5__8++;
									}
									if (!<assetFound>5__7)
									{
										Log("Accessory Not Found: " + <assetInfo>5__6[0]);
									}
									<assetInfo>5__6 = null;
									<assetStringToLoad>5__5 = null;
								}
							}
						}
						<>s__3 = null;
						break;
					}
					<i>5__1++;
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static List<AssetInfo> assetInfos = new List<AssetInfo>();

	private static bool[] enabled;

	public static Mod AccessoryBending = new Mod();

	private bool showOthersAssets = true;

	private static byte myEventCode = 16;

	private static RaiseEventOptions eventOptions = new RaiseEventOptions
	{
		Receivers = (ReceiverGroup)0,
		CachingOption = (EventCaching)4
	};

	private GameObject parentObject;

	private static List<List<GameObject>> accessoriesToNuke = new List<List<GameObject>>();

	private static List<string> playersLoaded = new List<string>();

	private static void Log(string msg)
	{
		MelonLogger.Msg(msg);
	}

	public override void OnLateInitializeMelon()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_0065: 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_0077: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		CheckFiles();
		AccessoryBending.ModName = "AccessoryBending";
		AccessoryBending.ModVersion = "1.0.0";
		AccessoryBending.SetFolder("AccessoryBending");
		AccessoryBending.AddToList("Show Others Accessories", true, 0, "Toggling ON will have others Accessories Shown that you have installed. (Will not Remove Accessories Already Loaded)", new Tags());
		AccessoryBending.AddToList("Nuke Others Accessories", false, 0, "Toggling ON then Saving will Remove all current Accessories from Players in the Scene. (Accessories will Come Back when a Player Enters the Room)", new Tags
		{
			DoNotSave = true
		});
		foreach (AssetInfo assetInfo in assetInfos)
		{
			AccessoryBending.AddToList(((Object)assetInfo.GetAssetToUse()).name, false, 0, "Toggling ON will have this Accessory Shown.", new Tags());
		}
		AccessoryBending.GetFromFile();
		AccessoryBending.ModSaved += Save;
		UI.instance.UI_Initialized += UIInit;
		Calls.onMapInitialized += MapInit;
		Save();
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		playersLoaded.Clear();
	}

	private void Save()
	{
		showOthersAssets = (bool)AccessoryBending.Settings[0].SavedValue;
		enabled = new bool[assetInfos.Count];
		for (int i = 0; i < enabled.Length; i++)
		{
			enabled[i] = (bool)AccessoryBending.Settings[i + 2].SavedValue;
		}
		if ((bool)AccessoryBending.Settings[1].SavedValue)
		{
			AccessoryBending.Settings[1].Value = false;
			AccessoryBending.Settings[1].SavedValue = false;
			NukeOthersAccessories();
		}
	}

	private void NukeOthersAccessories()
	{
		for (int i = 0; i < playersLoaded.Count; i++)
		{
			while (accessoriesToNuke[i].Count > 0)
			{
				if ((Object)(object)accessoriesToNuke[i][0] != (Object)null)
				{
					Object.Destroy((Object)(object)accessoriesToNuke[i][0]);
				}
				accessoriesToNuke[i].RemoveAt(0);
			}
			accessoriesToNuke[i].Clear();
		}
		accessoriesToNuke.Clear();
	}

	private void UIInit()
	{
		UI.instance.AddMod(AccessoryBending);
	}

	private void MapInit()
	{
		LoadBalancingClient networkingClient = PhotonNetwork.NetworkingClient;
		networkingClient.EventReceived += Action<EventData>.op_Implicit((Action<EventData>)OnEvent);
		if (Scene.GetSceneName() == "Gym")
		{
			CreateDressingRoomObjects();
		}
	}

	public void OnEvent(EventData eventData)
	{
		if (showOthersAssets && eventData.Code == myEventCode)
		{
			string text = eventData.CustomData.ToString();
			string[] array = text.Split(';');
			if (!playersLoaded.Contains(array[0]))
			{
				Log("Recieved Player Accessories:" + Environment.NewLine + text);
				playersLoaded.Add(array[0]);
				MelonCoroutines.Start(ProcessItems(array));
			}
		}
	}

	[IteratorStateMachine(typeof(<ProcessItems>d__17))]
	private IEnumerator ProcessItems(string[] processedString)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ProcessItems>d__17(0)
		{
			<>4__this = this,
			processedString = processedString
		};
	}

	private void CreateDressingRoomObjects()
	{
		for (int i = 0; i < assetInfos.Count; i++)
		{
			if (enabled[i])
			{
				PlaceDressingRoomAsset(assetInfos[i]);
			}
		}
	}

	private void CheckFiles()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_055b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0572: Unknown result type (might be due to invalid IL or missing references)
		if (!Directory.Exists("UserData\\AccessoryBending"))
		{
			Directory.CreateDirectory("UserData\\AccessoryBending");
			return;
		}
		string[] files = Directory.GetFiles("UserData\\AccessoryBending");
		if (files.Length == 0)
		{
			return;
		}
		List<string> list = new List<string>();
		parentObject = new GameObject();
		((Object)parentObject).name = "AssetBending Cosmetics";
		Object.DontDestroyOnLoad((Object)(object)parentObject);
		string[] array = files;
		foreach (string text in array)
		{
			try
			{
				if (!text.ToLower().EndsWith(".txt"))
				{
					list.Add(text);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error((object)ex);
			}
		}
		foreach (string item in list)
		{
			if (!File.Exists(item + ".txt"))
			{
				SaveFile($"Game Object Name{Environment.NewLine}Visuals/Skelington/Bone_Pelvis/Bone_Spine_A{Environment.NewLine}0|0|0{Environment.NewLine}0|0|0{Environment.NewLine}1|1|1{Environment.NewLine}true{Environment.NewLine}true{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}-------------------------------------------------------------------------------------------------------------------------------------------------{Environment.NewLine}{Environment.NewLine}Line 1: Name of Main Game Object (This is the Game Object Name Encompassing the Whole Cosmetic) (Found as Outter Most Object in Unity when Creating){Environment.NewLine}Line 2: The Bone Structure Path to the Spot you want it Parented (Cosmetic will Follow that Object).{Environment.NewLine}Line 3: Local Position Offset (0|0|0 will be in relation to the Parent's Rotation) (x, y, z){Environment.NewLine}Line 4: Local Rotation Offset (0|0|0 will be in relation to the Parent's Rotation) (x, y, z){Environment.NewLine}Line 5: Local Scale (1|1|1 will be the Normal Size) (x, y, z){Environment.NewLine}Line 6: Show in VR Headset (Set \"true\" or \"false\" to have the Cosmetic Visible or Not to the Headset){Environment.NewLine}Line 7: Show in Legacy Camera (Set \"true\" or \"false\" to have the Cosmetic Visible or Not to the Legacy Camera){Environment.NewLine}Line 8: If Something is in this Line, That Game Object will be Parented instead of the Line 1 Game Object. This should be the Line 1 Game Object's Child Path (not Including the Line 1 Game Object Name Itself){Environment.NewLine}", item + ".txt");
			}
			string[] array2 = File.ReadAllLines(item + ".txt");
			if (array2.Length < 7)
			{
				MelonLogger.Error("ASSET BUNDLE ERROR: " + item + ".txt HAS TOO FEW LINES!");
				continue;
			}
			string text2 = array2[0];
			string bone = array2[1];
			string[] array3 = array2[2].Split("|");
			string[] array4 = array2[3].Split("|");
			string[] array5 = array2[4].Split("|");
			string value = array2[5];
			string value2 = array2[6];
			string text3 = "";
			if (array2.Length >= 8)
			{
				text3 = array2[7];
			}
			if (array3.Length < 3 || array4.Length < 3 || array5.Length < 3)
			{
				MelonLogger.Error("ASSET BUNDLE ERROR: " + item + ".txt DOESNT HAVE ENOUGH DATA FOR POSITION ROTATION OR SCALE!");
				continue;
			}
			float[][] array6 = new float[3][];
			try
			{
				array6[0] = new float[3]
				{
					float.Parse(array3[0], CultureInfo.InvariantCulture),
					float.Parse(array3[1], CultureInfo.InvariantCulture),
					float.Parse(array3[2], CultureInfo.InvariantCulture)
				};
				array6[1] = new float[3]
				{
					float.Parse(array4[0], CultureInfo.InvariantCulture),
					float.Parse(array4[1], CultureInfo.InvariantCulture),
					float.Parse(array4[2], CultureInfo.InvariantCulture)
				};
				array6[2] = new float[3]
				{
					float.Parse(array5[0], CultureInfo.InvariantCulture),
					float.Parse(array5[1], CultureInfo.InvariantCulture),
					float.Parse(array5[2], CultureInfo.InvariantCulture)
				};
			}
			catch (Exception ex2)
			{
				MelonLogger.Error("ASSET BUNDLE ERROR: " + item + ".txt DATA CONVERSION ERROR: POSITION ROTATION OR SCALE string -> float!");
				MelonLogger.Error((object)ex2);
				continue;
			}
			bool[] array7 = new bool[2];
			try
			{
				array7[0] = bool.Parse(value);
				array7[1] = bool.Parse(value2);
			}
			catch (Exception ex3)
			{
				MelonLogger.Error("ASSET BUNDLE ERROR: " + item + ".txt DATA CONVERSION ERROR: SHOW IN HEADSET SHOW IN LEGACY CAM string -> bool!");
				MelonLogger.Error((object)ex3);
				continue;
			}
			GameObject val = SpawnDDOLAsset(item, text2);
			if ((Object)(object)val != (Object)null)
			{
				AssetInfo assetInfo = ((!(text3 != "")) ? new AssetInfo(val, bone, new Vector3(array6[0][0], array6[0][1], array6[0][2]), Quaternion.Euler(array6[1][0], array6[1][1], array6[1][2]), new Vector3(array6[2][0], array6[2][1], array6[2][2]), GetLayer(array7[0], array7[1])) : new AssetInfo(val, bone, new Vector3(array6[0][0], array6[0][1], array6[0][2]), Quaternion.Euler(array6[1][0], array6[1][1], array6[1][2]), new Vector3(array6[2][0], array6[2][1], array6[2][2]), GetLayer(array7[0], array7[1]), text3));
				assetInfos.Add(assetInfo);
				Log("Accessory Loaded: " + item + " | " + ((Object)assetInfo.GetAssetToUse()).name);
				continue;
			}
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
			MelonLogger.Error("ASSET ERROR: " + item + " DOESNT HAVE ASSET: " + text2);
		}
	}

	private int GetLayer(bool showInHead, bool showInLegacy)
	{
		if (showInHead && showInLegacy)
		{
			return 0;
		}
		if (!showInHead && showInLegacy)
		{
			return 17;
		}
		if (showInHead && !showInLegacy)
		{
			return 21;
		}
		return 18;
	}

	public GameObject SpawnDDOLAsset(string assetBundlePath, string assetName)
	{
		GameObject val = Calls.LoadAssetFromFile<GameObject>(assetBundlePath, assetName);
		if ((Object)(object)val != (Object)null)
		{
			val = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).name = assetName.Replace("(Clone)", "");
			val.SetActive(false);
			val.transform.parent = parentObject.transform;
		}
		return val;
	}

	private void SaveFile(string textToSave, string file)
	{
		FileStream fileStream = File.Create(file);
		byte[] bytes = Encoding.UTF8.GetBytes(textToSave);
		fileStream.Write(bytes);
		fileStream.Close();
		fileStream.Dispose();
	}

	private static void SendRPCString()
	{
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		string text = Singleton<PlayerManager>.instance.localPlayer.Data.GeneralData.PlayFabMasterId + ";";
		for (int i = 0; i < assetInfos.Count; i++)
		{
			if (enabled[i])
			{
				text += assetInfos[i].GetAssetInfo();
				if (i != assetInfos.Count - 1)
				{
					text += ";";
				}
			}
		}
		PhotonNetwork.RaiseEvent(myEventCode, Object.op_Implicit(text), eventOptions, SendOptions.SendReliable);
	}

	private static void PlaceAsset(PlayerController playerController, AssetInfo assetInfo)
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Invalid comparison between Unknown and I4
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Invalid comparison between Unknown and I4
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		int num = -1;
		for (int i = 0; i < playersLoaded.Count; i++)
		{
			if (playersLoaded[i] == playerController.assignedPlayer.Data.GeneralData.PlayFabMasterId)
			{
				num = i;
				break;
			}
		}
		if (num == -1 && (int)playerController.controllerType == 2)
		{
			MelonLogger.Error("REMOTE PLAYER NOT FOUND IN LIST!!!");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(assetInfo.GetAssetToUse());
		((Object)val).name = ((Object)val).name.Replace("(Clone)", "");
		Utility.SetLayerRecursively(val, assetInfo.GetLayer());
		GameObject val2 = ((assetInfo.GetChildsPath() != "") ? ((Component)val.transform.FindChild(assetInfo.GetChildsPath())).gameObject : (val2 = val));
		if ((int)playerController.controllerType == 2)
		{
			accessoriesToNuke[num].Add(val);
			if ((Object)(object)val != (Object)(object)val2)
			{
				accessoriesToNuke[num].Add(val2);
			}
		}
		Transform val3 = ((Component)playerController).gameObject.transform.FindChild(assetInfo.GetBoneToAttachTo());
		val.transform.position = val3.position;
		val.transform.rotation = val3.rotation;
		val2.transform.parent = val3;
		val2.transform.localPosition = assetInfo.GetPositionOffset();
		val2.transform.localRotation = assetInfo.GetRotationOffset();
		val2.transform.localScale = assetInfo.GetLocalScale();
		val.SetActive(true);
		val2.SetActive(true);
	}

	private static void PlaceDressingRoomAsset(AssetInfo assetInfo)
	{
		//IL_0066: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(assetInfo.GetAssetToUse());
		GameObject val2 = ((assetInfo.GetChildsPath() != "") ? ((Component)val.transform.FindChild(assetInfo.GetChildsPath())).gameObject : (val2 = val));
		try
		{
			Transform val3 = PreviewPlayerController.GetGameObject().transform.FindChild(assetInfo.GetBoneToAttachTo());
			val2.transform.parent = val3;
			val.transform.position = val3.position;
			val.transform.rotation = val3.rotation;
			val2.transform.localPosition = assetInfo.GetPositionOffset();
			val2.transform.localRotation = assetInfo.GetRotationOffset();
			val2.transform.localScale = assetInfo.GetLocalScale();
			val.SetActive(true);
			val2.SetActive(true);
		}
		catch
		{
			MelonLogger.Error("(" + ((Object)val2).name + ") DRESSING ROOM PATH NOT CORRECT! THIS IS MOST LIKELY DUE TO DIFFERENCES IN DRESSING ROOM PLAYER RIG AND NOT THE USER!");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
		}
	}
}