Decompiled source of ModelReplacementTool v0.9.3

ModelReplacementTool.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

[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("ModelReplacementTool")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c6f1b3eb6a0bda36fd213b0def9b1bccabc21362")]
[assembly: AssemblyProduct("ModelReplacementTool")]
[assembly: AssemblyTitle("ModelReplacementTool")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ModelReplacementTool
{
	public class BonePanel : MonoBehaviour
	{
		public string playerBoneString;

		public string modelBoneString;

		public Quaternion rotationOffset = Quaternion.identity;

		public Transform playerTransform;

		public Transform modelTransform;

		private TextMeshProUGUI playerText = null;

		private TMP_Dropdown dropDown;

		private Slider x = null;

		private Slider y = null;

		private Slider z = null;

		public MappedBone mapped = null;

		public BoneMap map = null;

		public bool isRootBone = false;

		public bool isItemHolder = false;

		private ToolComponent comp;

		public float xf
		{
			get
			{
				return x.value;
			}
			set
			{
				x.value = value;
			}
		}

		public float yf
		{
			get
			{
				return y.value;
			}
			set
			{
				y.value = value;
			}
		}

		public float zf
		{
			get
			{
				return z.value;
			}
			set
			{
				z.value = value;
			}
		}

		private void Awake()
		{
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>();
			TextMeshProUGUI[] array = componentsInChildren;
			foreach (TextMeshProUGUI val in array)
			{
				Console.WriteLine(((Object)((Component)val).gameObject).name);
				if (((Object)((Component)val).gameObject).name == "playerName")
				{
					playerText = val;
				}
			}
			Slider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Slider>();
			Slider[] array2 = componentsInChildren2;
			foreach (Slider val2 in array2)
			{
				Console.WriteLine(((Object)((Component)val2).gameObject).name);
				if (((Object)((Component)val2).gameObject).name == "SliderX")
				{
					x = val2;
				}
				if (((Object)((Component)val2).gameObject).name == "SliderY")
				{
					y = val2;
				}
				if (((Object)((Component)val2).gameObject).name == "SliderZ")
				{
					z = val2;
				}
			}
			TMP_Dropdown[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<TMP_Dropdown>();
			TMP_Dropdown[] array3 = componentsInChildren3;
			foreach (TMP_Dropdown val3 in array3)
			{
				Console.WriteLine(((Object)((Component)val3).gameObject).name);
				if (((Object)((Component)val3).gameObject).name == "boneDropDown")
				{
					dropDown = val3;
				}
			}
			((UnityEvent<int>)(object)dropDown.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				SetModelBone(dropDown);
			});
			Button[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<Button>();
			Button[] array4 = componentsInChildren4;
			foreach (Button val4 in array4)
			{
				Console.WriteLine(((Object)((Component)val4).gameObject).name);
				if (((Object)((Component)val4).gameObject).name == "ButtonSet")
				{
					((UnityEvent)val4.onClick).AddListener(new UnityAction(SetValues));
				}
				if (((Object)((Component)val4).gameObject).name == "ButtonReset")
				{
					((UnityEvent)val4.onClick).AddListener(new UnityAction(ResetValues));
				}
			}
		}

		private void SetValues()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (map != null)
			{
				if (isRootBone)
				{
					map.UpdateRootBoneAndOffset(map.RootBone(), new Vector3(xf, yf, zf));
				}
				if (isItemHolder)
				{
					map.UpdateItemHolderBoneAndOffset(map.ItemHolder(), new Vector3(xf, yf, zf));
				}
			}
			if (mapped != null)
			{
				comp.map.UpdateMappedBone(mapped.playerBoneString, mapped.modelBoneString, Quaternion.Euler(xf, yf, zf));
			}
		}

		private void ResetValues()
		{
			xf = 0f;
			yf = 0f;
			zf = 0f;
		}

		private void SetModelBone(TMP_Dropdown change)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			string text = change.options[change.value].text;
			if (text == GetModelBoneIfExists())
			{
				return;
			}
			if (map != null)
			{
				if (isRootBone)
				{
				}
				if (isItemHolder)
				{
					IEnumerable<Transform> source = map.modelBoneList.Where((Transform x) => ((Object)x).name == modelBoneString);
					Transform val = null;
					if (source.Any())
					{
						map.UpdateItemHolderBoneAndOffset(source.First(), map.ItemHolderPositionOffset());
					}
					else
					{
						Console.WriteLine("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
					}
				}
			}
			if (mapped != null)
			{
				comp.map.UpdateMappedBone(mapped.playerBoneString, text, mapped.rotationOffset);
			}
			comp.UpdateDropDowns();
		}

		private void Update()
		{
			if (!Mouse.current.leftButton.isPressed)
			{
				GUI.FocusControl((string)null);
			}
			SetValues();
			if (!((Object)(object)comp != (Object)null))
			{
				return;
			}
			BonePanel bonePanel = comp.MapSymmetric(this);
			if ((Object)(object)bonePanel != (Object)null)
			{
				if (comp.Symmetric)
				{
					bonePanel.xf = xf;
					bonePanel.yf = 0f - yf;
					bonePanel.zf = 0f - zf;
				}
				if (comp.antisymmetric)
				{
					bonePanel.xf = xf;
					bonePanel.yf = yf;
					bonePanel.zf = zf;
				}
			}
		}

		public void SetMappedBone(MappedBone mappedBone, string name)
		{
			mapped = mappedBone;
			((TMP_Text)playerText).text = name;
		}

		public void Initialize(ToolComponent comp)
		{
			//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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			this.comp = comp;
			PopulateDropdown();
			if (mapped != null)
			{
				Vector3 eulerAngles = ((Quaternion)(ref mapped.rotationOffset)).eulerAngles;
				xf = eulerAngles.x;
				yf = eulerAngles.y;
				zf = eulerAngles.z;
			}
			if (map != null)
			{
				if (isRootBone)
				{
					((TMP_Text)playerText).text = "player RootBone";
					xf = map.PositionOffset().x;
					yf = map.PositionOffset().y;
					zf = map.PositionOffset().z;
				}
				if (isItemHolder)
				{
					((TMP_Text)playerText).text = "player ItemHolder";
					xf = map.ItemHolderPositionOffset().x;
					yf = map.ItemHolderPositionOffset().y;
					zf = map.ItemHolderPositionOffset().z;
				}
			}
		}

		private string? GetModelBoneIfExists()
		{
			if (map != null)
			{
				if (isRootBone)
				{
					return ((Object)map.RootBone()).name;
				}
				if (isItemHolder)
				{
					return ((Object)map.ItemHolder()).name;
				}
			}
			if (mapped != null)
			{
				return mapped.modelBoneString;
			}
			return null;
		}

		public void PopulateDropdown()
		{
			string modelBoneIfExists = GetModelBoneIfExists();
			string text = "Null";
			if (modelBoneIfExists != null)
			{
				text = modelBoneIfExists;
			}
			List<string> list = new List<string>();
			list.Add(text);
			if (!isRootBone)
			{
				if (text != "Null")
				{
					list.Add("Null");
				}
				list.AddRange(comp.GetUnmappedBoneNames());
			}
			dropDown.ClearOptions();
			dropDown.AddOptions(list);
			dropDown.value = 0;
		}
	}
	[BepInPlugin("meow.ModelReplacementTool", "ModelReplacementTool", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ModelReplacementTool : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerControllerB))]
		public class PlayerControllerBPatch
		{
			[HarmonyPatch("Update")]
			[HarmonyPostfix]
			public static void UpdatePatch(ref PlayerControllerB __instance)
			{
				if ((ulong)StartOfRound.Instance.thisClientPlayerId == __instance.playerClientId)
				{
					BodyReplacementBase component = ((Component)__instance).gameObject.GetComponent<BodyReplacementBase>();
					if (!((Object)(object)component == (Object)null) && !Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<ToolComponent>()))
					{
						((Component)__instance).gameObject.AddComponent<ToolComponent>();
					}
				}
			}
		}

		public static ModelReplacementTool Instance;

		public ManualLogSource Logger;

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			Assets.PopulateAssets();
			Logger = Logger.CreateLogSource("ModelReplacementTool");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Harmony val = new Harmony("meow.ModelReplacementTool");
			val.PatchAll();
			Logger.LogInfo((object)"Plugin meow.ModelReplacementTool is loaded!");
		}
	}
	public static class Assets
	{
		public static string mainAssetBundleName = "tbundle";

		public static AssetBundle MainAssetBundle = null;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().FullName.Split(',')[0];
		}

		public static void PopulateAssets()
		{
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName))
				{
					MainAssetBundle = AssetBundle.LoadFromStream(stream);
				}
			}
		}
	}
	public class ToolComponent : MonoBehaviour
	{
		public PlayerControllerB controller;

		public BodyReplacementBase bodyReplacement;

		private Dictionary<string, MappedBone?> mappedBonesInModel = new Dictionary<string, MappedBone>();

		private Dictionary<string, BonePanel> PanelsPerMappedBone = new Dictionary<string, BonePanel>();

		public bool doSymmetric = true;

		public BoneMap map;

		private Transform[] allbones;

		private Toggle x = null;

		private Toggle y = null;

		private Toggle z = null;

		private Toggle a = null;

		private Toggle b = null;

		private GameObject camTempParent = new GameObject("CamTempParent");

		private Transform camOrigTrans;

		private Camera personCam2;

		public Vector3 initialPlayerLocation;

		private Quaternion intialPlayerRotation;

		private Vector2 previousMousePosition;

		private Vector2 centerPosition;

		private float desiredMoveSpeed = 10f;

		private List<string> playerBoneNames = new List<string>
		{
			"spine", "spine.001", "spine.002", "spine.003", "shoulder.L", "arm.L_upper", "arm.L_lower", "hand.L", "finger5.L", "finger5.L.001",
			"finger4.L", "finger4.L.001", "finger3.L", "finger3.L.001", "finger2.L", "finger2.L.001", "finger1.L", "finger1.L.001", "shoulder.R", "arm.R_upper",
			"arm.R_lower", "hand.R", "finger5.R", "finger5.R.001", "finger4.R", "finger4.R.001", "finger3.R", "finger3.R.001", "finger2.R", "finger2.R.001",
			"finger1.R", "finger1.R.001", "spine.004", "thigh.L", "shin.L", "foot.L", "toe.L", "heel.02.L", "thigh.R", "shin.R",
			"foot.R", "toe.R", "heel.02.R"
		};

		public bool Symmetric
		{
			get
			{
				return x.isOn;
			}
			set
			{
				x.isOn = value;
				if (value)
				{
					antisymmetric = false;
					notSymmetric = false;
				}
			}
		}

		public bool antisymmetric
		{
			get
			{
				return y.isOn;
			}
			set
			{
				y.isOn = value;
				if (value)
				{
					Symmetric = false;
					notSymmetric = false;
				}
			}
		}

		public bool notSymmetric
		{
			get
			{
				return z.isOn;
			}
			set
			{
				z.isOn = value;
				if (value)
				{
					Symmetric = false;
					antisymmetric = false;
				}
			}
		}

		public bool aa
		{
			get
			{
				return y.isOn;
			}
			set
			{
				a.isOn = value;
				DoRenderHelmet(value);
			}
		}

		public bool bb
		{
			get
			{
				return z.isOn;
			}
			set
			{
				b.isOn = value;
				bodyReplacement.renderBase = value;
			}
		}

		public List<string> GetUnmappedBoneNames()
		{
			List<string> list = (from x in bodyReplacement.GetMappedBones()
				select ((Object)x).name).ToList();
			List<string> list2 = new List<string>();
			List<MappedBone> list3 = mappedBonesInModel.Values.ToList();
			foreach (string item in list)
			{
				list2.Add(item);
			}
			foreach (MappedBone item2 in list3)
			{
				if (item2 != null)
				{
					list2.Remove(item2.modelBoneString);
				}
			}
			return list2;
		}

		public void UpdateDropDowns()
		{
			foreach (BonePanel value in PanelsPerMappedBone.Values)
			{
				value.PopulateDropdown();
			}
		}

		public BonePanel MapSymmetric(BonePanel panel)
		{
			if (!doSymmetric)
			{
				return null;
			}
			if (panel.mapped == null)
			{
				return null;
			}
			if (panel.mapped.playerBoneString.Length <= 2)
			{
				return null;
			}
			string text = panel.mapped.playerBoneString.ToLower();
			string text2 = "";
			string text3 = "";
			for (int i = 0; i < text.Count() - 1; i++)
			{
				char c = text[i];
				char c2 = text[i + 1];
				if ((c2 == 'r' || c2 == 'l') && (c == '.' || c == '_'))
				{
					text2 = c.ToString() + c2;
					if (c2 == 'l')
					{
						text3 = c.ToString() + 'r';
					}
					if (c2 == 'r')
					{
						text3 = c.ToString() + 'l';
					}
					break;
				}
			}
			if (text2 == "")
			{
				return null;
			}
			if (text3 == "")
			{
				return null;
			}
			string key = text.Replace(text2, text3);
			return PanelsPerMappedBone[key];
		}

		private void DoRenderHelmet(bool render)
		{
			if (render)
			{
				controller.cameraContainerTransform.parent = camOrigTrans;
			}
			else
			{
				controller.cameraContainerTransform.parent = camTempParent.transform;
			}
		}

		private void Awake()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			controller = ((Component)this).GetComponent<PlayerControllerB>();
			bodyReplacement = ((Component)this).GetComponent<BodyReplacementBase>();
			map = bodyReplacement.Map;
			camOrigTrans = controller.cameraContainerTransform.parent;
			camTempParent.transform.parent = camOrigTrans;
			camTempParent.transform.localPosition = new Vector3(0f, 100f, 0f);
			GameObject val = Object.Instantiate<GameObject>(Object.FindObjectOfType<Terminal>().buyableItemsList[0].spawnPrefab);
			GrabbableObject component = val.GetComponent<GrabbableObject>();
			component.itemProperties.canBeGrabbedBeforeGameStart = true;
			component.GrabItemOnClient();
			controller.SwitchToItemSlot(0, component);
			component.parentObject = controller.localItemHolder;
			foreach (string playerBoneName in playerBoneNames)
			{
				mappedBonesInModel.Add(playerBoneName, null);
			}
			map.GetMappedBones().ForEach(delegate(MappedBone x)
			{
				mappedBonesInModel[x.playerBoneString] = x;
				Console.WriteLine(x.rotationOffset.y);
				Console.WriteLine("BONE BONE");
			});
			Console.WriteLine("a");
			allbones = controller.thisPlayerModel.bones;
			string text = "ToolPanel";
			GameObject val2 = Object.Instantiate<GameObject>(Assets.MainAssetBundle.LoadAsset<GameObject>(text));
			Console.WriteLine("a");
			string text2 = "BonePanel";
			GameObject val3 = Object.Instantiate<GameObject>(Assets.MainAssetBundle.LoadAsset<GameObject>(text2));
			val3.AddComponent<BonePanel>();
			Console.WriteLine("a");
			string text3 = "BonePanel2";
			GameObject val4 = Object.Instantiate<GameObject>(Assets.MainAssetBundle.LoadAsset<GameObject>(text3));
			val4.AddComponent<BonePanel>();
			string text4 = "BonePanelRotation";
			GameObject val5 = Object.Instantiate<GameObject>(Assets.MainAssetBundle.LoadAsset<GameObject>(text4));
			val5.AddComponent<BonePanel>();
			Console.WriteLine("a");
			GameObject val6 = GameObject.Find("Systems/UI/Canvas");
			Console.WriteLine(Object.op_Implicit((Object)(object)val6));
			val2.transform.parent = val6.transform;
			val2.transform.localPosition = new Vector3(0f, 0f, 0f);
			val2.transform.localScale = Vector3.one * 0.75f;
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.offsetMin = new Vector2(-640f, -360f);
			component2.offsetMax = new Vector2(640f, 340f);
			GameObject gameObject = ((Component)val2.GetComponentInChildren<VerticalLayoutGroup>()).gameObject;
			val2.GetComponentInChildren<ScrollRect>().elasticity = 1000f;
			Button[] componentsInChildren = val2.GetComponentsInChildren<Button>();
			Button[] array = componentsInChildren;
			foreach (Button val7 in array)
			{
				Console.WriteLine(((Object)((Component)val7).gameObject).name);
				if (((Object)((Component)val7).gameObject).name == "ButtonSave")
				{
					((UnityEvent)val7.onClick).AddListener(new UnityAction(RefreshPanel));
				}
			}
			Toggle[] componentsInChildren2 = val2.GetComponentsInChildren<Toggle>();
			Toggle[] array2 = componentsInChildren2;
			foreach (Toggle val8 in array2)
			{
				Console.WriteLine(((Object)((Component)val8).gameObject).name);
				if (((Object)((Component)val8).gameObject).name == "S1")
				{
					x = val8;
				}
				if (((Object)((Component)val8).gameObject).name == "S2")
				{
					y = val8;
				}
				if (((Object)((Component)val8).gameObject).name == "S3")
				{
					z = val8;
				}
				if (((Object)((Component)val8).gameObject).name == "S4")
				{
					a = val8;
				}
				if (((Object)((Component)val8).gameObject).name == "S5")
				{
					b = val8;
				}
			}
			((UnityEvent<bool>)(object)x.onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
			{
				Symmetric = x;
			});
			((UnityEvent<bool>)(object)y.onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
			{
				antisymmetric = x;
			});
			((UnityEvent<bool>)(object)z.onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
			{
				notSymmetric = x;
			});
			((UnityEvent<bool>)(object)a.onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
			{
				aa = x;
			});
			((UnityEvent<bool>)(object)b.onValueChanged).AddListener((UnityAction<bool>)delegate(bool x)
			{
				bb = x;
			});
			GameObject val9 = Object.Instantiate<GameObject>(val3, gameObject.transform);
			val9.transform.localScale = Vector3.one * 0.7f;
			BonePanel component3 = val9.GetComponent<BonePanel>();
			component3.map = map;
			component3.isRootBone = true;
			component3.Initialize(this);
			GameObject val10 = Object.Instantiate<GameObject>(val4, gameObject.transform);
			val10.transform.localScale = Vector3.one * 0.7f;
			BonePanel component4 = val10.GetComponent<BonePanel>();
			component4.map = map;
			component4.isItemHolder = true;
			component4.Initialize(this);
			foreach (string playerBoneName2 in playerBoneNames)
			{
				GameObject val11 = Object.Instantiate<GameObject>(val5, gameObject.transform);
				val11.transform.localScale = Vector3.one * 0.7f;
				BonePanel component5 = val11.GetComponent<BonePanel>();
				component5.SetMappedBone(mappedBonesInModel[playerBoneName2], playerBoneName2);
				component5.Initialize(this);
				PanelsPerMappedBone.Add(playerBoneName2.ToLower(), component5);
			}
			bodyReplacement.renderLocalDebug = true;
			bodyReplacement.renderBase = true;
			bodyReplacement.renderModel = true;
		}

		private void RefreshPanel()
		{
			GUI.FocusControl((string)null);
			Console.WriteLine("REF");
			string text = map.SerializeToJsonString();
			text = JToken.Parse(text).ToString((Formatting)1, Array.Empty<JsonConverter>());
			Console.WriteLine(text);
			string jsonPath = bodyReplacement.jsonPath;
			Console.WriteLine(jsonPath);
			File.WriteAllText(jsonPath, text);
		}

		private void Start()
		{
			//IL_0012: 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_002b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)controller).gameObject.transform;
			transform.position += new Vector3(0f, 0f, 1f);
			Transform transform2 = ((Component)controller).gameObject.transform;
			transform2.rotation *= Quaternion.AngleAxis(-90f, Vector3.up);
			initialPlayerLocation = ((Component)controller).gameObject.transform.position;
			intialPlayerRotation = ((Component)controller).gameObject.transform.rotation;
		}

		private void Update()
		{
			WalkieTalkie[] array = Object.FindObjectsOfType<WalkieTalkie>();
			foreach (WalkieTalkie val in array)
			{
				if (!((Object)(object)((Component)val).gameObject.transform.parent == (Object)null))
				{
					Console.WriteLine(((Object)((Component)val).gameObject).name + " " + ((Object)((Component)((Component)val).gameObject.transform.parent).gameObject).name + " ");
					if (((Object)((Component)((Component)val).gameObject.transform.parent).gameObject).name == "HangarShip")
					{
						Object.Destroy((Object)(object)((Component)val).gameObject);
					}
				}
			}
		}

		private void LateUpdate()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			((Component)controller).gameObject.transform.position = new Vector3(initialPlayerLocation.x, ((Component)controller).gameObject.transform.position.y, initialPlayerLocation.z);
			((Component)controller).gameObject.transform.rotation = intialPlayerRotation;
			UpdateCamera();
		}

		public void UpdateCamera()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)personCam2 == (Object)null)
			{
				GameObject val = GameObject.Find("Environment/HangarShip/Player/ScavengerModel/metarig/CameraContainer/MainCamera");
				Camera component = val.GetComponent<Camera>();
				Console.WriteLine(Object.op_Implicit((Object)(object)val));
				Console.WriteLine(Object.op_Implicit((Object)(object)component));
				Console.WriteLine("Set");
				GameObject val2 = Object.Instantiate<GameObject>(val, val.transform);
				Console.WriteLine("Set2");
				personCam2 = val2.GetComponent<Camera>();
				Console.WriteLine("Set3");
				((Behaviour)personCam2).enabled = true;
				((Behaviour)component).enabled = false;
				((Component)component).gameObject.SetActive(false);
				((Component)personCam2).transform.parent = null;
				Cursor.lockState = (CursorLockMode)0;
				centerPosition = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
				Cursor.visible = true;
				Console.WriteLine("Set4");
				Transform transform = ((Component)personCam2).transform;
				transform.position += new Vector3(3f, 0f, 0f);
				Transform transform2 = ((Component)personCam2).transform;
				transform2.rotation *= Quaternion.AngleAxis(180f, Vector3.up);
				((Component)personCam2).transform.LookAt(((Component)component).transform, Vector3.up);
				GameObject val3 = Object.Instantiate<GameObject>(GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (8)"), val2.transform);
				val3.transform.localPosition = Vector3.zero;
				val3.GetComponent<Light>().intensity = 75f;
			}
			float num = desiredMoveSpeed * Time.deltaTime;
			if (((ButtonControl)Keyboard.current.leftShiftKey).isPressed)
			{
				num *= 10f;
			}
			if (((ButtonControl)Keyboard.current.aKey).isPressed)
			{
				Transform transform3 = ((Component)personCam2).transform;
				transform3.position += ((Component)personCam2).transform.right * -1f * num;
			}
			if (((ButtonControl)Keyboard.current.dKey).isPressed)
			{
				Transform transform4 = ((Component)personCam2).transform;
				transform4.position += ((Component)personCam2).transform.right * num;
			}
			if (((ButtonControl)Keyboard.current.wKey).isPressed)
			{
				Transform transform5 = ((Component)personCam2).transform;
				transform5.position += ((Component)personCam2).transform.forward * num;
			}
			if (((ButtonControl)Keyboard.current.sKey).isPressed)
			{
				Transform transform6 = ((Component)personCam2).transform;
				transform6.position += ((Component)personCam2).transform.forward * -1f * num;
			}
			if (((ButtonControl)Keyboard.current.spaceKey).isPressed)
			{
				Transform transform7 = ((Component)personCam2).transform;
				transform7.position += ((Component)personCam2).transform.up * num;
			}
			if (Keyboard.current.ctrlKey.isPressed)
			{
				Transform transform8 = ((Component)personCam2).transform;
				transform8.position += ((Component)personCam2).transform.up * -1f * num;
			}
			bool isPressed = Mouse.current.rightButton.isPressed;
			Vector2 val4 = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue() - previousMousePosition;
			if (isPressed)
			{
				Console.WriteLine($"{val4.x} {val4.y}");
				float num2 = ((Component)personCam2).transform.localEulerAngles.y + val4.x * 0.1f;
				float num3 = ((Component)personCam2).transform.localEulerAngles.x - val4.y * 0.1f;
				((Component)personCam2).transform.localEulerAngles = new Vector3(num3, num2, 0f);
			}
			if (((Vector2)(ref val4)).magnitude == 0f)
			{
			}
			previousMousePosition = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
		}
	}
}