Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Moe Company v1.0.9
ModelReplacementAPI.dll
Decompiled 2 years agousing System; using System.Collections; 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.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCThirdPerson; using Microsoft.CodeAnalysis; using MoreCompany; using MoreCompany.Cosmetics; using Newtonsoft.Json; using UnityEngine; using UnityEngine.InputSystem; using _3rdPerson.Helper; [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 = "")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("ModelReplacementAPI")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ModelReplacementAPI")] [assembly: AssemblyTitle("ModelReplacementAPI")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace ModelReplacement { internal class AvatarBodyUpdater : MonoBehaviour { private void LateUpdate() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0038: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) Animator val = new Animator(); Animator val2 = new Animator(); Array values = Enum.GetValues(typeof(HumanBodyBones)); foreach (object item in values) { Transform boneTransform = val.GetBoneTransform((HumanBodyBones)item); Transform boneTransform2 = val.GetBoneTransform((HumanBodyBones)item); if (!((Object)(object)boneTransform == (Object)null) && !((Object)(object)boneTransform2 == (Object)null)) { boneTransform2.rotation = new Quaternion(boneTransform.rotation.x, boneTransform.rotation.y, boneTransform.rotation.z, boneTransform.rotation.w); } } Dictionary<string, HumanBodyBones> dictionary = new Dictionary<string, HumanBodyBones> { { "spine", (HumanBodyBones)0 }, { "spine.001", (HumanBodyBones)7 }, { "spine.002", (HumanBodyBones)8 }, { "spine.003", (HumanBodyBones)54 }, { "shoulder.L", (HumanBodyBones)11 }, { "arm.L_upper", (HumanBodyBones)13 }, { "arm.L_lower", (HumanBodyBones)15 }, { "hand.L", (HumanBodyBones)17 }, { "finger5.L", (HumanBodyBones)36 }, { "finger5.L.001", (HumanBodyBones)37 }, { "finger4.L", (HumanBodyBones)33 }, { "finger4.L.001", (HumanBodyBones)34 }, { "finger3.L", (HumanBodyBones)30 }, { "finger3.L.001", (HumanBodyBones)31 }, { "finger2.L", (HumanBodyBones)27 }, { "finger2.L.001", (HumanBodyBones)28 }, { "finger1.L", (HumanBodyBones)24 }, { "finger1.L.001", (HumanBodyBones)26 }, { "shoulder.R", (HumanBodyBones)12 }, { "arm.R_upper", (HumanBodyBones)14 }, { "arm.R_lower", (HumanBodyBones)16 }, { "hand.R", (HumanBodyBones)18 }, { "finger5.R", (HumanBodyBones)51 }, { "finger5.R.001", (HumanBodyBones)52 }, { "finger4.R", (HumanBodyBones)48 }, { "finger4.R.001", (HumanBodyBones)49 }, { "finger3.R", (HumanBodyBones)45 }, { "finger3.R.001", (HumanBodyBones)46 }, { "finger2.R", (HumanBodyBones)42 }, { "finger2.R.001", (HumanBodyBones)43 }, { "finger1.R", (HumanBodyBones)39 }, { "finger1.R.001", (HumanBodyBones)41 }, { "spine.004", (HumanBodyBones)10 }, { "thigh.L", (HumanBodyBones)1 }, { "shin.L", (HumanBodyBones)3 }, { "foot.L", (HumanBodyBones)5 }, { "toe.L", (HumanBodyBones)19 }, { "thigh.R", (HumanBodyBones)2 }, { "shin.R", (HumanBodyBones)4 }, { "foot.R", (HumanBodyBones)6 }, { "toe.R", (HumanBodyBones)20 } }; } } public class Blinker : MonoBehaviour { public bool Blink = true; [Tooltip("Minimum seconds between blinks")] public float MinTime = 5f; [Tooltip("Maximum seconds between blinks")] public float MaxTime = 15f; [Tooltip("Duration of a single blink")] public float BlinkDuration = 0.1f; private SkinnedMeshRenderer thisMesh; private Material instanceMaterial; private Vector2 originalOffset; private bool isBlinking = false; private void Start() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) thisMesh = ((Component)this).GetComponent<SkinnedMeshRenderer>(); if (((Renderer)thisMesh).materials.Length != 0) { instanceMaterial = ((Renderer)thisMesh).materials[0]; originalOffset = instanceMaterial.mainTextureOffset; ((MonoBehaviour)this).StartCoroutine(BlinkRoutine()); } else { Blink = false; } } public void DeadEyes() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StopCoroutine(BlinkRoutine()); thisMesh = ((Component)this).GetComponent<SkinnedMeshRenderer>(); Blink = false; if (((Renderer)thisMesh).materials.Length != 0) { instanceMaterial = ((Renderer)thisMesh).materials[0]; instanceMaterial.mainTextureOffset = new Vector2(0.01469f, 0.53901f); } else { Debug.LogError((object)"Didn't find heawd after attaching for dead eyes method"); } } private IEnumerator BlinkRoutine() { while (Blink) { yield return (object)new WaitForSeconds(Random.Range(MinTime, MaxTime)); isBlinking = true; instanceMaterial.mainTextureOffset = new Vector2(0.01469f, 0.53901f); yield return (object)new WaitForSeconds(BlinkDuration); isBlinking = false; instanceMaterial.mainTextureOffset = originalOffset; } } } public abstract class BodyReplacementBase : MonoBehaviour { public bool renderLocalDebug = false; public bool renderBase = false; public bool renderModel = false; private bool isCoroutineRunning = false; private PlayerDeathTracker playerDeathTracker; private Blinker blinker; private CosmeticApplication[] applications; private bool runConnectHairOnce = false; private InputAction f12Action; public string boneMapJsonStr; public string jsonPath; public BoneMap Map; private PlayerControllerB controller; public GameObject replacementModel; public GameObject deadBody = null; public GameObject replacementDeadBody = null; public BoneMap ragDollMap; private MeshRenderer nameTagObj = null; private MeshRenderer nameTagObj2 = null; public bool flagReparentObject = false; public bool moreCompanyCosmeticsReparented = false; internal bool ragdollEnabled = true; internal bool bloodDecalsEnabled = true; public bool localPlayer => (ulong)StartOfRound.Instance.thisClientPlayerId == controller.playerClientId; public abstract string boneMapFileName { get; } public bool DangerousViewState() { return ThirdPersonCamera.ViewState; } public bool DangerousLCViewState() { return ThirdPersonPlugin.Instance.Enabled; } public bool RenderBodyReplacement() { if (!localPlayer) { return true; } if (ModelReplacementAPI.thirdPersonPresent) { return DangerousViewState(); } if (ModelReplacementAPI.LCthirdPersonPresent) { return DangerousLCViewState(); } return false; } public abstract GameObject LoadAssetsAndReturnModel(); public abstract void AddModelScripts(); public virtual Transform[] GetMappedBones() { List<Transform> list = new List<Transform>(); SkinnedMeshRenderer[] componentsInChildren = replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val in componentsInChildren) { list.AddRange(val.bones); } return list.ToArray(); } private void CreateAndParentRagdoll(DeadBodyInfo bodyinfo) { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) deadBody = ((Component)bodyinfo).gameObject; SkinnedMeshRenderer componentInChildren = deadBody.GetComponentInChildren<SkinnedMeshRenderer>(); replacementDeadBody = Object.Instantiate<GameObject>(replacementModel); Renderer[] componentsInChildren = replacementDeadBody.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { val.enabled = true; } ((Renderer)componentInChildren).enabled = false; Blinker blinker = ((Component)replacementDeadBody.transform.Find("Head")).gameObject.AddComponent<Blinker>(); blinker.Blink = false; blinker.DeadEyes(); List<Transform> list = new List<Transform>(); SkinnedMeshRenderer[] componentsInChildren2 = replacementDeadBody.GetComponentsInChildren<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in componentsInChildren2) { list.AddRange(val2.bones); } Transform[] originalMappedBones = GetMappedBones(); Transform[] array = (Transform[])(object)new Transform[originalMappedBones.Length]; int i; for (i = 0; i < originalMappedBones.Length; i++) { array[i] = list.Where((Transform bone) => ((Object)bone).name == ((Object)originalMappedBones[i]).name).First(); } ragDollMap = BoneMap.DeserializeFromJson(boneMapJsonStr); ragDollMap.MapBones(componentInChildren.bones, array); ragDollMap.RootBone().parent = componentInChildren.rootBone; ragDollMap.RootBone().localPosition = Vector3.zero + Map.PositionOffset(); GameObject[] bodyBloodDecals = bodyinfo.bodyBloodDecals; foreach (GameObject val3 in bodyBloodDecals) { Transform parent = val3.transform.parent; Transform mappedTransform = ragDollMap.GetMappedTransform(((Object)parent).name); if (Object.op_Implicit((Object)(object)mappedTransform)) { Object.Instantiate<GameObject>(val3, mappedTransform); } } if (localPlayer) { ConnectClientToPlayerObjectPatch.Postfix(controller); } playerDeathTracker.Died = true; } public virtual void AfterAwake() { AttemptReparentMoreCompanyCosmetics(); } public void RepairModel() { //IL_00eb: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)controller == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)$" {((object)this).GetType()} PlayerControllerB is null"); } if ((Object)(object)controller.thisPlayerModel == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)$"{((Object)controller).name} {((object)this).GetType()} base player model is null"); } if ((Object)(object)replacementModel == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)$"{((Object)controller).name} {((object)this).GetType()} replacementModel is null"); replacementModel = LoadAssetsAndReturnModel(); replacementModel = Object.Instantiate<GameObject>(replacementModel); replacementModel.transform.localPosition = new Vector3(0f, 0f, 0f); replacementModel.SetActive(true); blinker = ((Component)replacementModel.transform.Find("Head")).gameObject.AddComponent<Blinker>(); Bounds bounds = ((Renderer)controller.thisPlayerModel).bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; float y = extents.y; bounds = GetBounds(); float num = y / ((Bounds)(ref bounds)).extents.y; Transform transform = replacementModel.transform; transform.localScale *= num; } Map = BoneMap.DeserializeFromJson(boneMapJsonStr); Map.MapBones(controller.thisPlayerModel.bones, GetMappedBones()); Map.SetBodyReplacement(this); ReparentModel(); moreCompanyCosmeticsReparented = false; } internal void Awake() { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown controller = ((Component)this).GetComponent<PlayerControllerB>(); replacementModel = LoadAssetsAndReturnModel(); if ((Object)(object)replacementModel == (Object)null) { Console.WriteLine("LoadAssetsAndReturnModel returned null"); } Renderer[] componentsInChildren = replacementModel.GetComponentsInChildren<Renderer>(); Material material = ((Renderer)((Component)controller.thisPlayerModel).GetComponent<SkinnedMeshRenderer>()).material; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (((Object)((Component)val).gameObject).name != "Suit") { List<Material> list = new List<Material>(); Material[] materials = val.materials; foreach (Material val2 in materials) { Material val3 = new Material(material); val3.mainTexture = val2.mainTexture; list.Add(val3); } val.SetMaterials(list); } } try { AddModelScripts(); } catch (Exception ex) { ModelReplacementAPI.Instance.Logger.LogError((object)("Could not set all model scripts.\n Error: " + ex.Message)); } replacementModel = Object.Instantiate<GameObject>(replacementModel); SetRenderers(enabled: false); replacementModel.transform.localPosition = new Vector3(0f, 0f, 0f); replacementModel.SetActive(true); blinker = ((Component)replacementModel.transform.Find("Head")).gameObject.AddComponent<Blinker>(); Bounds bounds = ((Renderer)controller.thisPlayerModel).bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; float y = extents.y; bounds = GetBounds(); float num = y / ((Bounds)(ref bounds)).extents.y; Transform transform = replacementModel.transform; transform.localScale *= num; string text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); while (true) { string name = new DirectoryInfo(text).Name; if (name == "plugins") { break; } text = Path.Combine(text, ".."); } string[] files = Directory.GetFiles(text, "*.json", SearchOption.AllDirectories); jsonPath = files.Where((string f) => string.Equals(Path.GetFileName(f), boneMapFileName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); boneMapJsonStr = File.ReadAllText(jsonPath); Map = BoneMap.DeserializeFromJson(boneMapJsonStr); controller = ((Component)this).GetComponent<PlayerControllerB>(); Map.MapBones(controller.thisPlayerModel.bones, GetMappedBones()); Map.SetBodyReplacement(this); ReparentModel(); MeshRenderer[] componentsInChildren2 = ((Component)controller).gameObject.GetComponentsInChildren<MeshRenderer>(); nameTagObj = componentsInChildren2.Where((MeshRenderer x) => ((Object)((Component)x).gameObject).name == "LevelSticker").First(); nameTagObj2 = componentsInChildren2.Where((MeshRenderer x) => ((Object)((Component)x).gameObject).name == "BetaBadge").First(); Console.WriteLine("AwakeEnd " + controller.playerUsername); if (((Component)this).gameObject.GetComponents<PlayerDeathTracker>().Length == 0) { Console.WriteLine("Player death tracker component added"); playerDeathTracker = ((Component)this).gameObject.AddComponent<PlayerDeathTracker>(); } else { Console.WriteLine("Player death tracker re-connected"); playerDeathTracker = ((Component)this).gameObject.GetComponent<PlayerDeathTracker>(); } AfterAwake(); } public void ReparentModel() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) Map.RootBone().parent = controller.thisPlayerModel.rootBone; Map.RootBone().localPosition = Vector3.zero + Map.PositionOffset(); } public virtual void AfterStart() { } private void Start() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown f12Action = new InputAction((string)null, (InputActionType)0, "<Keyboard>/f11", (string)null, (string)null, (string)null); f12Action.performed += OnF12Pressed; f12Action.Enable(); AfterStart(); } private void OnF12Pressed(CallbackContext context) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown if ((Object)(object)controller.deadBody == (Object)null) { playerDeathTracker.Died = true; RepairModel(); AttemptReparentMoreCompanyCosmetics(); Console.WriteLine(controller.playerUsername + " player model reset"); return; } GameObject gameObject = ((Component)controller.deadBody).gameObject; if (!applications.Any()) { gameObject.AddComponent<CosmeticApplication>(); applications = gameObject.GetComponents<CosmeticApplication>(); } Console.WriteLine("Telling all other clients we have hair " + controller.playerUsername); if (localPlayer) { ConnectClientToPlayerObjectPatch.Postfix(controller); } applications = gameObject.GetComponents<CosmeticApplication>(); if (!applications.Any()) { return; } Console.WriteLine("Setting up applications for " + controller.playerUsername); CosmeticApplication[] array = applications; foreach (CosmeticApplication val in array) { foreach (CosmeticInstance spawnedCosmetic in val.spawnedCosmetics) { Renderer[] componentsInChildren = ((Component)spawnedCosmetic).GetComponentsInChildren<Renderer>(); Material material = ((Renderer)((Component)controller.thisPlayerModel).GetComponent<SkinnedMeshRenderer>()).material; Renderer[] array2 = componentsInChildren; foreach (Renderer val2 in array2) { List<Material> list = new List<Material>(); Material[] materials = val2.materials; foreach (Material val3 in materials) { Material val4 = new Material(material); val4.mainTexture = val3.mainTexture; list.Add(val4); } val2.SetMaterials(list); } } } } public virtual void AfterUpdate() { } private void AttemptUnparentMoreCompanyCosmetics() { if (ModelReplacementAPI.moreCompanyPresent && moreCompanyCosmeticsReparented) { DangerousUnparent(); } } private IEnumerator AttemptReparentMoreCompanyCosmeticsCoroutine() { if (isCoroutineRunning) { yield break; } isCoroutineRunning = true; if (!ModelReplacementAPI.moreCompanyPresent || moreCompanyCosmeticsReparented) { yield break; } PlayerControllerB hair_controller_source = ((Component)this).GetComponent<PlayerControllerB>(); Console.WriteLine("Hair Controller player" + hair_controller_source.playerUsername); bool childrenFound = false; for (int j = 0; j < 5; j++) { CosmeticApplication[] cosmeticAppsChilds3 = ((Component)hair_controller_source).GetComponentsInChildren<CosmeticApplication>(); int numberOfChildren2 = cosmeticAppsChilds3.Length; Console.WriteLine("Updated number of children: " + numberOfChildren2); if (numberOfChildren2 != 0) { childrenFound = true; break; } yield return (object)new WaitForSeconds(0.1f); } if (!childrenFound && playerDeathTracker.Died) { hair_controller_source = ((Component)this).GetComponent<PlayerControllerB>(); ConnectClientToPlayerObjectPatch.Postfix(hair_controller_source); runConnectHairOnce = true; for (int i = 0; i < 5; i++) { CosmeticInstance[] cosmeticAppsChilds2 = ((Component)hair_controller_source).GetComponentsInChildren<CosmeticInstance>(); int numberOfChildren = cosmeticAppsChilds2.Length; Console.WriteLine("Updated number of children: " + numberOfChildren); if (numberOfChildren != 0) { break; } Console.WriteLine("None found. COmmence grabbin " + numberOfChildren); cosmeticAppsChilds2 = ((Component)hair_controller_source).GetComponentsInChildren<CosmeticInstance>(); Console.WriteLine("Updated number of children: " + cosmeticAppsChilds2.Length); yield return (object)new WaitForSeconds(0.1f); } } DangerousParent(); isCoroutineRunning = false; } private void StartReparentCoroutine() { ((MonoBehaviour)this).StartCoroutine(AttemptReparentMoreCompanyCosmeticsCoroutine()); } private void AttemptReparentMoreCompanyCosmetics() { if (ModelReplacementAPI.moreCompanyPresent && !moreCompanyCosmeticsReparented) { DangerousParent(); } } private void DangerousUnparent() { CosmeticApplication[] componentsInChildren = ((Component)controller).gameObject.GetComponentsInChildren<CosmeticApplication>(); if (componentsInChildren.Any()) { CosmeticApplication[] array = componentsInChildren; foreach (CosmeticApplication val in array) { Object.Destroy((Object)(object)val); moreCompanyCosmeticsReparented = false; } } Console.WriteLine(" unparent done"); } private void DangerousParent() { //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected I4, but got Unknown controller = ((Component)this).gameObject.GetComponent<PlayerControllerB>(); PlayerControllerB component = ((Component)controller).gameObject.GetComponent<PlayerControllerB>(); if (!playerDeathTracker.Died) { applications = ((Component)controller).gameObject.GetComponentsInChildren<CosmeticApplication>(); } else if (playerDeathTracker.Died) { if (localPlayer) { Console.WriteLine("Executing hair fix on " + controller.playerUsername); ConnectClientToPlayerObjectPatch.Postfix(controller); } applications = ((Component)component).GetComponentsInChildren<CosmeticApplication>(); } if (!applications.Any()) { return; } Console.WriteLine("Setting up applications for " + controller.playerUsername); CosmeticApplication[] array = applications; foreach (CosmeticApplication val in array) { Console.WriteLine(((object)val).GetType().Name + " parent"); Transform mappedTransform = Map.GetMappedTransform("spine.004"); Console.WriteLine("CurrentHead:" + (object)mappedTransform); Transform mappedTransform2 = Map.GetMappedTransform("spine.003"); Transform mappedTransform3 = Map.GetMappedTransform("arm.R_lower"); Transform mappedTransform4 = Map.GetMappedTransform("spine"); Transform mappedTransform5 = Map.GetMappedTransform("shin.L"); Transform mappedTransform6 = Map.GetMappedTransform("shin.R"); val.head = mappedTransform; val.chest = mappedTransform2; val.lowerArmRight = mappedTransform3; val.hip = mappedTransform4; val.shinLeft = mappedTransform5; val.shinRight = mappedTransform6; foreach (CosmeticInstance spawnedCosmetic in val.spawnedCosmetics) { Transform val2 = null; if ((Object)(object)spawnedCosmetic != (Object)null) { CosmeticType cosmeticType = spawnedCosmetic.cosmeticType; CosmeticType val3 = cosmeticType; switch ((int)val3) { case 0: val2 = val.head; break; case 2: val2 = val.chest; break; case 3: val2 = val.lowerArmRight; break; case 4: val2 = val.hip; break; case 5: val2 = val.shinLeft; break; case 6: val2 = val.shinRight; break; } } ((Component)spawnedCosmetic).transform.position = val2.position; ((Component)spawnedCosmetic).transform.rotation = val2.rotation; ((Component)spawnedCosmetic).transform.parent = val2; } } if (playerDeathTracker.Died) { CosmeticInstance[] componentsInChildren = ((Component)this).GetComponentsInChildren<CosmeticInstance>(); int num = componentsInChildren.Length; if (num > 0) { playerDeathTracker.Died = false; moreCompanyCosmeticsReparented = true; } } else { moreCompanyCosmeticsReparented = true; } } private void Update() { if (Map.CompletelyDestroyed()) { Object.Destroy((Object)(object)this); return; } if (!renderLocalDebug) { if (RenderBodyReplacement()) { SetRenderers(enabled: true); ((Renderer)controller.thisPlayerModel).enabled = false; ((Renderer)controller.thisPlayerModelLOD1).enabled = false; ((Renderer)controller.thisPlayerModelLOD2).enabled = false; ((Renderer)nameTagObj).enabled = false; ((Renderer)nameTagObj2).enabled = false; } else { SetRenderers(enabled: false); } } else { SkinnedMeshRenderer[] componentsInChildren = ((Component)controller).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val = (Renderer)(object)componentsInChildren[i]; val.enabled = renderBase; } SetRenderers(renderModel); } Map.UpdateModelbones(); if (controller.isPlayerDead || !localPlayer) { } if (ragdollEnabled) { GameObject val2 = null; try { val2 = ((Component)controller.deadBody).gameObject; } catch { } if (Object.op_Implicit((Object)(object)val2) && (Object)(object)replacementDeadBody == (Object)null) { CreateAndParentRagdoll(controller.deadBody); } if (Object.op_Implicit((Object)(object)replacementDeadBody)) { if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)replacementDeadBody); replacementDeadBody = null; ragDollMap = null; } else { ragDollMap.UpdateModelbones(); } } } AfterUpdate(); } private void OnDestroy() { f12Action.Disable(); Console.WriteLine("Destroy body component for " + controller.playerUsername); ((Renderer)controller.thisPlayerModel).enabled = true; ((Renderer)controller.thisPlayerModelLOD1).enabled = true; ((Renderer)controller.thisPlayerModelLOD2).enabled = true; ((Renderer)nameTagObj).enabled = true; ((Renderer)nameTagObj2).enabled = true; AttemptUnparentMoreCompanyCosmetics(); Object.Destroy((Object)(object)replacementModel); Object.Destroy((Object)(object)replacementDeadBody); } private void SetRenderers(bool enabled) { if ((Object)(object)replacementModel != (Object)null) { Renderer[] componentsInChildren = replacementModel.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { val.enabled = enabled; } } } private Bounds GetBounds() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_01b5: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); IEnumerable<Bounds> source = from r in replacementModel.GetComponentsInChildren<SkinnedMeshRenderer>() select ((Renderer)r).bounds; Bounds val = source.OrderByDescending((Bounds x) => ((Bounds)(ref x)).max.x).First(); float x2 = ((Bounds)(ref val)).max.x; val = source.OrderByDescending((Bounds x) => ((Bounds)(ref x)).max.y).First(); float y = ((Bounds)(ref val)).max.y; val = source.OrderByDescending((Bounds x) => ((Bounds)(ref x)).max.z).First(); float z = ((Bounds)(ref val)).max.z; val = source.OrderBy((Bounds x) => ((Bounds)(ref x)).min.x).First(); float x3 = ((Bounds)(ref val)).min.x; val = source.OrderBy((Bounds x) => ((Bounds)(ref x)).min.y).First(); float y2 = ((Bounds)(ref val)).min.y; val = source.OrderBy((Bounds x) => ((Bounds)(ref x)).min.z).First(); float z2 = ((Bounds)(ref val)).min.z; ((Bounds)(ref result)).SetMinMax(new Vector3(x3, y2, z2), new Vector3(z, y, z)); return result; } } [JsonObject] public class BoneMap { public class MappedBone { public string playerBoneString; public string modelBoneString; public Quaternion rotationOffset = Quaternion.identity; public Transform playerTransform; public Transform modelTransform; public List<string> additionalVars = new List<string>(); public MappedBone(string playerBoneString, string modelBoneString, Quaternion rotationOffset, Transform playerTransform, Transform modelTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_002e: Unknown result type (might be due to invalid IL or missing references) this.playerBoneString = playerBoneString; this.modelBoneString = modelBoneString; this.rotationOffset = rotationOffset; this.playerTransform = playerTransform; this.modelTransform = modelTransform; } public MappedBone(List<string> vars, Transform player, Transform model) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) playerTransform = player; modelTransform = model; int count = vars.Count; if (count >= 2) { playerBoneString = vars[0]; modelBoneString = vars[1]; } if (count >= 6) { try { float num = float.Parse(vars[2]); float num2 = float.Parse(vars[3]); float num3 = float.Parse(vars[4]); float num4 = float.Parse(vars[5]); rotationOffset = new Quaternion(num, num2, num3, num4); } catch (Exception) { ModelReplacementAPI.Instance.Logger.LogError((object)("could not parse rotation offset for player bone " + playerBoneString + " xyzw(" + vars[2] + "," + vars[3] + "," + vars[4] + "," + vars[5] + ")")); } } if (count > 6) { for (int i = 6; i < count; i++) { additionalVars.Add(vars[i]); } } } public bool Update() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_008d: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)modelTransform == (Object)null || (Object)(object)playerTransform == (Object)null) { ModelReplacementAPI.Instance.Logger.LogError((object)("Could not Update bone, model or player transform is null. Destroying MappedBone (" + modelBoneString + ")")); return true; } try { modelTransform.rotation = new Quaternion(playerTransform.rotation.x, playerTransform.rotation.y, playerTransform.rotation.z, playerTransform.rotation.w); Transform obj = modelTransform; obj.rotation *= rotationOffset; } catch { ModelReplacementAPI.Instance.Logger.LogError((object)("Could not Update bones for " + ((Object)playerTransform).name + " to " + ((Object)modelTransform).name + " ")); return true; } return false; } } [JsonProperty] private List<List<string>> boneMap = new List<List<string>>(); [JsonIgnore] private List<MappedBone> mappedBones = new List<MappedBone>(); [JsonProperty] private List<float> _positionOffSet = new List<float>(); [JsonIgnore] private Vector3 positionOffset = Vector3.zero; [JsonProperty] private List<float> _itemHolderPositionOffset = new List<float>(); [JsonIgnore] private Vector3 itemHolderPositionOffset = Vector3.zero; [JsonProperty] private string itemHolderBone = ""; [JsonIgnore] private Transform itemHolderTransform = null; [JsonProperty] private string rootBone = ""; [JsonIgnore] private Transform rootBoneTransform = null; [JsonIgnore] public Transform[] playerBoneList = null; [JsonIgnore] public Transform[] modelBoneList = null; [JsonIgnore] public BodyReplacementBase replacementBase; public static BoneMap DeserializeFromJson(string jsonStr) { return JsonConvert.DeserializeObject<BoneMap>(jsonStr); } public string SerializeToJsonString() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) _positionOffSet = new List<float> { positionOffset.x, positionOffset.y, positionOffset.z }; _itemHolderPositionOffset = new List<float> { itemHolderPositionOffset.x, itemHolderPositionOffset.y, itemHolderPositionOffset.z }; boneMap.Clear(); foreach (MappedBone mappedBone in mappedBones) { List<string> list = new List<string>(); list.Add(mappedBone.playerBoneString); list.Add(mappedBone.modelBoneString); if (mappedBone.rotationOffset != Quaternion.identity) { list.Add(mappedBone.rotationOffset.x.ToString()); list.Add(mappedBone.rotationOffset.y.ToString()); list.Add(mappedBone.rotationOffset.z.ToString()); list.Add(mappedBone.rotationOffset.w.ToString()); if (mappedBone.additionalVars.Count > 0) { foreach (string additionalVar in mappedBone.additionalVars) { list.Add(additionalVar); } } } boneMap.Add(list); } return JsonConvert.SerializeObject((object)this); } public void SetBodyReplacement(BodyReplacementBase body) { replacementBase = body; } public void MapBones(Transform[] playerBones, Transform[] modelBones) { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) playerBoneList = playerBones; modelBoneList = modelBones; if (!boneMap.Where((List<string> x) => x[0] == "PlayerRagdoll(Clone)").Any() && boneMap.Where((List<string> x) => x[0] == "spine").Any()) { List<string> list = new List<string>(); List<string> list2 = boneMap.Where((List<string> x) => x[0] == "spine").First(); for (int i = 0; i < list2.Count(); i++) { if (i == 0) { list.Add("PlayerRagdoll(Clone)"); } else { list.Add(list2[i]); } } boneMap.Add(list); } mappedBones.Clear(); itemHolderTransform = null; if (_positionOffSet.Count == 3) { positionOffset = new Vector3(_positionOffSet[0], _positionOffSet[1], _positionOffSet[2]); } if (_itemHolderPositionOffset.Count == 3) { itemHolderPositionOffset = new Vector3(_itemHolderPositionOffset[0], _itemHolderPositionOffset[1], _itemHolderPositionOffset[2]); } foreach (List<string> item in boneMap) { string playerBone = item[0]; string modelBone = item[1]; if (modelBone == "") { continue; } if (!modelBones.Any((Transform x) => ((Object)x).name == modelBone)) { ModelReplacementAPI.Instance.Logger.LogWarning((object)("No bone in model with name (" + modelBone + ")")); continue; } if (!playerBones.Any((Transform x) => ((Object)x).name == playerBone)) { ModelReplacementAPI.Instance.Logger.LogWarning((object)("No bone in player with name (" + playerBone + ")")); continue; } Transform player = playerBones.Where((Transform x) => ((Object)x).name == playerBone).First(); Transform model = modelBones.Where((Transform x) => ((Object)x).name == modelBone).First(); mappedBones.Add(new MappedBone(item, player, model)); } itemHolderTransform = modelBones.Where((Transform x) => ((Object)x).name == itemHolderBone).First(); rootBoneTransform = modelBones.Where((Transform x) => ((Object)x).name == rootBone).First(); } public void UpdateModelbones() { mappedBones.ForEach(delegate(MappedBone x) { bool flag = x.Update(); }); List<MappedBone> destroyBones = new List<MappedBone>(); mappedBones.ForEach(delegate(MappedBone x) { if (x.Update()) { destroyBones.Add(x); } }); destroyBones.ForEach(delegate(MappedBone x) { mappedBones.Remove(x); }); } public bool CompletelyDestroyed() { if (mappedBones.Count() == 0 || (Object)(object)rootBoneTransform == (Object)null) { Console.WriteLine("bone Map destroyed"); return true; } return false; } public Vector3 PositionOffset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return positionOffset; } public Vector3 ItemHolderPositionOffset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return itemHolderPositionOffset; } public Transform ItemHolder() { return itemHolderTransform; } public Transform RootBone() { return rootBoneTransform; } public Transform GetMappedTransform(string playerTransformName) { string playerTransformName2 = playerTransformName; IEnumerable<MappedBone> source = mappedBones.Where((MappedBone x) => x.playerBoneString == playerTransformName2); if (source.Any()) { return source.First().modelTransform; } ModelReplacementAPI.Instance.Logger.LogWarning((object)("No mapped bone with player bone name " + playerTransformName2)); return null; } public MappedBone GetMappedBoneWithPlayerName(string playerTransformName) { string playerTransformName2 = playerTransformName; IEnumerable<MappedBone> source = mappedBones.Where((MappedBone x) => x.playerBoneString == playerTransformName2); if (source.Any()) { return source.First(); } ModelReplacementAPI.Instance.Logger.LogWarning((object)("No mapped bone with player bone name " + playerTransformName2)); return null; } public List<MappedBone> GetMappedBones() { return mappedBones; } public void UpdateMappedBone(string playerBoneString, string modelBoneString, Quaternion rotationOffset) { //IL_0052: 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_0108: Unknown result type (might be due to invalid IL or missing references) string playerBoneString2 = playerBoneString; string modelBoneString2 = modelBoneString; IEnumerable<MappedBone> source = mappedBones.Where((MappedBone x) => x.playerBoneString == playerBoneString2); if (source.Any()) { MappedBone mappedBoneWithPlayerName = GetMappedBoneWithPlayerName(playerBoneString2); mappedBoneWithPlayerName.modelBoneString = modelBoneString2; mappedBoneWithPlayerName.rotationOffset = rotationOffset; IEnumerable<Transform> source2 = modelBoneList.Where((Transform x) => ((Object)x).name == modelBoneString2); if (source2.Any()) { mappedBoneWithPlayerName.modelTransform = source2.First(); } return; } IEnumerable<Transform> source3 = playerBoneList.Where((Transform x) => ((Object)x).name == playerBoneString2); IEnumerable<Transform> source4 = modelBoneList.Where((Transform x) => ((Object)x).name == modelBoneString2); Transform playerTransform = null; Transform modelTransform = null; if (source3.Any()) { playerTransform = source3.First(); } if (source4.Any()) { modelTransform = source4.First(); } MappedBone item = new MappedBone(playerBoneString2, modelBoneString2, rotationOffset, playerTransform, modelTransform); mappedBones.Add(item); } public void UpdateRootBoneAndOffset(Transform newRootBone, Vector3 offset) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)newRootBone != (Object)(object)rootBoneTransform) { rootBoneTransform.parent = null; rootBoneTransform = newRootBone; rootBone = ((Object)newRootBone).name; } positionOffset = offset; replacementBase.ReparentModel(); } public void UpdateItemHolderBoneAndOffset(Transform newRootBone, Vector3 offset) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) itemHolderTransform = newRootBone; itemHolderBone = ((Object)newRootBone).name; itemHolderPositionOffset = offset; replacementBase.flagReparentObject = true; } } [BepInPlugin("meow.ModelReplacementAPI", "ModelReplacementAPI", "1.2.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ModelReplacementAPI : BaseUnityPlugin { [HarmonyPatch(typeof(GrabbableObject))] public class LocateHeldObjectsOnModelReplacementPatch { [HarmonyPatch(typeof(StartOfRound))] public class RepairBrokenBodyReplacementsPatch { [HarmonyPatch("ReviveDeadPlayers")] [HarmonyPostfix] public static void ReviveDeadPlayersPatch(ref StartOfRound __instance) { PlayerControllerB[] allPlayerScripts = __instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (val.isPlayerDead && !((Object)(object)((Component)val).gameObject.GetComponent<BodyReplacementBase>() == (Object)null)) { Console.WriteLine("Reinstantiating model replacement for " + val.playerUsername + " "); Type type = ((object)((Component)val).gameObject.GetComponent<BodyReplacementBase>()).GetType(); Object.Destroy((Object)(object)((Component)val).gameObject.GetComponent<BodyReplacementBase>()); ((Component)val).gameObject.AddComponent(type); } } } } [HarmonyPatch(typeof(PlayerControllerB))] public class SetRegisteredBodyReplacements { private static InputAction f11Action; [HarmonyPatch("Update")] [HarmonyPostfix] public static void UpdatePatch(ref PlayerControllerB __instance) { try { if (__instance.playerSteamId == 0) { return; } if (RegisteredModelReplacementOverride != null) { SetPlayerModelReplacement(__instance, RegisteredModelReplacementOverride); return; } int currentSuitID = __instance.currentSuitID; string unlockableName = StartOfRound.Instance.unlockablesList.unlockables[currentSuitID].unlockableName; unlockableName = unlockableName.ToLower().Replace(" ", ""); if (RegisteredModelReplacements.ContainsKey(unlockableName)) { Type type = RegisteredModelReplacements[unlockableName]; SetPlayerModelReplacement(__instance, type); } else { RemovePlayerModelReplacement(__instance); } } catch (Exception) { } } [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake(ref PlayerControllerB __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown PlayerControllerB localInstance = __instance; f11Action = new InputAction((string)null, (InputActionType)0, "<Keyboard>/f11", (string)null, (string)null, (string)null); f11Action.performed += delegate { OnF11Pressed(localInstance); }; f11Action.Enable(); } private static void OnF11Pressed(PlayerControllerB __instance) { try { if (__instance.playerSteamId != 0) { Console.WriteLine("Reset player"); int currentSuitID = __instance.currentSuitID; string unlockableName = StartOfRound.Instance.unlockablesList.unlockables[currentSuitID].unlockableName; unlockableName = unlockableName.ToLower().Replace(" ", ""); if (RegisteredModelReplacements.ContainsKey(unlockableName)) { Type type = RegisteredModelReplacements[unlockableName]; SetPlayerModelReplacement(__instance, type); } else { RemovePlayerModelReplacement(__instance); } } } catch (Exception) { } } } [HarmonyPatch("LateUpdate")] [HarmonyPostfix] public static void LateUpdatePatch(ref GrabbableObject __instance) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.parentObject == (Object)null) && !((Object)(object)__instance.playerHeldBy == (Object)null)) { BodyReplacementBase component = ((Component)__instance.playerHeldBy).gameObject.GetComponent<BodyReplacementBase>(); if (!((Object)(object)component == (Object)null) && component.RenderBodyReplacement() && (!component.renderLocalDebug || component.renderModel)) { Transform val = component.Map.ItemHolder(); Vector3 val2 = component.Map.ItemHolderPositionOffset(); ((Component)__instance).transform.rotation = val.rotation; ((Component)__instance).transform.Rotate(__instance.itemProperties.rotationOffset); ((Component)__instance).transform.position = val.position; Vector3 val3 = __instance.itemProperties.positionOffset + val2; val3 = val.rotation * val3; Transform transform = ((Component)__instance).transform; transform.position += val3; } } } } public static bool moreCompanyPresent; public static bool thirdPersonPresent; public static bool LCthirdPersonPresent; public static ModelReplacementAPI Instance; public ManualLogSource Logger; private static Dictionary<string, Type> RegisteredModelReplacements = new Dictionary<string, Type>(); private static Type RegisteredModelReplacementOverride = null; private void Awake() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown Logger = Logger.CreateLogSource("ModelReplacementAPI"); if ((Object)(object)Instance == (Object)null) { Instance = this; } moreCompanyPresent = Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"); thirdPersonPresent = Chainloader.PluginInfos.ContainsKey("verity.3rdperson"); LCthirdPersonPresent = Chainloader.PluginInfos.ContainsKey("LCThirdPerson"); Harmony val = new Harmony("meow.ModelReplacementAPI"); val.PatchAll(); Logger.LogInfo((object)"Plugin meow.ModelReplacementAPI is loaded!"); } public static void RegisterModelReplacementOverride(Type type) { if (!type.IsSubclassOf(typeof(BodyReplacementBase))) { Instance.Logger.LogError((object)$"Cannot register body replacement override type {type.GetType()}, must inherit from BodyReplacementBase"); return; } if (RegisteredModelReplacementOverride != null) { Instance.Logger.LogError((object)$"Cannot register body replacement override, already registered to {RegisteredModelReplacementOverride.GetType()}."); return; } Instance.Logger.LogInfo((object)$"Registering body replacement override type {type.GetType()}."); RegisteredModelReplacementOverride = type; } public static void RegisterSuitModelReplacement(string suitNameToReplace, Type type) { suitNameToReplace = suitNameToReplace.ToLower().Replace(" ", ""); if (!type.IsSubclassOf(typeof(BodyReplacementBase))) { Instance.Logger.LogError((object)$"Cannot register body replacement type {type.GetType()}, must inherit from BodyReplacementBase"); return; } if (RegisteredModelReplacements.ContainsKey(suitNameToReplace)) { Instance.Logger.LogError((object)$"Cannot register body replacement type {type.GetType()}, suit name to replace {suitNameToReplace} is already registered."); return; } Instance.Logger.LogInfo((object)$"Registering body replacement type {type.GetType()} to suit name {suitNameToReplace}."); RegisteredModelReplacements.Add(suitNameToReplace, type); } public static void SetPlayerModelReplacement(PlayerControllerB player, Type type) { if (!type.IsSubclassOf(typeof(BodyReplacementBase))) { Instance.Logger.LogError((object)("Cannot set body replacement of type " + type.Name + ", must inherit from BodyReplacementBase")); return; } BodyReplacementBase component = ((Component)player.thisPlayerBody).gameObject.GetComponent<BodyReplacementBase>(); if ((Object)(object)component != (Object)null) { if (((object)component).GetType() == type) { return; } if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } } ((Component)player.thisPlayerBody).gameObject.AddComponent(type); } public static void RemovePlayerModelReplacement(PlayerControllerB player) { BodyReplacementBase component = ((Component)player.thisPlayerBody).gameObject.GetComponent<BodyReplacementBase>(); if (Object.op_Implicit((Object)(object)component)) { Object.Destroy((Object)(object)component); } } } public class PlayerDeathTracker : MonoBehaviour { private bool _died; public bool Died { get { return _died; } set { _died = value; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }
MoeCompany.dll
Decompiled 2 years agousing System; 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.Configuration; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ModelReplacement; using MoreCompany.Cosmetics; using MoreCompany.Utils; 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 = "")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("MoeCompany")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoeCompany")] [assembly: AssemblyTitle("MoeCompany")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace Mina.Cosmetics { public class EyeCoverBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/cover_eye_black.prefab"; public override string cosmeticId => "mina.covereyeblack"; public override string textureIconPath => "Assets/icons/eyecover_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class EyeCoverBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/cover_eye_blonde.prefab"; public override string cosmeticId => "mina.covereyeblonde"; public override string textureIconPath => "Assets/icons/eyecover_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class EyeCoverBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/cover_eye_brown.prefab"; public override string cosmeticId => "mina.covereyebrown"; public override string textureIconPath => "Assets/icons/eyecover_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class Hair1 : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/Hair1.prefab"; public override string cosmeticId => "mina.hair1"; public override string textureIconPath => "Assets/hair/hair1_icon.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class Hair1Blonde : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/Hair1_blonde.prefab"; public override string cosmeticId => "mina.hair1blonde"; public override string textureIconPath => "Assets/icons/default_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class Hair1Brown : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/Hair1_brown.prefab"; public override string cosmeticId => "mina.hair1brown"; public override string textureIconPath => "Assets/icons/default_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class HimecutBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/himecut/himecut_black.prefab"; public override string cosmeticId => "mina.himecutblack"; public override string textureIconPath => "Assets/icons/himecut_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class HimecutBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/himecut/himecut_blonde.prefab"; public override string cosmeticId => "mina.himecutblonde"; public override string textureIconPath => "Assets/icons/himecut_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class HimecutBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/himecut/himecut_brown.prefab"; public override string cosmeticId => "mina.himecutbrown"; public override string textureIconPath => "Assets/icons/himecut_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class MessyWhite : CosmeticGeneric { public override string gameObjectPath => "Assets/hair/messyhair_white.prefab"; public override string cosmeticId => "mina.messywhite"; public override string textureIconPath => "Assets/icons/messy_white.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailHairBlack.prefab"; public override string cosmeticId => "mina.ponytailblack"; public override string textureIconPath => "Assets/icons/ponytail_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailHairBlonde.prefab"; public override string cosmeticId => "mina.ponytailblonde"; public override string textureIconPath => "Assets/ponytail/blondethumbnail.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailHairBrown.prefab"; public override string cosmeticId => "mina.ponytailbrown"; public override string textureIconPath => "Assets/icons/ponytail_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBiggerBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailBiggerHairBlack.prefab"; public override string cosmeticId => "mina.ponytailblackbigger"; public override string textureIconPath => "Assets/icons/ponytail_bigger_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBiggerBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailBiggerHairBlonde.prefab"; public override string cosmeticId => "mina.ponytailblondebigger"; public override string textureIconPath => "Assets/icons/ponytail_bigger_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class PonytailBiggerBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/ponytail/PonyTailBiggerHairBrown.prefab"; public override string cosmeticId => "mina.ponytailbrownbigger"; public override string textureIconPath => "Assets/icons/ponytail_bigger_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class SidetailBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/sidetail/sidetail_black.prefab"; public override string cosmeticId => "mina.sidetailblack"; public override string textureIconPath => "Assets/icons/sidetail_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class SidetailBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/sidetail/sidetail_blonde.prefab"; public override string cosmeticId => "mina.sidetailblonde"; public override string textureIconPath => "Assets/icons/sidetail_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class SidetailBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/sidetail/sidetail_brown.prefab"; public override string cosmeticId => "mina.sidetailbrown"; public override string textureIconPath => "Assets/icons/sidetail_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/twintails/twintails_black.prefab"; public override string cosmeticId => "mina.twintailsblack"; public override string textureIconPath => "Assets/icons/twintails_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/twintails/twintails_blonde.prefab"; public override string cosmeticId => "mina.twintailsblonde"; public override string textureIconPath => "Assets/icons/twintails_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/twintails/twintails_brown.prefab"; public override string cosmeticId => "mina.twintailsbrown"; public override string textureIconPath => "Assets/icons/twintails_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsPink : CosmeticGeneric { public override string gameObjectPath => "Assets/twintails/twintails_pink.prefab"; public override string cosmeticId => "mina.twintailspink"; public override string textureIconPath => "Assets/icons/twintails_pink.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBackBlack : CosmeticGeneric { public override string gameObjectPath => "Assets/twintailsback/twintailsback_black.prefab"; public override string cosmeticId => "mina.twintailsbackblack"; public override string textureIconPath => "Assets/icons/twintailsback_black.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBackBlonde : CosmeticGeneric { public override string gameObjectPath => "Assets/twintailsback/twintailsback_blonde.prefab"; public override string cosmeticId => "mina.twintailsbackblonde"; public override string textureIconPath => "Assets/icons/twintailsback_blonde.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } public class TwintailsBackBrown : CosmeticGeneric { public override string gameObjectPath => "Assets/twintailsback/twintailsback_brown.prefab"; public override string cosmeticId => "mina.twintailsbackbrown"; public override string textureIconPath => "Assets/icons/twintailsback_brown.png"; public override CosmeticType cosmeticType => (CosmeticType)0; } } namespace SpaceGirlModelReplacement { public class BodyReplacementSpaceGirl : BodyReplacementBase { public override string boneMapFileName => "boneMapSpacegirl.json"; public override GameObject LoadAssetsAndReturnModel() { string text = "space girl"; return Assets.MainAssetBundle.LoadAsset<GameObject>(text); } public override void AddModelScripts() { } } [BepInPlugin("mina.SpaceGirlModelReplacement", "Space Girl", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyPostfix] public static void UpdatePatch(ref PlayerControllerB __instance) { if (__instance.playerSteamId != 0) { } } } public static ConfigFile config; public static ConfigEntry<float> UpdateRate { get; private set; } public static ConfigEntry<float> distanceDisablePhysics { get; private set; } public static ConfigEntry<bool> disablePhysicsAtRange { get; private set; } private static void InitConfig() { UpdateRate = config.Bind<float>("Dynamic Bone Settings", "Update rate", 60f, "Refreshes dynamic bones more times per second the higher the number"); disablePhysicsAtRange = config.Bind<bool>("Dynamic Bone Settings", "Disable physics at range", false, "Enable to disable physics past the specified range"); distanceDisablePhysics = config.Bind<float>("Dynamic Bone Settings", "Distance to disable physics", 20f, "If Disable physics at range is enabled, this is the range after which physics is disabled."); } private void Awake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown config = ((BaseUnityPlugin)this).Config; InitConfig(); AssetBundle val = BundleUtilities.LoadBundleFromInternalAssembly("hair", Assembly.GetExecutingAssembly()); CosmeticRegistry.LoadCosmeticsFromAssembly(Assembly.GetExecutingAssembly(), val); ModelReplacementAPI.RegisterSuitModelReplacement("Default", typeof(BodyReplacementSpaceGirl)); ModelReplacementAPI.RegisterSuitModelReplacement("주황색 슈트", typeof(BodyReplacementSpaceGirl)); ModelReplacementAPI.RegisterSuitModelReplacement("Orange suit", typeof(BodyReplacementSpaceGirl)); Assets.PopulateAssets(); Harmony val2 = new Harmony("mina.SpaceGirlModelReplacement"); val2.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin mina.SpaceGirlModelReplacement is loaded!"); } } public static class Assets { public static string mainAssetBundleName = "mbundle"; 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); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }
MoreCompany.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using MoreCompany.Cosmetics; using MoreCompany.Utils; using Steamworks; using Steamworks.Data; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.SceneManagement; 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: AssemblyTitle("MoreCompany")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoreCompany")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("511a1e5e-0611-49f1-b60f-cec69c668fd8")] [assembly: AssemblyFileVersion("1.7.1")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.7.1.0")] namespace MoreCompany { [HarmonyPatch(typeof(AudioMixer), "SetFloat")] public static class AudioMixerSetFloatPatch { public static bool Prefix(string name, float value) { if (name.StartsWith("PlayerVolume") || name.StartsWith("PlayerPitch")) { string s = name.Replace("PlayerVolume", "").Replace("PlayerPitch", ""); int num = int.Parse(s); PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[num]; AudioSource currentVoiceChatAudioSource = val.currentVoiceChatAudioSource; if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)currentVoiceChatAudioSource)) { if (name.StartsWith("PlayerVolume")) { currentVoiceChatAudioSource.volume = value / 16f; } else if (name.StartsWith("PlayerPitch")) { currentVoiceChatAudioSource.pitch = value; } } return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")] public static class SendChatToServerPatch { public static bool Prefix(HUDManager __instance, string chatMessage, int playerId = -1) { if (chatMessage.StartsWith("[morecompanycosmetics]")) { ReflectionUtils.InvokeMethod(__instance, "AddPlayerChatMessageServerRpc", new object[2] { chatMessage, 99 }); return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")] public static class ServerReceiveMessagePatch { public static string previousDataMessage = ""; public static bool Prefix(HUDManager __instance, ref string chatMessage, int playerId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (chatMessage.StartsWith("[morecompanycosmetics]") && networkManager.IsServer) { previousDataMessage = chatMessage; chatMessage = "[replacewithdata]"; } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static class ConnectClientToPlayerObjectPatch { public static void Postfix(PlayerControllerB __instance) { string text = "[morecompanycosmetics]"; text = text + ";" + __instance.playerClientId; foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { text = text + ";" + locallySelectedCosmetic; } HUDManager.Instance.AddTextToChatOnServer(text, -1); } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class AddChatMessagePatch { public static bool Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped = "") { if (chatMessage.StartsWith("[replacewithdata]") || chatMessage.StartsWith("[morecompanycosmetics]")) { return false; } return true; } } [HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")] public static class ClientReceiveMessagePatch { public static bool ignoreSample; public static bool died; public static bool Prefix(HUDManager __instance, ref string chatMessage, int playerId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (networkManager.IsServer) { if (chatMessage.StartsWith("[replacewithdata]")) { chatMessage = ServerReceiveMessagePatch.previousDataMessage; HandleDataMessage(chatMessage); } else if (chatMessage.StartsWith("[morecompanycosmetics]")) { return false; } } else if (chatMessage.StartsWith("[morecompanycosmetics]")) { HandleDataMessage(chatMessage); } return true; } private static void HandleDataMessage(string chatMessage) { //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown if (ignoreSample) { return; } chatMessage = chatMessage.Replace("[morecompanycosmetics]", ""); string[] array = chatMessage.Split(new char[1] { ';' }); string text = array[1]; int num = int.Parse(text); Transform val = ((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel"); val = ((Component)val).transform.parent; CosmeticApplication cosmeticApplication = ((!((Object)(object)((Component)val).gameObject.GetComponent<PlayerControllerB>().deadBody == (Object)null)) ? ((Component)((Component)val).gameObject.GetComponent<PlayerControllerB>().deadBody).gameObject.GetComponent<CosmeticApplication>() : ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.GetComponent<CosmeticApplication>()); if (Object.op_Implicit((Object)(object)cosmeticApplication)) { cosmeticApplication.ClearCosmetics(); Object.Destroy((Object)(object)cosmeticApplication); } CosmeticApplication cosmeticApplication2 = ((!((Object)(object)((Component)val).gameObject.GetComponent<PlayerControllerB>().deadBody == (Object)null)) ? ((Component)((Component)val).gameObject.GetComponent<PlayerControllerB>().deadBody).gameObject.AddComponent<CosmeticApplication>() : ((Component)((Component)StartOfRound.Instance.allPlayerScripts[num]).transform.Find("ScavengerModel").Find("metarig")).gameObject.AddComponent<CosmeticApplication>()); cosmeticApplication2.ClearCosmetics(); List<string> list = new List<string>(); string[] array2 = array; foreach (string text2 in array2) { if (!(text2 == text)) { if (text2 != null && text2 != "") { list.Add(text2); } if (MainClass.showCosmetics) { cosmeticApplication2.ApplyCosmetic(text2, startEnabled: true); } } } if (num == StartOfRound.Instance.thisClientPlayerId && (Object)(object)((Component)val).gameObject.GetComponent<PlayerControllerB>().deadBody == (Object)null) { cosmeticApplication2.ClearCosmetics(); } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication2.spawnedCosmetics) { Transform transform = ((Component)spawnedCosmetic).transform; transform.localScale *= 0.38f; Renderer[] componentsInChildren = ((Component)spawnedCosmetic).GetComponentsInChildren<Renderer>(); Material material = ((Renderer)((Component)((Component)val).GetComponent<PlayerControllerB>().thisPlayerModel).GetComponent<SkinnedMeshRenderer>()).material; Renderer[] array3 = componentsInChildren; foreach (Renderer val2 in array3) { List<Material> list2 = new List<Material>(); Material[] materials = val2.materials; foreach (Material val3 in materials) { Material val4 = new Material(material); val4.mainTexture = val3.mainTexture; list2.Add(val4); } val2.SetMaterials(list2); } } MainClass.playerIdsAndCosmetics.Remove(num); MainClass.playerIdsAndCosmetics.Add(num, list); if (!died) { ResetHair(num); } } public static void ResetHair(int playerIdNumeric) { if (!GameNetworkManager.Instance.isHostingGame || playerIdNumeric == 0) { return; } ignoreSample = true; foreach (KeyValuePair<int, List<string>> playerIdsAndCosmetic in MainClass.playerIdsAndCosmetics) { string text = "[morecompanycosmetics]"; text = text + ";" + playerIdsAndCosmetic.Key; foreach (string item in playerIdsAndCosmetic.Value) { text = text + ";" + item; } HUDManager.Instance.AddTextToChatOnServer(text, -1); } ignoreSample = false; } } [HarmonyPatch(typeof(ForestGiantAI), "LookForPlayers")] public static class LookForPlayersForestGiantPatch { public static void Prefix(ForestGiantAI __instance) { if (__instance.playerStealthMeters.Length != MainClass.newPlayerCount) { __instance.playerStealthMeters = new float[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { __instance.playerStealthMeters[i] = 0f; } } } } [HarmonyPatch(typeof(SpringManAI), "Update")] public static class SpringManAIUpdatePatch { public static bool Prefix(SpringManAI __instance, ref float ___timeSinceHittingPlayer, ref float ___stopAndGoMinimumInterval, ref bool ___wasOwnerLastFrame, ref bool ___stoppingMovement, ref float ___currentChaseSpeed, ref bool ___hasStopped, ref float ___currentAnimSpeed, ref float ___updateDestinationInterval, ref Vector3 ___tempVelocity, ref float ___targetYRotation, ref float ___setDestinationToPlayerInterval, ref float ___previousYRotation) { //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) UpdateBase((EnemyAI)(object)__instance, ref ___updateDestinationInterval, ref ___tempVelocity, ref ___targetYRotation, ref ___setDestinationToPlayerInterval, ref ___previousYRotation); if (((EnemyAI)__instance).isEnemyDead) { return false; } int currentBehaviourStateIndex = ((EnemyAI)__instance).currentBehaviourStateIndex; if (currentBehaviourStateIndex != 0 && currentBehaviourStateIndex == 1) { if (___timeSinceHittingPlayer >= 0f) { ___timeSinceHittingPlayer -= Time.deltaTime; } if (((NetworkBehaviour)__instance).IsOwner) { if (___stopAndGoMinimumInterval > 0f) { ___stopAndGoMinimumInterval -= Time.deltaTime; } if (!___wasOwnerLastFrame) { ___wasOwnerLastFrame = true; if (!___stoppingMovement && ___timeSinceHittingPlayer < 0.12f) { ((EnemyAI)__instance).agent.speed = ___currentChaseSpeed; } else { ((EnemyAI)__instance).agent.speed = 0f; } } bool flag = false; for (int i = 0; i < MainClass.newPlayerCount; i++) { if (((EnemyAI)__instance).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && StartOfRound.Instance.allPlayerScripts[i].HasLineOfSightToPosition(((Component)__instance).transform.position + Vector3.up * 1.6f, 68f, 60, -1f) && Vector3.Distance(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, ((EnemyAI)__instance).eye.position) > 0.3f) { flag = true; } } if (((EnemyAI)__instance).stunNormalizedTimer > 0f) { flag = true; } if (flag != ___stoppingMovement && ___stopAndGoMinimumInterval <= 0f) { ___stopAndGoMinimumInterval = 0.15f; if (flag) { __instance.SetAnimationStopServerRpc(); } else { __instance.SetAnimationGoServerRpc(); } ___stoppingMovement = flag; } } if (___stoppingMovement) { if (__instance.animStopPoints.canAnimationStop) { if (!___hasStopped) { ___hasStopped = true; __instance.mainCollider.isTrigger = false; if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)__instance).transform.position, 70f, 25, -1f)) { float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position); if (num < 4f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.9f, true); } else if (num < 9f) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.4f, true); } } if (___currentAnimSpeed > 2f) { RoundManager.PlayRandomClip(((EnemyAI)__instance).creatureVoice, __instance.springNoises, false, 1f, 0); if (__instance.animStopPoints.animationPosition == 1) { ((EnemyAI)__instance).creatureAnimator.SetTrigger("springBoing"); } else { ((EnemyAI)__instance).creatureAnimator.SetTrigger("springBoingPosition2"); } } } ((EnemyAI)__instance).creatureAnimator.SetFloat("walkSpeed", 0f); ___currentAnimSpeed = 0f; if (((NetworkBehaviour)__instance).IsOwner) { ((EnemyAI)__instance).agent.speed = 0f; return false; } } } else { if (___hasStopped) { ___hasStopped = false; __instance.mainCollider.isTrigger = true; } ___currentAnimSpeed = Mathf.Lerp(___currentAnimSpeed, 6f, 5f * Time.deltaTime); ((EnemyAI)__instance).creatureAnimator.SetFloat("walkSpeed", ___currentAnimSpeed); if (((NetworkBehaviour)__instance).IsOwner) { ((EnemyAI)__instance).agent.speed = Mathf.Lerp(((EnemyAI)__instance).agent.speed, ___currentChaseSpeed, 4.5f * Time.deltaTime); } } } return false; } private static void UpdateBase(EnemyAI __instance, ref float updateDestinationInterval, ref Vector3 tempVelocity, ref float targetYRotation, ref float setDestinationToPlayerInterval, ref float previousYRotation) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) if (__instance.enemyType.isDaytimeEnemy && !__instance.daytimeEnemyLeaving) { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "CheckTimeOfDayToLeave", null); } if (__instance.stunnedIndefinitely <= 0) { if ((double)__instance.stunNormalizedTimer >= 0.0) { __instance.stunNormalizedTimer -= Time.deltaTime / __instance.enemyType.stunTimeMultiplier; } else { __instance.stunnedByPlayer = null; if ((double)__instance.postStunInvincibilityTimer >= 0.0) { __instance.postStunInvincibilityTimer -= Time.deltaTime * 5f; } } } if (!__instance.ventAnimationFinished && (double)__instance.timeSinceSpawn < (double)__instance.exitVentAnimationTime + 0.004999999888241291 * (double)RoundManager.Instance.numberOfEnemiesInScene) { __instance.timeSinceSpawn += Time.deltaTime; if (!((NetworkBehaviour)__instance).IsOwner) { Vector3 serverPosition = __instance.serverPosition; if (__instance.serverPosition != Vector3.zero) { ((Component)__instance).transform.position = __instance.serverPosition; ((Component)__instance).transform.eulerAngles = new Vector3(((Component)__instance).transform.eulerAngles.x, targetYRotation, ((Component)__instance).transform.eulerAngles.z); } } else if ((double)updateDestinationInterval >= 0.0) { updateDestinationInterval -= Time.deltaTime; } else { __instance.SyncPositionToClients(); updateDestinationInterval = 0.1f; } return; } if (!__instance.ventAnimationFinished) { __instance.ventAnimationFinished = true; if ((Object)(object)__instance.creatureAnimator != (Object)null) { __instance.creatureAnimator.SetBool("inSpawningAnimation", false); } } if (!((NetworkBehaviour)__instance).IsOwner) { if (__instance.currentSearch.inProgress) { __instance.StopSearch(__instance.currentSearch, true); } __instance.SetClientCalculatingAI(false); if (!__instance.inSpecialAnimation) { ((Component)__instance).transform.position = Vector3.SmoothDamp(((Component)__instance).transform.position, __instance.serverPosition, ref tempVelocity, __instance.syncMovementSpeed); ((Component)__instance).transform.eulerAngles = new Vector3(((Component)__instance).transform.eulerAngles.x, Mathf.LerpAngle(((Component)__instance).transform.eulerAngles.y, targetYRotation, 15f * Time.deltaTime), ((Component)__instance).transform.eulerAngles.z); } __instance.timeSinceSpawn += Time.deltaTime; return; } if (__instance.isEnemyDead) { __instance.SetClientCalculatingAI(false); return; } if (!__instance.inSpecialAnimation) { __instance.SetClientCalculatingAI(true); } if (__instance.movingTowardsTargetPlayer && (Object)(object)__instance.targetPlayer != (Object)null) { if ((double)setDestinationToPlayerInterval <= 0.0) { setDestinationToPlayerInterval = 0.25f; __instance.destination = RoundManager.Instance.GetNavMeshPosition(((Component)__instance.targetPlayer).transform.position, RoundManager.Instance.navHit, 2.7f, -1); } else { __instance.destination = new Vector3(((Component)__instance.targetPlayer).transform.position.x, __instance.destination.y, ((Component)__instance.targetPlayer).transform.position.z); setDestinationToPlayerInterval -= Time.deltaTime; } } if (__instance.inSpecialAnimation) { return; } if ((double)updateDestinationInterval >= 0.0) { updateDestinationInterval -= Time.deltaTime; } else { __instance.DoAIInterval(); updateDestinationInterval = __instance.AIIntervalTime; } if (!((double)Mathf.Abs(previousYRotation - ((Component)__instance).transform.eulerAngles.y) <= 6.0)) { previousYRotation = ((Component)__instance).transform.eulerAngles.y; targetYRotation = previousYRotation; if (((NetworkBehaviour)__instance).IsServer) { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "UpdateEnemyRotationClientRpc", new object[1] { (short)previousYRotation }); } else { ReflectionUtils.InvokeMethod(__instance, typeof(EnemyAI), "UpdateEnemyRotationServerRpc", new object[1] { (short)previousYRotation }); } } } } [HarmonyPatch(typeof(SpringManAI), "DoAIInterval")] public static class SpringManAIIntervalPatch { public static bool Prefix(SpringManAI __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) if (((EnemyAI)__instance).moveTowardsDestination) { ((EnemyAI)__instance).agent.SetDestination(((EnemyAI)__instance).destination); } ((EnemyAI)__instance).SyncPositionToClients(); if (StartOfRound.Instance.allPlayersDead) { return false; } if (((EnemyAI)__instance).isEnemyDead) { return false; } switch (((EnemyAI)__instance).currentBehaviourStateIndex) { default: return false; case 1: if (__instance.searchForPlayers.inProgress) { ((EnemyAI)__instance).StopSearch(__instance.searchForPlayers, true); } if (((EnemyAI)__instance).TargetClosestPlayer(1.5f, false, 70f)) { PlayerControllerB fieldValue = ReflectionUtils.GetFieldValue<PlayerControllerB>(__instance, "previousTarget"); if ((Object)(object)fieldValue != (Object)(object)((EnemyAI)__instance).targetPlayer) { ReflectionUtils.SetFieldValue(__instance, "previousTarget", ((EnemyAI)__instance).targetPlayer); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(((EnemyAI)__instance).targetPlayer.actualClientId); } ((EnemyAI)__instance).movingTowardsTargetPlayer = true; return false; } ((EnemyAI)__instance).SwitchToBehaviourState(0); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); break; case 0: { if (!((NetworkBehaviour)__instance).IsServer) { ((EnemyAI)__instance).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId); return false; } for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (((EnemyAI)__instance).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && !Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.5f, ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 30f) { ((EnemyAI)__instance).SwitchToBehaviourState(1); return false; } } if (!__instance.searchForPlayers.inProgress) { ((EnemyAI)__instance).movingTowardsTargetPlayer = false; ((EnemyAI)__instance).StartSearch(((Component)__instance).transform.position, __instance.searchForPlayers); return false; } break; } } return false; } } [HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")] public static class GetClosestPlayerPatch { public static bool Prefix(EnemyAI __instance, ref PlayerControllerB __result, bool requireLineOfSight = false, bool cannotBeInShip = false, bool cannotBeNearShip = false) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) PlayerControllerB val = null; __instance.mostOptimalDistance = 2000f; for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!__instance.PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], cannotBeInShip, false)) { continue; } if (cannotBeNearShip) { if (StartOfRound.Instance.allPlayerScripts[i].isInElevator) { continue; } bool flag = false; for (int j = 0; j < RoundManager.Instance.spawnDenialPoints.Length; j++) { if (Vector3.Distance(RoundManager.Instance.spawnDenialPoints[j].transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 10f) { flag = true; break; } } if (flag) { continue; } } if (!requireLineOfSight || !Physics.Linecast(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position, 256)) { __instance.tempDist = Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position); if (__instance.tempDist < __instance.mostOptimalDistance) { __instance.mostOptimalDistance = __instance.tempDist; val = StartOfRound.Instance.allPlayerScripts[i]; } } } __result = val; return false; } } [HarmonyPatch(typeof(EnemyAI), "GetAllPlayersInLineOfSight")] public static class GetAllPlayersInLineOfSightPatch { public static bool Prefix(EnemyAI __instance, ref PlayerControllerB[] __result, float width = 45f, int range = 60, Transform eyeObject = null, float proximityCheck = -1f, int layerMask = -1) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_00b3: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if (layerMask == -1) { layerMask = StartOfRound.Instance.collidersAndRoomMaskAndDefault; } if ((Object)(object)eyeObject == (Object)null) { eyeObject = __instance.eye; } if (__instance.enemyType.isOutsideEnemy && !__instance.enemyType.canSeeThroughFog && (int)TimeOfDay.Instance.currentLevelWeather == 3) { range = Mathf.Clamp(range, 0, 30); } List<PlayerControllerB> list = new List<PlayerControllerB>(MainClass.newPlayerCount); for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++) { if (!__instance.PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false)) { continue; } Vector3 position = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position; if (Vector3.Distance(__instance.eye.position, position) < (float)range && !Physics.Linecast(eyeObject.position, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { Vector3 val = position - eyeObject.position; if (Vector3.Angle(eyeObject.forward, val) < width || Vector3.Distance(((Component)__instance).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < proximityCheck) { list.Add(StartOfRound.Instance.allPlayerScripts[i]); } } } if (list.Count == MainClass.newPlayerCount) { __result = StartOfRound.Instance.allPlayerScripts; return false; } if (list.Count > 0) { __result = list.ToArray(); return false; } __result = null; return false; } } [HarmonyPatch(typeof(DressGirlAI), "ChoosePlayerToHaunt")] public static class DressGirlHauntPatch { public static bool Prefix(DressGirlAI __instance) { ReflectionUtils.SetFieldValue(__instance, "timesChoosingAPlayer", ReflectionUtils.GetFieldValue<int>(__instance, "timesChoosingAPlayer") + 1); if (ReflectionUtils.GetFieldValue<int>(__instance, "timesChoosingAPlayer") > 1) { __instance.timer = __instance.hauntInterval - 1f; } __instance.SFXVolumeLerpTo = 0f; ((EnemyAI)__instance).creatureVoice.Stop(); __instance.heartbeatMusic.volume = 0f; if (!ReflectionUtils.GetFieldValue<bool>(__instance, "initializedRandomSeed")) { ReflectionUtils.SetFieldValue(__instance, "ghostGirlRandom", new Random(StartOfRound.Instance.randomMapSeed + 158)); } float num = 0f; float num2 = 0f; int num3 = 0; int num4 = 0; for (int i = 0; i < MainClass.newPlayerCount; i++) { if (StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount > num3) { num3 = StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount; num4 = i; } if (StartOfRound.Instance.allPlayerScripts[i].insanityLevel > num) { num = StartOfRound.Instance.allPlayerScripts[i].insanityLevel; num2 = i; } } int[] array = new int[MainClass.newPlayerCount]; for (int j = 0; j < MainClass.newPlayerCount; j++) { if (!StartOfRound.Instance.allPlayerScripts[j].isPlayerControlled) { array[j] = 0; continue; } array[j] += 80; if (num2 == (float)j && num > 1f) { array[j] += 50; } if (num4 == j) { array[j] += 30; } if (!StartOfRound.Instance.allPlayerScripts[j].hasBeenCriticallyInjured) { array[j] += 10; } if ((Object)(object)StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer != (Object)null && StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer.scrapValue > 150) { array[j] += 30; } } __instance.hauntingPlayer = StartOfRound.Instance.allPlayerScripts[RoundManager.Instance.GetRandomWeightedIndex(array, ReflectionUtils.GetFieldValue<Random>(__instance, "ghostGirlRandom"))]; if (__instance.hauntingPlayer.isPlayerDead) { for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++) { if (!StartOfRound.Instance.allPlayerScripts[k].isPlayerDead) { __instance.hauntingPlayer = StartOfRound.Instance.allPlayerScripts[k]; break; } } } Debug.Log((object)$"Little girl: Haunting player with playerClientId: {__instance.hauntingPlayer.playerClientId}; actualClientId: {__instance.hauntingPlayer.actualClientId}"); ((EnemyAI)__instance).ChangeOwnershipOfEnemy(__instance.hauntingPlayer.actualClientId); __instance.hauntingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)__instance.hauntingPlayer; if (ReflectionUtils.GetFieldValue<Coroutine>(__instance, "switchHauntedPlayerCoroutine") != null) { ((MonoBehaviour)__instance).StopCoroutine(ReflectionUtils.GetFieldValue<Coroutine>(__instance, "switchHauntedPlayerCoroutine")); } ReflectionUtils.SetFieldValue(__instance, "switchHauntedPlayerCoroutine", ((MonoBehaviour)__instance).StartCoroutine(ReflectionUtils.InvokeMethod<IEnumerator>(__instance, "setSwitchingHauntingPlayer", null))); return false; } } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class HudChatPatch { public static void Prefix(HUDManager __instance, ref string chatMessage, string nameOfUserWhoTyped = "") { if (!(__instance.lastChatMessage == chatMessage)) { StringBuilder stringBuilder = new StringBuilder(chatMessage); for (int i = 0; i < MainClass.newPlayerCount; i++) { string oldValue = $"[playerNum{i}]"; string playerUsername = StartOfRound.Instance.allPlayerScripts[i].playerUsername; stringBuilder.Replace(oldValue, playerUsername); } chatMessage = stringBuilder.ToString(); } } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerLogoOverridePatch { public static void Postfix(MenuManager __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) try { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.Find("MenuContainer").Find("MainButtons").Find("HeaderImage")).gameObject; Image component = gameObject2.GetComponent<Image>(); MainClass.ReadSettingsFromFile(); component.sprite = Sprite.Create(MainClass.mainLogo, new Rect(0f, 0f, (float)((Texture)MainClass.mainLogo).width, (float)((Texture)MainClass.mainLogo).height), new Vector2(0.5f, 0.5f)); CosmeticRegistry.SpawnCosmeticGUI(); Transform val = gameObject.transform.Find("MenuContainer").Find("LobbyHostSettings").Find("Panel") .Find("LobbyHostOptions") .Find("OptionsNormal"); GameObject val2 = Object.Instantiate<GameObject>(MainClass.crewCountUI, val); RectTransform component2 = val2.GetComponent<RectTransform>(); ((Transform)component2).localPosition = new Vector3(96.9f, -70f, -6.7f); TMP_InputField inputField = ((Component)val2.transform.Find("InputField (TMP)")).GetComponent<TMP_InputField>(); inputField.characterLimit = 3; inputField.text = MainClass.newPlayerCount.ToString(); ((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)delegate(string s) { if (int.TryParse(s, out var result)) { MainClass.newPlayerCount = result; MainClass.newPlayerCount = Mathf.Clamp(MainClass.newPlayerCount, 1, MainClass.maxPlayerCount); inputField.text = MainClass.newPlayerCount.ToString(); MainClass.SaveSettingsToFile(); } else if (s.Length != 0) { inputField.text = MainClass.newPlayerCount.ToString(); inputField.caretPosition = 1; } }); } catch (Exception) { } } } [HarmonyPatch(typeof(QuickMenuManager), "AddUserToPlayerList")] public static class AddUserPlayerListPatch { public static bool Prefix(QuickMenuManager __instance, ulong steamId, string playerName, int playerObjectId) { QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance); MainClass.EnablePlayerObjectsBasedOnConnected(); return false; } } [HarmonyPatch(typeof(QuickMenuManager), "RemoveUserFromPlayerList")] public static class RemoveUserPlayerListPatch { public static bool Prefix(QuickMenuManager __instance) { QuickmenuVisualInjectPatch.PopulateQuickMenu(__instance); return false; } } [HarmonyPatch(typeof(QuickMenuManager), "Update")] public static class QuickMenuUpdatePatch { public static bool Prefix(QuickMenuManager __instance) { return false; } } [HarmonyPatch(typeof(QuickMenuManager), "NonHostPlayerSlotsEnabled")] public static class QuickMenuDisplayPatch { public static bool Prefix(QuickMenuManager __instance, ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] public static class QuickmenuVisualInjectPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__2_2; internal void <PopulateQuickMenu>b__2_2() { if (!GameNetworkManager.Instance.disableSteam) { } } } public static GameObject quickMenuScrollInstance; public static void Postfix(QuickMenuManager __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)__instance.playerListPanel.transform.Find("Image")).gameObject; GameObject val = Object.Instantiate<GameObject>(MainClass.quickMenuScrollParent); val.transform.SetParent(gameObject.transform); RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).localPosition = new Vector3(0f, -31.2f, 0f); ((Transform)component).localScale = Vector3.one; quickMenuScrollInstance = val; } public static void PopulateQuickMenu(QuickMenuManager __instance) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown int childCount = quickMenuScrollInstance.transform.Find("Holder").childCount; List<GameObject> list = new List<GameObject>(); for (int i = 0; i < childCount; i++) { list.Add(((Component)quickMenuScrollInstance.transform.Find("Holder").GetChild(i)).gameObject); } foreach (GameObject item in list) { Object.Destroy((Object)(object)item); } if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return; } for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++) { PlayerControllerB playerScript = StartOfRound.Instance.allPlayerScripts[j]; if (!playerScript.isPlayerControlled && !playerScript.isPlayerDead) { continue; } GameObject val = Object.Instantiate<GameObject>(MainClass.playerEntry, quickMenuScrollInstance.transform.Find("Holder")); RectTransform component = val.GetComponent<RectTransform>(); ((Transform)component).localScale = Vector3.one; ((Transform)component).localPosition = new Vector3(0f, 0f - ((Transform)component).localPosition.y, 0f); TextMeshProUGUI component2 = ((Component)val.transform.Find("PlayerNameButton").Find("PName")).GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).text = playerScript.playerUsername; Slider playerVolume = ((Component)val.transform.Find("PlayerVolumeSlider")).GetComponent<Slider>(); int finalIndex = j; ((UnityEvent<float>)(object)playerVolume.onValueChanged).AddListener((UnityAction<float>)delegate(float f) { if (playerScript.isPlayerControlled || playerScript.isPlayerDead) { float num = f / playerVolume.maxValue + 1f; if (num <= -1f) { SoundManager.Instance.playerVoiceVolumes[finalIndex] = -70f; } else { SoundManager.Instance.playerVoiceVolumes[finalIndex] = num; } } }); if (StartOfRound.Instance.localPlayerController.playerClientId == playerScript.playerClientId) { ((Component)playerVolume).gameObject.SetActive(false); ((Component)val.transform.Find("Text (1)")).gameObject.SetActive(false); } Button component3 = ((Component)val.transform.Find("KickButton")).GetComponent<Button>(); ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { __instance.KickUserFromServer(finalIndex); }); if (!GameNetworkManager.Instance.isHostingGame) { ((Component)component3).gameObject.SetActive(false); } Button component4 = ((Component)val.transform.Find("ProfileIcon")).GetComponent<Button>(); ButtonClickedEvent onClick = component4.onClick; object obj = <>c.<>9__2_2; if (obj == null) { UnityAction val2 = delegate { if (!GameNetworkManager.Instance.disableSteam) { } }; <>c.<>9__2_2 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); } } } [HarmonyPatch(typeof(HUDManager), "UpdateBoxesSpectateUI")] public static class SpectatorBoxUpdatePatch { public static void Postfix(HUDManager __instance) { //IL_009c: 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) Dictionary<Animator, PlayerControllerB> fieldValue = ReflectionUtils.GetFieldValue<Dictionary<Animator, PlayerControllerB>>(__instance, "spectatingPlayerBoxes"); int num = -64; int num2 = 0; int num3 = 0; int num4 = -70; int num5 = 230; int num6 = 4; foreach (KeyValuePair<Animator, PlayerControllerB> item in fieldValue) { if (((Component)item.Key).gameObject.activeInHierarchy) { GameObject gameObject = ((Component)item.Key).gameObject; RectTransform component = gameObject.GetComponent<RectTransform>(); int num7 = (int)Math.Floor((double)num3 / (double)num6); int num8 = num3 % num6; int num9 = num8 * num4; int num10 = num7 * num5; component.anchoredPosition = Vector2.op_Implicit(new Vector3((float)(num + num10), (float)(num2 + num9), 0f)); num3++; } } } } [HarmonyPatch(typeof(HUDManager), "FillEndGameStats")] public static class HudFillEndGameFix { public static bool Prefix(HUDManager __instance, EndOfGameStats stats) { //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 int num = 0; int num2 = 0; for (int i = 0; i < __instance.statsUIElements.playerNamesText.Length; i++) { PlayerControllerB val = __instance.playersManager.allPlayerScripts[i]; ((TMP_Text)__instance.statsUIElements.playerNamesText[i]).text = ""; ((Behaviour)__instance.statsUIElements.playerStates[i]).enabled = false; ((TMP_Text)__instance.statsUIElements.playerNotesText[i]).text = "Notes: \n"; if (val.disconnectedMidGame || val.isPlayerDead || val.isPlayerControlled) { if (val.isPlayerDead) { num++; } else if (val.isPlayerControlled) { num2++; } ((TMP_Text)__instance.statsUIElements.playerNamesText[i]).text = __instance.playersManager.allPlayerScripts[i].playerUsername; ((Behaviour)__instance.statsUIElements.playerStates[i]).enabled = true; if (__instance.playersManager.allPlayerScripts[i].isPlayerDead) { if ((int)__instance.playersManager.allPlayerScripts[i].causeOfDeath == 10) { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.missingIcon; } else { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.deceasedIcon; } } else { __instance.statsUIElements.playerStates[i].sprite = __instance.statsUIElements.aliveIcon; } for (int j = 0; j < 3 && j < stats.allPlayerStats[i].playerNotes.Count; j++) { TextMeshProUGUI val2 = __instance.statsUIElements.playerNotesText[i]; ((TMP_Text)val2).text = ((TMP_Text)val2).text + "* " + stats.allPlayerStats[i].playerNotes[j] + "\n"; } } else { ((TMP_Text)__instance.statsUIElements.playerNotesText[i]).text = ""; } } ((TMP_Text)__instance.statsUIElements.quotaNumerator).text = RoundManager.Instance.scrapCollectedInLevel.ToString(); ((TMP_Text)__instance.statsUIElements.quotaDenominator).text = RoundManager.Instance.totalScrapValueInLevel.ToString(); if (StartOfRound.Instance.allPlayersDead) { ((Behaviour)__instance.statsUIElements.allPlayersDeadOverlay).enabled = true; ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "F"; return false; } ((Behaviour)__instance.statsUIElements.allPlayersDeadOverlay).enabled = false; int num3 = 0; float num4 = (float)RoundManager.Instance.scrapCollectedInLevel / RoundManager.Instance.totalScrapValueInLevel; if (num2 == StartOfRound.Instance.connectedPlayersAmount + 1) { num3++; } else if (num > 1) { num3--; } if (num4 >= 0.99f) { num3 += 2; } else if (num4 >= 0.6f) { num3++; } else if (num4 <= 0.25f) { num3--; } switch (num3) { case -1: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "D"; return false; case 0: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "C"; return false; case 1: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "B"; return false; case 2: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "A"; return false; case 3: ((TMP_Text)__instance.statsUIElements.gradeLetter).text = "S"; return false; default: return false; } } } [HarmonyPatch(typeof(HUDManager), "Start")] public static class HudStartPatch { public static void Postfix(HUDManager __instance) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) EndOfGameStatUIElements statsUIElements = __instance.statsUIElements; GameObject gameObject = ((Component)((Component)statsUIElements.playerNamesText[0]).gameObject.transform.parent).gameObject; GameObject gameObject2 = ((Component)gameObject.transform.parent.parent).gameObject; GameObject gameObject3 = ((Component)gameObject2.transform.Find("BGBoxes")).gameObject; gameObject2.transform.parent.Find("DeathScreen").SetSiblingIndex(3); gameObject3.transform.localScale = new Vector3(2.5f, 1f, 1f); MakePlayerHolder(4, gameObject, statsUIElements, new Vector3(426.9556f, -0.7932f, 0f)); MakePlayerHolder(5, gameObject, statsUIElements, new Vector3(426.9556f, -115.4483f, 0f)); MakePlayerHolder(6, gameObject, statsUIElements, new Vector3(-253.6783f, -115.4483f, 0f)); MakePlayerHolder(7, gameObject, statsUIElements, new Vector3(-253.6783f, -0.7932f, 0f)); for (int i = 8; i < MainClass.newPlayerCount; i++) { MakePlayerHolder(i, gameObject, statsUIElements, new Vector3(10000f, 10000f, 0f)); } } public static void MakePlayerHolder(int index, GameObject original, EndOfGameStatUIElements uiElements, Vector3 localPosition) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (index + 1 <= MainClass.newPlayerCount) { GameObject val = Object.Instantiate<GameObject>(original); RectTransform component = val.GetComponent<RectTransform>(); RectTransform component2 = original.GetComponent<RectTransform>(); ((Transform)component).SetParent(((Transform)component2).parent); ((Transform)component).localScale = new Vector3(1f, 1f, 1f); ((Transform)component).localPosition = localPosition; GameObject gameObject = ((Component)val.transform.Find("PlayerName1")).gameObject; GameObject gameObject2 = ((Component)val.transform.Find("Notes")).gameObject; ((Transform)gameObject2.GetComponent<RectTransform>()).localPosition = new Vector3(-95.7222f, 43.3303f, 0f); GameObject gameObject3 = ((Component)val.transform.Find("Symbol")).gameObject; if (index >= uiElements.playerNamesText.Length) { Array.Resize(ref uiElements.playerNamesText, index + 1); Array.Resize(ref uiElements.playerStates, index + 1); Array.Resize(ref uiElements.playerNotesText, index + 1); } uiElements.playerNamesText[index] = gameObject.GetComponent<TextMeshProUGUI>(); uiElements.playerNotesText[index] = gameObject2.GetComponent<TextMeshProUGUI>(); uiElements.playerStates[index] = gameObject3.GetComponent<Image>(); } } } public static class PluginInformation { public const string PLUGIN_NAME = "MoreCompany"; public const string PLUGIN_VERSION = "1.7.1"; public const string PLUGIN_GUID = "me.swipez.melonloader.morecompany"; } [BepInPlugin("me.swipez.melonloader.morecompany", "MoreCompany", "1.7.1")] public class MainClass : BaseUnityPlugin { public static int newPlayerCount = 32; public static int maxPlayerCount = 50; public static bool showCosmetics = true; public static List<PlayerControllerB> notSupposedToExistPlayers = new List<PlayerControllerB>(); public static Texture2D mainLogo; public static GameObject quickMenuScrollParent; public static GameObject playerEntry; public static GameObject crewCountUI; public static GameObject cosmeticGUIInstance; public static GameObject cosmeticButton; public static ManualLogSource StaticLogger; public static Dictionary<int, List<string>> playerIdsAndCosmetics = new Dictionary<int, List<string>>(); public static string cosmeticSavePath = Application.persistentDataPath + "/morecompanycosmetics.txt"; public static string moreCompanySave = Application.persistentDataPath + "/morecompanysave.txt"; public static string dynamicCosmeticsPath = Paths.PluginPath + "/MoreCompanyCosmetics"; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown StaticLogger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("me.swipez.melonloader.morecompany"); try { val.PatchAll(); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to patch: " + ex)); } ManualHarmonyPatches.ManualPatch(val); StaticLogger.LogInfo((object)"Loading MoreCompany..."); StaticLogger.LogInfo((object)("Checking: " + dynamicCosmeticsPath)); if (!Directory.Exists(dynamicCosmeticsPath)) { StaticLogger.LogInfo((object)"Creating cosmetics directory"); Directory.CreateDirectory(dynamicCosmeticsPath); } StaticLogger.LogInfo((object)"Loaded MoreCompany FULLY"); ReadSettingsFromFile(); ReadCosmeticsFromFile(); StaticLogger.LogInfo((object)"Read settings and cosmetics"); AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.assets", Assembly.GetExecutingAssembly()); AssetBundle val2 = BundleUtilities.LoadBundleFromInternalAssembly("morecompany.cosmetics", Assembly.GetExecutingAssembly()); CosmeticRegistry.LoadCosmeticsFromBundle(val2); val2.Unload(false); SteamFriends.OnGameLobbyJoinRequested += delegate(Lobby lobby, SteamId steamId) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; SteamMatchmaking.OnLobbyEntered += delegate(Lobby lobby) { newPlayerCount = ((Lobby)(ref lobby)).MaxMembers; }; StaticLogger.LogInfo((object)"Loading USER COSMETICS..."); RecursiveCosmeticLoad(dynamicCosmeticsPath); LoadAssets(bundle); } private void RecursiveCosmeticLoad(string directory) { string[] directories = Directory.GetDirectories(directory); foreach (string directory2 in directories) { RecursiveCosmeticLoad(directory2); } string[] files = Directory.GetFiles(directory); foreach (string text in files) { if (text.EndsWith(".cosmetics")) { AssetBundle val = AssetBundle.LoadFromFile(text); CosmeticRegistry.LoadCosmeticsFromBundle(val); val.Unload(false); } } } private void ReadCosmeticsFromFile() { if (File.Exists(cosmeticSavePath)) { string[] array = File.ReadAllLines(cosmeticSavePath); string[] array2 = array; foreach (string item in array2) { CosmeticRegistry.locallySelectedCosmetics.Add(item); } } } public static void WriteCosmeticsToFile() { string text = ""; foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics) { text = text + locallySelectedCosmetic + "\n"; } File.WriteAllText(cosmeticSavePath, text); } public static void SaveSettingsToFile() { string text = ""; text = text + newPlayerCount + "\n"; text = text + showCosmetics + "\n"; File.WriteAllText(moreCompanySave, text); } public static void ReadSettingsFromFile() { if (File.Exists(moreCompanySave)) { string[] array = File.ReadAllLines(moreCompanySave); try { newPlayerCount = int.Parse(array[0]); showCosmetics = bool.Parse(array[1]); } catch (Exception) { StaticLogger.LogError((object)"Failed to read settings from file, resetting to default"); newPlayerCount = 32; showCosmetics = true; } } } private static void LoadAssets(AssetBundle bundle) { if (Object.op_Implicit((Object)(object)bundle)) { mainLogo = bundle.LoadPersistentAsset<Texture2D>("assets/morecompanyassets/morecompanytransparentred.png"); quickMenuScrollParent = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/quickmenuoverride.prefab"); playerEntry = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/playerlistslot.prefab"); cosmeticGUIInstance = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/testoverlay.prefab"); cosmeticButton = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/cosmeticinstance.prefab"); crewCountUI = bundle.LoadPersistentAsset<GameObject>("assets/morecompanyassets/crewcountfield.prefab"); bundle.Unload(false); } } public static void ResizePlayerCache(Dictionary<uint, Dictionary<int, NetworkObject>> ScenePlacedObjects) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown StartOfRound instance = StartOfRound.Instance; if (instance.allPlayerObjects.Length == newPlayerCount) { return; } playerIdsAndCosmetics.Clear(); uint num = 10000u; int num2 = newPlayerCount - instance.allPlayerObjects.Length; int num3 = instance.allPlayerObjects.Length; GameObject val = instance.allPlayerObjects[3]; for (int i = 0; i < num2; i++) { uint num4 = num + (uint)i; GameObject val2 = Object.Instantiate<GameObject>(val); NetworkObject component = val2.GetComponent<NetworkObject>(); ReflectionUtils.SetFieldValue(component, "GlobalObjectIdHash", num4); Scene scene = ((Component)component).gameObject.scene; int handle = ((Scene)(ref scene)).handle; uint num5 = num4; if (!ScenePlacedObjects.ContainsKey(num5)) { ScenePlacedObjects.Add(num5, new Dictionary<int, NetworkObject>()); } if (ScenePlacedObjects[num5].ContainsKey(handle)) { string arg = (((Object)(object)ScenePlacedObjects[num5][handle] != (Object)null) ? ((Object)ScenePlacedObjects[num5][handle]).name : "Null Entry"); throw new Exception(((Object)component).name + " tried to registered with ScenePlacedObjects which already contains " + string.Format("the same {0} value {1} for {2}!", "GlobalObjectIdHash", num5, arg)); } ScenePlacedObjects[num5].Add(handle, component); ((Object)val2).name = $"Player ({4 + i})"; val2.transform.parent = null; PlayerControllerB componentInChildren = val2.GetComponentInChildren<PlayerControllerB>(); notSupposedToExistPlayers.Add(componentInChildren); componentInChildren.playerClientId = (ulong)(4 + i); componentInChildren.isPlayerControlled = false; componentInChildren.isPlayerDead = false; componentInChildren.DropAllHeldItems(false, false); componentInChildren.TeleportPlayer(instance.notSpawnedPosition.position, false, 0f, false, true); UnlockableSuit.SwitchSuitForPlayer(componentInChildren, 0, false); Array.Resize(ref instance.allPlayerObjects, instance.allPlayerObjects.Length + 1); Array.Resize(ref instance.allPlayerScripts, instance.allPlayerScripts.Length + 1); Array.Resize(ref instance.gameStats.allPlayerStats, instance.gameStats.allPlayerStats.Length + 1); Array.Resize(ref instance.playerSpawnPositions, instance.playerSpawnPositions.Length + 1); instance.allPlayerObjects[num3 + i] = val2; instance.gameStats.allPlayerStats[num3 + i] = new PlayerStats(); instance.allPlayerScripts[num3 + i] = componentInChildren; instance.playerSpawnPositions[num3 + i] = instance.playerSpawnPositions[3]; } } public static void EnablePlayerObjectsBasedOnConnected() { int connectedPlayersAmount = StartOfRound.Instance.connectedPlayersAmount; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { for (int j = 0; j < connectedPlayersAmount + 1; j++) { if (!val.isPlayerControlled) { ((Component)val).gameObject.SetActive(false); } else { ((Component)val).gameObject.SetActive(true); } } } } } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesServerRpc")] public static class SendNewPlayerValuesServerRpcPatch { public static ulong lastId; public static void Prefix(PlayerControllerB __instance, ulong newPlayerSteamId) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && networkManager.IsServer) { lastId = newPlayerSteamId; } } } [HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")] public static class SendNewPlayerValuesClientRpcPatch { public static void Prefix(PlayerControllerB __instance, ref ulong[] playerSteamIds) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return; } if (StartOfRound.Instance.mapScreen.radarTargets.Count != MainClass.newPlayerCount) { List<PlayerControllerB> useless = new List<PlayerControllerB>(); foreach (PlayerControllerB notSupposedToExistPlayer in MainClass.notSupposedToExistPlayers) { if (Object.op_Implicit((Object)(object)notSupposedToExistPlayer)) { StartOfRound.Instance.mapScreen.radarTargets.Add(new TransformAndName(((Component)notSupposedToExistPlayer).transform, notSupposedToExistPlayer.playerUsername, false)); } else { useless.Add(notSupposedToExistPlayer); } } MainClass.notSupposedToExistPlayers.RemoveAll((PlayerControllerB x) => useless.Contains(x)); } if (!networkManager.IsServer) { return; } List<ulong> list = new List<ulong>(); for (int i = 0; i < MainClass.newPlayerCount; i++) { if (i == (int)__instance.playerClientId) { list.Add(SendNewPlayerValuesServerRpcPatch.lastId); } else { list.Add(__instance.playersManager.allPlayerScripts[i].playerSteamId); } } playerSteamIds = list.ToArray(); } } public static class HUDManagerBullshitPatch { public static bool ManualPrefix(HUDManager __instance) { return false; } } [HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")] public static class SyncShipUnlockablePatch { public static void Prefix(StartOfRound __instance, ref int[] playerSuitIDs, bool shipLightsOn, Vector3[] placeableObjectPositions, Vector3[] placeableObjectRotations, int[] placeableObjects, int[] storedItems, int[] scrapValues, int[] itemSaveData) { NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && networkManager.IsServer) { int[] array = new int[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { array[i] = __instance.allPlayerScripts[i].currentSuitID; } playerSuitIDs = array; } } } [HarmonyPatch(typeof(NetworkSceneManager), "PopulateScenePlacedObjects")] public static class ScenePlacedObjectsInitPatch { public static void Postfix(ref Dictionary<uint, Dictionary<int, NetworkObject>> ___ScenePlacedObjects) { MainClass.ResizePlayerCache(___ScenePlacedObjects); } } [HarmonyPatch(typeof(GameNetworkManager), "LobbyDataIsJoinable")] public static class LobbyDataJoinablePatch { public static bool Prefix(ref bool __result) { __result = true; return false; } } [HarmonyPatch(typeof(NetworkConnectionManager), "HandleConnectionApproval")] public static class ConnectionApprovalTest { public static void Prefix(ulong ownerClientId, ConnectionApprovalResponse response) { if (Object.op_Implicit((Object)(object)StartOfRound.Instance)) { if (StartOfRound.Instance.connectedPlayersAmount >= MainClass.newPlayerCount) { response.Approved = false; response.Reason = "Server is full"; } else { response.Approved = true; } } } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")] public static class LobbyThingPatch { public static void Prefix(ref int maxMembers) { MainClass.ReadSettingsFromFile(); maxMembers = MainClass.newPlayerCount; } } public class ManualHarmonyPatches { public static void ManualPatch(Harmony HarmonyInstance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(HUDManager), "SyncAllPlayerLevelsServerRpc", new Type[0], (Type[])null), new HarmonyMethod(typeof(HUDManagerBullshitPatch).GetMethod("ManualPrefix")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } public class ReflectionUtils { public static void InvokeMethod(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void InvokeMethod(object obj, Type forceType, string methodName, object[] parameters) { MethodInfo method = forceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); method.Invoke(obj, parameters); } public static void SetPropertyValue(object obj, string propertyName, object value) { Type type = obj.GetType(); PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); property.SetValue(obj, value); } public static T InvokeMethod<T>(object obj, string methodName, object[] parameters) { Type type = obj.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)method.Invoke(obj, parameters); } public static T GetFieldValue<T>(object obj, string fieldName) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); return (T)field.GetValue(obj); } public static void SetFieldValue(object obj, string fieldName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field.SetValue(obj, value); } } [HarmonyPatch(typeof(ShipTeleporter), "Awake")] public static class ShipTeleporterAwakePatch { public static void Postfix(ShipTeleporter __instance) { int[] array = new int[MainClass.newPlayerCount]; for (int i = 0; i < MainClass.newPlayerCount; i++) { array[i] = -1; } ReflectionUtils.SetFieldValue(__instance, "playersBeingTeleported", array); } } [HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")] public static class SpectatePatches { public static bool Prefix(PlayerControllerB __instance) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) int num = 0; if ((Object)(object)__instance.spectatedPlayerScript != (Object)null) { num = (int)__instance.spectatedPlayerScript.playerClientId; } for (int i = 0; i < MainClass.newPlayerCount; i++) { num = (num + 1) % MainClass.newPlayerCount; if (!__instance.playersManager.allPlayerScripts[num].isPlayerDead && __instance.playersManager.allPlayerScripts[num].isPlayerControlled && (Object)(object)__instance.playersManager.allPlayerScripts[num] != (Object)(object)__instance) { __instance.spectatedPlayerScript = __instance.playersManager.allPlayerScripts[num]; __instance.SetSpectatedPlayerEffects(false); return false; } } if ((Object)(object)__instance.deadBody != (Object)null && ((Component)__instance.deadBody).gameObject.activeSelf) { __instance.spectateCameraPivot.position = __instance.deadBody.bodyParts[0].position; ReflectionUtils.InvokeMethod(__instance, "RaycastSpectateCameraAroundPivot", null); } StartOfRound.Instance.SetPlayerSafeInShip(); return false; } } [HarmonyPatch(typeof(SoundManager), "Start")] public static class SoundManagerStartPatch { public static void Postfix() { int num = MainClass.newPlayerCount - 4; int num2 = 4; for (int i = 0; i < num; i++) { Array.Resize(ref SoundManager.Instance.playerVoicePitches, SoundManager.Instance.playerVoicePitches.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoicePitchTargets, SoundManager.Instance.playerVoicePitchTargets.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoiceVolumes, SoundManager.Instance.playerVoiceVolumes.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoicePitchLerpSpeed, SoundManager.Instance.playerVoicePitchLerpSpeed.Length + 1); Array.Resize(ref SoundManager.Instance.playerVoiceMixers, SoundManager.Instance.playerVoiceMixers.Length + 1); AudioMixerGroup val = ((IEnumerable<AudioMixerGroup>)Resources.FindObjectsOfTypeAll<AudioMixerGroup>()).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup x) => ((Object)x).name.Contains("Voice"))); SoundManager.Instance.playerVoicePitches[num2 + i] = 1f; SoundManager.Instance.playerVoicePitchTargets[num2 + i] = 1f; SoundManager.Instance.playerVoiceVolumes[num2 + i] = 0.5f; SoundManager.Instance.playerVoicePitchLerpSpeed[num2 + i] = 3f; SoundManager.Instance.playerVoiceMixers[num2 + i] = val; } } } [HarmonyPatch(typeof(StartOfRound), "GetPlayerSpawnPosition")] public static class SpawnPositionClampPatch { public static void Prefix(ref int playerNum, bool simpleTeleport = false) { if (playerNum > 3) { playerNum = 3; } } } [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] public static class OnClientConnectedPatch { public static bool Prefix(StartOfRound __instance, ulong clientId) { if (!((NetworkBehaviour)__instance).IsServer) { return false; } Debug.Log((object)"player connected"); Debug.Log((object)$"connected players #: {__instance.connectedPlayersAmount}"); try { List<int> list = __instance.ClientPlayerList.Values.ToList(); Debug.Log((object)$"Connecting new player on host; clientId: {clientId}"); int num = 0; for (int i = 1; i < MainClass.newPlayerCount; i++) { if (!list.Contains(i)) { num = i; break; } } __instance.allPlayerScripts[num].actualClientId = clientId; __instance.allPlayerObjects[num].GetComponent<NetworkObject>().ChangeOwnership(clientId); Debug.Log((object)$"New player assigned object id: {__instance.allPlayerObjects[num]}"); List<ulong> list2 = new List<ulong>(); for (int j = 0; j < __instance.allPlayerObjects.Length; j++) { NetworkObject component = __instance.allPlayerObjects[j].GetComponent<NetworkObject>(); if (!component.IsOwnedByServer) { list2.Add(component.OwnerClientId); } else if (j == 0) { list2.Add(NetworkManager.Singleton.LocalClientId); } else { list2.Add(999uL); } } int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits; int profitQuota = TimeOfDay.Instance.profitQuota; int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled; int num2 = (int)TimeOfDay.Instance.timeUntilDeadline; ReflectionUtils.InvokeMethod(__instance, "OnPlayerConnectedClientRpc", new object[10] { clientId, __instance.connectedPlayersAmount, list2.ToArray(), num, groupCredits, __instance.currentLevelID, profitQuota, num2, quotaFulfilled, __instance.randomMapSeed }); __instance.ClientPlayerList.Add(clientId, num); Debug.Log((object)$"client id connecting: {clientId} ; their corresponding player object id: {num}"); } catch (Exception arg) { Debug.LogError((object)$"Error occured in OnClientConnected! Shutting server down. clientId: {clientId}. Error: {arg}"); GameNetworkManager.Instance.disconnectionReasonMessage = "Error occured when a player attempted to join the server! Restart the application and please report the glitch!"; GameNetworkManager.Instance.Disconnect(); } return false; } } [HarmonyPatch(typeof(SteamLobbyManager), "LoadServerList")] public static class LoadServerListPatch { public static bool Prefix(SteamLobbyManager __instance) { OverrideMethod(__instance); return false; } private static async void OverrideMethod(SteamLobbyManager __instance) { if (GameNetworkManager.Instance.waitingForLobbyDataRefresh) { return; } ReflectionUtils.SetFieldValue(__instance, "refreshServerListTimer", 0f); ((TMP_Text)__instance.serverListBlankText).text = "Loading server list..."; ReflectionUtils.GetFieldValue<Lobby[]>(__instance, "currentLobbyList"); LobbySlot[] array = Object.FindObjectsOfType<LobbySlot>(); for (int i = 0; i < array.Length; i++) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } LobbyQuery val; switch (__instance.sortByDistanceSetting) { case 0: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceClose(); break; case 1: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceFar(); break; case 2: val = SteamMatchmaking.LobbyList; ((LobbyQuery)(ref val)).FilterDistanceWorldwide(); break; } Debug.Log((object)"Requested server list"); GameNetworkManager.Instance.waitingForLobbyDataRefresh = true; Lobby[] currentLobbyList; switch (__instance.sortByDistanceSetting) { case 0: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceClose(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; case 1: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceFar(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; default: val = SteamMatchmaking.LobbyList; val = ((LobbyQuery)(ref val)).FilterDistanceWorldwide(); val = ((LobbyQuery)(ref val)).WithSlotsAvailable(1); val = ((LobbyQuery)(ref val)).WithKeyValue("vers", GameNetworkManager.Instance.gameVersionNum.ToString()); currentLobbyList = await ((LobbyQuery)(ref val)).RequestAsync(); break; } GameNetworkManager.Instance.waitingForLobbyDataRefresh = false; if (currentLobbyList != null) { Debug.Log((object)"Got lobby list!"); ReflectionUtils.InvokeMethod(__instance, "DebugLogServerList", null); if (currentLobbyList.Length == 0) { ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join."; } else { ((TMP_Text)__instance.serverListBlankText).text = ""; } ReflectionUtils.SetFieldValue(__instance, "lobbySlotPositionOffset", 0f); for (int j = 0; j < currentLobbyList.Length; j++) { Friend[] array2 = SteamFriends.GetBlocked().ToArray(); if (array2 != null) { for (int k = 0; k < array2.Length; k++) { Debug.Log((object)$"blocked user: {((Friend)(ref array2[k])).Name}; id: {array2[k].Id}"); if (((Lobby)(ref currentLobbyList[j])).IsOwnedBy(array2[k].Id)) { Debug.Log((object)("Hiding lobby by blocked user: " + ((Friend)(ref array2[k])).Name)); } } } else { Debug.Log((object)"Blocked users list is null"); } GameObject gameObject = Object.Instantiate<GameObject>(__instance.LobbySlotPrefab, __instance.levelListContainer); gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 0f + ReflectionUtils.GetFieldValue<float>(__instance, "lobbySlotPositionOffset")); ReflectionUtils.SetFieldValue(__instance, "lobbySlotPositionOffset", ReflectionUtils.GetFieldValue<float>(__instance, "lobbySlotPositionOffset") - 42f); LobbySlot componentInChildren = gameObject.GetComponentInChildren<LobbySlot>(); ((TMP_Text)componentInChildren.LobbyName).text = ((Lobby)(ref currentLobbyList[j])).GetData("name"); ((TMP_Text)componentInChildren.playerCount).text = $"{((Lobby)(ref currentLobbyList[j])).MemberCount} / {((Lobby)(ref currentLobbyList[j])).MaxMembers}"; componentInChildren.lobbyId = ((Lobby)(ref currentLobbyList[j])).Id; componentInChildren.thisLobby = currentLobbyList[j]; ReflectionUtils.SetFieldValue(__instance, "currentLobbyList", currentLobbyList); } } else { Debug.Log((object)"Lobby list is null after request."); ((TMP_Text)__instance.serverListBlankText).text = "No available servers to join."; } } } [HarmonyPatch(typeof(GameNetworkManager), "Awake")] public static class GameNetworkAwakePatch { public static int originalVersion; public static void Postfix(GameNetworkManager __instance) { originalVersion = __instance.gameVersionNum; if (!AssemblyChecker.HasAssemblyLoaded("lc_api")) { __instance.gameVersionNum = 9999; } } } [HarmonyPatch(typeof(MenuManager), "Awake")] public static class MenuManagerVersionDisplayPatch { public static void Postfix(MenuManager __instance) { if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)__instance.versionNumberText != (Object)null) { ((TMP_Text)__instance.versionNumberText).text = $"v{GameNetworkAwakePatch.originalVersion} (MC)"; } } } } namespace MoreCompany.Utils { public class AssemblyChecker { public static bool HasAssemblyLoaded(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { if (assembly.GetName().Name.ToLower().Equals(name)) { return true; } } return false; } } public class BundleUtilities { public static byte[] GetResourceBytes(string filename, Assembly assembly) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(filename)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } return null; } public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly) { return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly)); } } public static class AssetBundleExtension { public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object { Object val = bundle.LoadAsset(name); if (val != (Object)null) { val.hideFlags = (HideFlags)32; return (T)(object)val; } return default(T); } } } namespace MoreCompany.Cosmetics { public class CosmeticApplication : MonoBehaviour { public Transform head; public Transform hip; public Transform lowerArmRight; public Transform shinLeft; public Transform shinRight; public Transform chest; public List<CosmeticInstance> spawnedCosmetics = new List<CosmeticInstance>(); public void Awake() { head = FindDeepChild(((Component)this).transform, "spine/root.x/spine_01.x/spine_02.x/spine_03.x/neck.x/head.x"); if ((Object)(object)head == (Object)null) { head = FindDeepChild(((Component)this).transform, "root.x/spine_01.x/spine_02.x/spine_03.x/neck.x/head.x"); } if ((Object)(object)head == (Object)null) { head = FindDeepChild(((Component)this).transform, "spine/spine.001/spine.002/spine.003/spine.004"); } chest = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002") .Find("spine.003"); lowerArmRight = ((Component)this).transform.Find("spine").Find("spine.001").Find("spine.002") .Find("spine.003") .Find("shoulder.R") .Find("arm.R_upper") .Find("arm.R_lower"); hip = ((Component)this).transform.Find("spine"); shinLeft = ((Component)this).transform.Find("spine").Find("thigh.L").Find("shin.L"); shinRight = ((Component)this).transform.Find("spine").Find("thigh.R").Find("shin.R"); if (!Object.op_Implicit((Object)(object)head)) { RefreshAllCosmeticPositions(); } } private void OnDisable() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ((Component)spawnedCosmetic).gameObject.SetActive(false); } } private void OnEnable() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ((Component)spawnedCosmetic).gameObject.SetActive(true); } } public void ClearCosmetics() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { Object.Destroy((Object)(object)((Component)spawnedCosmetic).gameObject); } spawnedCosmetics.Clear(); } public void ApplyCosmetic(string cosmeticId, bool startEnabled) { if (CosmeticRegistry.cosmeticInstances.ContainsKey(cosmeticId)) { CosmeticInstance cosmeticInstance = CosmeticRegistry.cosmeticInstances[cosmeticId]; GameObject val = Object.Instantiate<GameObject>(((Component)cosmeticInstance).gameObject); val.SetActive(startEnabled); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); spawnedCosmetics.Add(component); if (startEnabled) { ParentCosmetic(component); } } } public void RefreshAllCosmeticPositions() { foreach (CosmeticInstance spawnedCosmetic in spawnedCosmetics) { ParentCosmetic(spawnedCosmetic); } } private void ParentCosmetic(CosmeticInstance cosmeticInstance) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Transform val = null; switch (cosmeticInstance.cosmeticType) { case CosmeticType.HAT: val = head; break; case CosmeticType.R_LOWER_ARM: val = lowerArmRight; break; case CosmeticType.HIP: val = hip; break; case CosmeticType.L_SHIN: val = shinLeft; break; case CosmeticType.R_SHIN: val = shinRight; break; case CosmeticType.CHEST: val = chest; break; } ((Component)cosmeticInstance).transform.position = val.position; ((Component)cosmeticInstance).transform.rotation = val.rotation; ((Component)cosmeticInstance).transform.parent = val; } private Transform FindDeepChild(Transform parent, string path) { Transform val = parent; string[] array = path.Split(new char[1] { '/' }); foreach (string text in array) { if ((Object)(object)val == (Object)null) { return null; } val = val.Find(text); } return val; } } public class CosmeticInstance : MonoBehaviour { public CosmeticType cosmeticType; public string cosmeticId; public Texture2D icon; } public class CosmeticGeneric { public virtual string gameObjectPath { get; } public virtual string cosmeticId { get; } public virtual string textureIconPath { get; } public virtual CosmeticType cosmeticType { get; } public void LoadFromBundle(AssetBundle bundle) { GameObject val = bundle.LoadPersistentAsset<GameObject>(gameObjectPath); Texture2D icon = bundle.LoadPersistentAsset<Texture2D>(textureIconPath); CosmeticInstance cosmeticInstance = val.AddComponent<CosmeticInstance>(); cosmeticInstance.cosmeticId = cosmeticId; cosmeticInstance.icon = icon; cosmeticInstance.cosmeticType = cosmeticType; MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + cosmeticId + " from bundle: " + ((Object)bundle).name)); CosmeticRegistry.cosmeticInstances.Add(cosmeticId, cosmeticInstance); } } public enum CosmeticType { HAT, WRIST, CHEST, R_LOWER_ARM, HIP, L_SHIN, R_SHIN } public class CosmeticRegistry { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__7_0; public static UnityAction <>9__7_1; internal void <SpawnCosmeticGUI>b__7_0() { MainClass.showCosmetics = true; MainClass.SaveSettingsToFile(); } internal void <SpawnCosmeticGUI>b__7_1() { MainClass.showCosmetics = false; MainClass.SaveSettingsToFile(); } } public static Dictionary<string, CosmeticInstance> cosmeticInstances = new Dictionary<string, CosmeticInstance>(); public static GameObject cosmeticGUI; private static GameObject displayGuy; private static CosmeticApplication cosmeticApplication; public static List<string> locallySelectedCosmetics = new List<string>(); public static void LoadCosmeticsFromBundle(AssetBundle bundle) { string[] allAssetNames = bundle.GetAllAssetNames(); foreach (string text in allAssetNames) { if (text.EndsWith(".prefab")) { GameObject val = bundle.LoadPersistentAsset<GameObject>(text); CosmeticInstance component = val.GetComponent<CosmeticInstance>(); if (!((Object)(object)component == (Object)null)) { MainClass.StaticLogger.LogInfo((object)("Loaded cosmetic: " + component.cosmeticId + " from bundle")); cosmeticInstances.Add(component.cosmeticId, component); } } } } public static void LoadCosmeticsFromAssembly(Assembly assembly, AssetBundle bundle) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(CosmeticGeneric))) { CosmeticGeneric cosmeticGeneric = (CosmeticGeneric)type.GetConstructor(new Type[0]).Invoke(new object[0]); cosmeticGeneric.LoadFromBundle(bundle); } } } public static void SpawnCosmeticGUI() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_010e: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown cosmeticGUI = Object.Instantiate<GameObject>(MainClass.cosmeticGUIInstance); ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale")).transform.localScale = new Vector3(2f, 2f, 2f); displayGuy = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("ObjectHolder") .Find("ScavengerModel") .Find("metarig")).gameObject; cosmeticApplication = displayGuy.AddComponent<CosmeticApplication>(); GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("EnableButton")).gameObject; ButtonClickedEvent onClick = gameObject.GetComponent<Button>().onClick; object obj = <>c.<>9__7_0; if (obj == null) { UnityAction val = delegate { MainClass.showCosmetics = true; MainClass.SaveSettingsToFile(); }; <>c.<>9__7_0 = val; obj = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj); GameObject gameObject2 = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("DisableButton")).gameObject; ButtonClickedEvent onClick2 = gameObject2.GetComponent<Button>().onClick; object obj2 = <>c.<>9__7_1; if (obj2 == null) { UnityAction val2 = delegate { MainClass.showCosmetics = false; MainClass.SaveSettingsToFile(); }; <>c.<>9__7_1 = val2; obj2 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); if (MainClass.showCosmetics) { gameObject.SetActive(false); gameObject2.SetActive(true); } else { gameObject.SetActive(true); gameObject2.SetActive(false); } PopulateCosmetics(); UpdateCosmeticsOnDisplayGuy(startEnabled: false); } public static void PopulateCosmetics() { //IL_0106: 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_021e: Expected O, but got Unknown GameObject gameObject = ((Component)cosmeticGUI.transform.Find("Canvas").Find("GlobalScale").Find("CosmeticsScreen") .Find("CosmeticsHolder") .Find("Content")).gameObject; List<Transform> list = new List<Transform>(); for (int i = 0; i < gameObject.transform.childCount; i++) { list.Add(gameObject.transform.GetChild(i)); } foreach (Transform item in list) { Object.Destroy((Object)(object)((Component)item).gameObject); } foreach (KeyValuePair<string, CosmeticInstance> cosmeticInstance in cosmeticInstances) { GameObject val = Object.Instantiate<GameObject>(MainClass.cosmeticButton, gameObject.transform); val.transform.localScale = Vector3.one; GameObject disabledOverlay = ((Component)val.transform.Find("Deselected")).gameObject; disabledOverlay.SetActive(true); GameObject enabledOverlay = ((Component)val.transform.Find("Selected")).gameObject; enabledOverlay.SetActive(true); if (IsEquipped(cosmeticInstance.Value.cosmeticId)) { enabledOverlay.SetActive(true); disabledOverlay.SetActive(false); } else { enabledOverlay.SetActive(false); disabledOverlay.SetActive(true); } RawImage component = ((Component)val.transform.Find("Icon")).GetComponent<RawImage>(); component.texture = (Texture)(object)cosmeticInstance.Value.icon; Button component2 = val.GetComponent<Button>(); ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { ToggleCosmetic(cosmeticInstance.Value.cosmeticId); if (IsEquipped(cosmeticInstance.Value.cosmeticId)) { enabledOverlay.SetActive(true); disabledOverlay.SetActive(false); } else { enabledOverlay.SetActive(false); disabledOverlay.SetActive(true); } MainClass.WriteCosmeticsToFile(); UpdateCosmeticsOnDisplayGuy(startEnabled: true); }); } } private static Color HexToColor(string hex) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); ColorUtility.TryParseHtmlString(hex, ref result); return result; } public static void UpdateCosmeticsOnDisplayGuy(bool startEnabled) { cosmeticApplication.ClearCosmetics(); foreach (string locallySelectedCosmetic in locallySelectedCosmetics) { cosmeticApplication.ApplyCosmetic(locallySelectedCosmetic, startEnabled); } foreach (CosmeticInstance spawnedCosmetic in cosmeticApplication.spawnedCosmetics) { RecursiveLayerChange(((Component)spawnedCosmetic).transform, 5); } } private static void RecursiveLayerChange(Transform transform, int layer) { ((Component)transform).gameObject.layer = layer; for (int i = 0; i < transform.childCount; i++) { RecursiveLayerChange(transform.GetChild(i), layer); } } public static bool IsEquipped(string cosmeticId) { return locallySelectedCosmetics.Contains(cosmeticId); } public static void ToggleCosmetic(string cosmeticId) { if (locallySelectedCosmetics.Contains(cosmeticId)) { locallySelectedCosmetics.Remove(cosmeticId); } else { locallySelectedCosmetics.Add(cosmeticId); } } } }