Decompiled source of Custom Sosig Loader v1.1.3
SosigClothing.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using FistVR; using HarmonyLib; using OtherLoader; using UnityEngine; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Packer.SosigClothing { [BepInPlugin("Packer.SosigClothing", "SosigClothing", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] public class SosigClothingPlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Packer.SosigClothing"); OtherLoader.RegisterDirectLoad(BasePath, "Packer.SosigClothing", "", "", "sosigclothing", ""); } } } namespace Packer { public class CameraDisplay : MonoBehaviour { [SerializeField] private Camera displayCamera; private RenderTexture renderTexture; private Camera targetCamera; [SerializeField] private Texture2D offlineTexture; public List<Camera> cameras = new List<Camera>(); public int index = 0; private Material renderMaterial; private FVRPhysicalObject physObject; [SerializeField] private Transform offset; [SerializeField] private MeshRenderer meshRenderer; private Quaternion offsetDefault; private bool quickbeltUpdate = false; public FVRPointableButton[] buttons; public Text cameraName; public GameObject crosshair; private bool preState = true; private void Start() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown renderTexture = new RenderTexture(1024, 1024, 16, (RenderTextureFormat)0); ((Object)renderTexture).name = "DisplayRender"; displayCamera.targetTexture = renderTexture; ((Renderer)meshRenderer).materials[1] = renderMaterial; } private void SetCameraAtIndex() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) targetCamera = cameras[index]; displayCamera.farClipPlane = targetCamera.farClipPlane; cameraName.text = ((Object)((Component)cameras[index]).transform).name + " " + index; SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } private void OnEnable() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) physObject = ((Component)this).GetComponent<FVRPhysicalObject>(); renderMaterial = ((Renderer)meshRenderer).materials[1]; offsetDefault = offset.localRotation; } private void Update() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)targetCamera) && ((Behaviour)displayCamera).enabled) { ((Component)displayCamera).transform.SetPositionAndRotation(((Component)targetCamera).transform.position, ((Component)targetCamera).transform.rotation); if (((Behaviour)targetCamera).enabled) { displayCamera.fov = targetCamera.fov; displayCamera.fieldOfView = targetCamera.fieldOfView; } } if ((Object)(object)physObject.QuickbeltSlot != (Object)null && !((FVRInteractiveObject)physObject).IsHeld) { offset.LookAt(GM.CurrentPlayerBody.Head, Vector3.up); if (quickbeltUpdate) { preState = ((Component)buttons[0]).gameObject.activeSelf; for (int i = 0; i < buttons.Length; i++) { ((Component)buttons[i]).gameObject.SetActive(false); } quickbeltUpdate = false; } } else if (!quickbeltUpdate) { offset.localRotation = offsetDefault; quickbeltUpdate = true; for (int j = 0; j < buttons.Length; j++) { ((Component)buttons[j]).gameObject.SetActive(preState); } if (offset.localScale.x < 0.2f) { ResetScale(); } } } public void AdjustScale(float amount) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //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) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (amount < 0f && offset.localScale.x > 0.2f) { Transform obj = offset; obj.localScale += new Vector3(amount, amount, amount); } else { if (!(amount > 0f) || !(offset.localScale.x < 2f)) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); return; } Transform obj2 = offset; obj2.localScale += new Vector3(amount, amount, amount); } SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } public void AdjustWidth(float amount) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (amount < 0f && offset.localScale.x > 0.3f) { Transform obj = offset; obj.localScale += new Vector3(amount, 0f, 0f); } else { if (!(amount > 0f) || !(offset.localScale.x < 1.9f)) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); return; } Transform obj2 = offset; obj2.localScale += new Vector3(amount, 0f, 0f); } SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } public void ToggleCrosshair() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) crosshair.SetActive(!crosshair.activeSelf); SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } public void ToggleUI() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < buttons.Length; i++) { ((Component)buttons[i]).gameObject.SetActive(!((Component)buttons[i]).gameObject.activeSelf); } SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } public void ResetScale() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) offset.localScale = Vector3.one; SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); } public void ToggleOnCamera() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)displayCamera).enabled) { ((Behaviour)displayCamera).enabled = false; ((Component)displayCamera).transform.position = Vector3.zero; ((Component)displayCamera).transform.rotation = Quaternion.identity; renderMaterial.SetTexture("_MainTex", (Texture)(object)offlineTexture); } else if (cameras.Count > 0 && index < cameras.Count && Object.op_Implicit((Object)(object)cameras[index])) { ((Behaviour)displayCamera).enabled = true; renderMaterial.SetTexture("_MainTex", (Texture)(object)renderTexture); SM.PlayGlobalUISound((GlobalUISound)0, ((Component)GM.CurrentPlayerBody).transform.position); return; } SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); } public void RemoveCurrentCamera() { //IL_0033: 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) if (cameras.Count == 0 || index >= cameras.Count) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); return; } cameras.RemoveAt(index); if (cameras.Count == 0) { cameraName.text = "Awaiting Cameras"; ((Behaviour)displayCamera).enabled = false; renderMaterial.SetTexture("_MainTex", (Texture)(object)offlineTexture); SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); } else { if (index > 0) { index--; } else { index = 0; } SetCameraAtIndex(); } } public void NextCamera() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (cameras.Count == 0) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); return; } if (index + 1 >= cameras.Count) { index = 0; } else { index++; } if ((Object)(object)cameras[index] == (Object)null) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); } else { SetCameraAtIndex(); } } public void PrevCamera() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (cameras.Count == 0) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); return; } if (index - 1 < 0) { index = cameras.Count - 1; } else { index--; } if ((Object)(object)cameras[index] == (Object)null) { SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); } else { SetCameraAtIndex(); } } public void RefreshCameras() { //IL_008c: 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_00bc: Unknown result type (might be due to invalid IL or missing references) Camera[] array = Object.FindObjectsOfType<Camera>(); cameras.Clear(); index = 0; for (int i = 0; i < array.Length; i++) { if (!((Object)array[i]).name.Contains(((Object)displayCamera).name)) { cameras.Add(array[i]); } } if (cameras.Count > 0) { SetCameraAtIndex(); return; } ((Component)displayCamera).transform.SetPositionAndRotation(((Component)this).transform.position, ((Component)this).transform.rotation); cameraName.text = "Awaiting Cameras"; SM.PlayGlobalUISound((GlobalUISound)1, ((Component)GM.CurrentPlayerBody).transform.position); } private void OnDestroy() { } } } public class CuttableMesh { private MeshRenderer inputMeshRenderer; private bool hasUvs; private bool hasUv1s; private bool hasColours; private List<CuttableSubMesh> subMeshes; public CuttableMesh(Mesh inputMesh) { Init(inputMesh, ((Object)inputMesh).name); } public CuttableMesh(MeshRenderer input) { inputMeshRenderer = input; MeshFilter component = ((Component)input).GetComponent<MeshFilter>(); Mesh sharedMesh = component.sharedMesh; Init(sharedMesh, ((Object)input).name); } public CuttableMesh(CuttableMesh inputMesh, List<CuttableSubMesh> newSubMeshes) { inputMeshRenderer = inputMesh.inputMeshRenderer; hasUvs = inputMesh.hasUvs; hasUv1s = inputMesh.hasUv1s; hasColours = inputMesh.hasColours; subMeshes = new List<CuttableSubMesh>(); subMeshes.AddRange(newSubMeshes); } private void Init(Mesh inputMesh, string debugName) { subMeshes = new List<CuttableSubMesh>(); if (inputMesh.isReadable) { Vector3[] vertices = inputMesh.vertices; Vector3[] normals = inputMesh.normals; Vector2[] uv = inputMesh.uv; Vector2[] uv2 = inputMesh.uv2; Color32[] colors = inputMesh.colors32; hasUvs = uv != null && uv.Length > 0; hasUv1s = uv2 != null && uv2.Length > 0; hasColours = colors != null && colors.Length > 0; for (int i = 0; i < inputMesh.subMeshCount; i++) { int[] indices = inputMesh.GetIndices(i); CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2); subMeshes.Add(item); } } else { Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh); } } public void Add(CuttableMesh other) { if (subMeshes.Count != other.subMeshes.Count) { throw new Exception("Mismatched submesh count"); } for (int i = 0; i < subMeshes.Count; i++) { subMeshes[i].Add(other.subMeshes[i]); } } public int NumSubMeshes() { return subMeshes.Count; } public bool HasUvs() { return hasUvs; } public bool HasColours() { return hasColours; } public List<CuttableSubMesh> GetSubMeshes() { return subMeshes; } public CuttableSubMesh GetSubMesh(int index) { return subMeshes[index]; } public Transform GetTransform() { if ((Object)(object)inputMeshRenderer != (Object)null) { return ((Component)inputMeshRenderer).transform; } return null; } public MeshRenderer ConvertToRenderer(string newObjectName) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) Mesh val = CreateMesh(); if (val.vertexCount == 0) { return null; } GameObject val2 = new GameObject(newObjectName); val2.transform.SetParent(((Component)inputMeshRenderer).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; MeshFilter val3 = val2.AddComponent<MeshFilter>(); val3.mesh = val; MeshRenderer val4 = val2.AddComponent<MeshRenderer>(); ((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode; ((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage; ((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage; ((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials; return val4; } public Mesh CreateMesh() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Mesh val = new Mesh(); int num = 0; for (int i = 0; i < subMeshes.Count; i++) { num += subMeshes[i].NumIndices(); } List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Color32> list3 = ((!hasColours) ? null : new List<Color32>()); List<Vector2> list4 = ((!hasUvs) ? null : new List<Vector2>()); List<Vector2> list5 = ((!hasUv1s) ? null : new List<Vector2>()); List<int> list6 = new List<int>(); foreach (CuttableSubMesh subMesh in subMeshes) { list6.Add(list.Count); subMesh.AddTo(list, list2, list3, list4, list5); } val.vertices = list.ToArray(); val.normals = list2.ToArray(); val.colors32 = ((!hasColours) ? null : list3.ToArray()); val.uv = ((!hasUvs) ? null : list4.ToArray()); val.uv2 = ((!hasUv1s) ? null : list5.ToArray()); val.subMeshCount = subMeshes.Count; for (int j = 0; j < subMeshes.Count; j++) { CuttableSubMesh cuttableSubMesh = subMeshes[j]; int num2 = list6[j]; int[] array = cuttableSubMesh.GenIndices(); for (int k = 0; k < array.Length; k++) { array[k] += num2; } val.SetTriangles(array, j, true); } return val; } } public class CuttableSubMesh { private List<Vector3> vertices; private List<Vector3> normals; private List<Color32> colours; private List<Vector2> uvs; private List<Vector2> uv1s; public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1) { vertices = new List<Vector3>(); if (hasNormals) { normals = new List<Vector3>(); } if (hasColours) { colours = new List<Color32>(); } if (hasUvs) { uvs = new List<Vector2>(); } if (hasUv1) { uv1s = new List<Vector2>(); } } public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) vertices = new List<Vector3>(); if (inputNormals != null && inputNormals.Length > 0) { normals = new List<Vector3>(); } if (inputColours != null && inputColours.Length > 0) { colours = new List<Color32>(); } if (inputUvs != null && inputUvs.Length > 0) { uvs = new List<Vector2>(); } if (inputUv1 != null && inputUv1.Length > 0) { uv1s = new List<Vector2>(); } foreach (int num in indices) { vertices.Add(inputVertices[num]); if (normals != null) { normals.Add(inputNormals[num]); } if (colours != null) { colours.Add(inputColours[num]); } if (uvs != null) { uvs.Add(inputUvs[num]); } if (uv1s != null) { uv1s.Add(inputUv1[num]); } } } public void Add(CuttableSubMesh other) { for (int i = 0; i < other.vertices.Count; i++) { CopyVertex(i, other); } } public int NumVertices() { return vertices.Count; } public Vector3 GetVertex(int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) return vertices[index]; } public bool HasNormals() { return normals != null; } public bool HasColours() { return colours != null; } public bool HasUvs() { return uvs != null; } public bool HasUv1() { return uv1s != null; } public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0096: Unknown result type (might be due to invalid IL or missing references) vertices.Add(srcMesh.vertices[srcIndex]); if (normals != null) { normals.Add(srcMesh.normals[srcIndex]); } if (colours != null) { colours.Add(srcMesh.colours[srcIndex]); } if (uvs != null) { uvs.Add(srcMesh.uvs[srcIndex]); } if (uv1s != null) { uv1s.Add(srcMesh.uv1s[srcIndex]); } } public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = srcMesh.GetVertex(i0); Vector3 vertex2 = srcMesh.GetVertex(i1); vertices.Add(Vector3.Lerp(vertex, vertex2, weight)); if (normals != null) { List<Vector3> list = normals; Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight); list.Add(((Vector3)(ref val)).normalized); } if (colours != null) { colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight)); } if (uvs != null) { uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight)); } if (uv1s != null) { uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight)); } } public void AddTo(List<Vector3> destVertices, List<Vector3> destNormals, List<Color32> destColours, List<Vector2> destUvs, List<Vector2> destUv1s) { destVertices.AddRange(vertices); if (normals != null) { destNormals.AddRange(normals); } if (colours != null) { destColours.AddRange(colours); } if (uvs != null) { destUvs.AddRange(uvs); } if (uv1s != null) { destUv1s.AddRange(uv1s); } } public int NumIndices() { return vertices.Count; } public int[] GenIndices() { int[] array = new int[vertices.Count]; for (int i = 0; i < array.Length; i++) { array[i] = i; } return array; } } public enum VertexClassification { Front = 1, Back = 2, OnPlane = 4 } public class MeshCutter { private CuttableMesh inputMesh; private List<CuttableSubMesh> outputFrontSubMeshes; private List<CuttableSubMesh> outputBackSubMeshes; public void Cut(CuttableMesh input, Plane worldCutPlane) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) inputMesh = input; outputFrontSubMeshes = new List<CuttableSubMesh>(); outputBackSubMeshes = new List<CuttableSubMesh>(); Transform transform = inputMesh.GetTransform(); Plane cutPlane = default(Plane); if ((Object)(object)transform != (Object)null) { Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero)); Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal); ((Plane)(ref cutPlane))..ctor(val2, val); } else { cutPlane = worldCutPlane; } foreach (CuttableSubMesh subMesh in input.GetSubMeshes()) { Cut(subMesh, cutPlane); } } private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) //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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point); if (((Plane)(ref plane)).GetSide(point)) { return point - ((Plane)(ref plane)).normal * distanceToPoint; } return point + ((Plane)(ref plane)).normal * distanceToPoint; } public CuttableMesh GetFrontOutput() { return new CuttableMesh(inputMesh, outputFrontSubMeshes); } public CuttableMesh GetBackOutput() { return new CuttableMesh(inputMesh, outputBackSubMeshes); } private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_0142: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //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_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) bool hasNormals = inputSubMesh.HasNormals(); bool hasColours = inputSubMesh.HasColours(); bool hasUvs = inputSubMesh.HasUvs(); bool hasUv = inputSubMesh.HasUv1(); CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv); for (int i = 0; i < inputSubMesh.NumVertices(); i += 3) { int num = i; int num2 = i + 1; int num3 = i + 2; Vector3 vertex = inputSubMesh.GetVertex(num); Vector3 vertex2 = inputSubMesh.GetVertex(num2); Vector3 vertex3 = inputSubMesh.GetVertex(num3); VertexClassification vertexClassification = Classify(vertex, cutPlane); VertexClassification vertexClassification2 = Classify(vertex2, cutPlane); VertexClassification vertexClassification3 = Classify(vertex3, cutPlane); int numFront = 0; int numBehind = 0; CountSides(vertexClassification, ref numFront, ref numBehind); CountSides(vertexClassification2, ref numFront, ref numBehind); CountSides(vertexClassification3, ref numFront, ref numBehind); if (numFront > 0 && numBehind == 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } else if (numFront == 0 && numBehind > 0) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else if (numFront == 2 && numBehind == 1) { if (vertexClassification == VertexClassification.Back) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else if (vertexClassification2 == VertexClassification.Back) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh); } } else if (numFront == 1 && numBehind == 2) { if (vertexClassification == VertexClassification.Front) { SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else if (vertexClassification2 == VertexClassification.Front) { SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } } else if (numFront == 1 && numBehind == 1) { if (vertexClassification == VertexClassification.OnPlane) { if (vertexClassification3 == VertexClassification.Front) { SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } continue; } switch (vertexClassification2) { case VertexClassification.OnPlane: if (vertexClassification == VertexClassification.Front) { SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } else { SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); } break; case VertexClassification.Front: SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; default: SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2); break; } } else if (numFront == 0 && numBehind == 0) { Vector3 val = vertex2 - vertex; Vector3 val2 = vertex3 - vertex; Vector3 val3 = Vector3.Cross(val, val2); if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f) { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2); } else { KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh); } } } outputFrontSubMeshes.Add(cuttableSubMesh); outputBackSubMeshes.Add(cuttableSubMesh2); } private VertexClassification Classify(Vector3 vertex, Plane cutPlane) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z); float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val); double num = 9.999999747378752E-06; if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num) { return VertexClassification.OnPlane; } if (distanceToPoint > 0f) { return VertexClassification.Front; } return VertexClassification.Back; } private void CountSides(VertexClassification c, ref int numFront, ref int numBehind) { switch (c) { case VertexClassification.Front: numFront++; break; case VertexClassification.Back: numBehind++; break; } } private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh) { destSubMesh.CopyVertex(i0, inputSubMesh); destSubMesh.CopyVertex(i1, inputSubMesh); destSubMesh.CopyVertex(i2, inputSubMesh); } private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); Vector3 vertex3 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex, vertex2, cutPlane, out var weight); CalcIntersection(vertex3, vertex, cutPlane, out var weight2); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i2); CalcIntersection(vertex2, vertex, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.CopyVertex(i1, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh); } private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vertex = inputSubMesh.GetVertex(i0); Vector3 vertex2 = inputSubMesh.GetVertex(i1); CalcIntersection(vertex, vertex2, cutPlane, out var weight); frontSubMesh.CopyVertex(i0, inputSubMesh); frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); frontSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.CopyVertex(i1, inputSubMesh); backSubMesh.CopyVertex(i2, inputSubMesh); backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh); } private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0014: 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) //IL_0022: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) Vector3 val = v1 - v0; float magnitude = ((Vector3)(ref val)).magnitude; Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(v0, val / magnitude); float num = default(float); ((Plane)(ref plane)).Raycast(val2, ref num); Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num; weight = num / magnitude; return result; } }
Sosig_Squad.CustomSosigLoader.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using 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.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using CustomSosigLoader; using FistVR; using H3MP; using H3MP.Networking; using H3MP.Scripts; using H3MP.Tracking; using HarmonyLib; using Microsoft.CodeAnalysis; using OtherLoader; using Sodalite.Api; using TNHFramework; using UnityEngine; using UnityEngine.AI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyCompany("Packer")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A Custom Sosig Loader for H3VR")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+0812410b6a18985930c3ac38f71eccdd8f8efffd")] [assembly: AssemblyProduct("Sosig_Squad.CustomSosigLoader")] [assembly: AssemblyTitle("Custom Sosig Loader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class WavUtility { private const int BlockSize_16Bit = 2; public static AudioClip ToAudioClip(string filePath) { byte[] fileBytes = File.ReadAllBytes(filePath); return ToAudioClip(fileBytes); } public static AudioClip ToAudioClip(byte[] fileBytes, int offsetSamples = 0, string name = "wav") { int num = BitConverter.ToInt32(fileBytes, 16); ushort code = BitConverter.ToUInt16(fileBytes, 20); string text = FormatCode(code); ushort num2 = BitConverter.ToUInt16(fileBytes, 22); int num3 = BitConverter.ToInt32(fileBytes, 24); ushort num4 = BitConverter.ToUInt16(fileBytes, 34); int num5 = 20 + num + 4; int dataSize = BitConverter.ToInt32(fileBytes, num5); float[] array = num4 switch { 8 => Convert8BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 16 => Convert16BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 24 => Convert24BitByteArrayToAudioClipData(fileBytes, num5, dataSize), 32 => Convert32BitByteArrayToAudioClipData(fileBytes, num5, dataSize), _ => throw new Exception(num4 + " bit depth is not supported."), }; AudioClip val = AudioClip.Create(name, array.Length, (int)num2, num3, false); val.SetData(array, 0); return val; } private static float[] Convert8BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; float[] array = new float[num]; sbyte b = sbyte.MaxValue; for (int i = 0; i < num; i++) { array[i] = (float)(int)source[i] / (float)b; } return array; } private static float[] Convert16BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 2; int num3 = num / num2; float[] array = new float[num3]; short num4 = short.MaxValue; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; array[i] = (float)BitConverter.ToInt16(source, num5) / (float)num4; } return array; } private static float[] Convert24BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 3; int num3 = num / num2; int num4 = int.MaxValue; float[] array = new float[num3]; byte[] array2 = new byte[4]; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; Buffer.BlockCopy(source, num5, array2, 1, num2); array[i] = (float)BitConverter.ToInt32(array2, 0) / (float)num4; } return array; } private static float[] Convert32BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) { int num = BitConverter.ToInt32(source, headerOffset); headerOffset += 4; int num2 = 4; int num3 = num / num2; int num4 = int.MaxValue; float[] array = new float[num3]; int num5 = 0; for (int i = 0; i < num3; i++) { num5 = i * num2 + headerOffset; array[i] = (float)BitConverter.ToInt32(source, num5) / (float)num4; } return array; } public static byte[] FromAudioClip(AudioClip audioClip) { string filepath; return FromAudioClip(audioClip, out filepath, saveAsFile: false); } public static byte[] FromAudioClip(AudioClip audioClip, out string filepath, bool saveAsFile = true, string dirname = "recordings") { MemoryStream stream = new MemoryStream(); ushort bitDepth = 16; int fileSize = audioClip.samples * 2 + 44; WriteFileHeader(ref stream, fileSize); WriteFileFormat(ref stream, audioClip.channels, audioClip.frequency, bitDepth); WriteFileData(ref stream, audioClip, bitDepth); byte[] array = stream.ToArray(); if (saveAsFile) { filepath = string.Format("{0}/{1}/{2}.{3}", Application.persistentDataPath, dirname, DateTime.UtcNow.ToString("yyMMdd-HHmmss-fff"), "wav"); Directory.CreateDirectory(Path.GetDirectoryName(filepath)); File.WriteAllBytes(filepath, array); } else { filepath = null; } stream.Dispose(); return array; } private static int WriteFileHeader(ref MemoryStream stream, int fileSize) { int num = 0; int num2 = 12; byte[] bytes = Encoding.ASCII.GetBytes("RIFF"); num += WriteBytesToMemoryStream(ref stream, bytes, "ID"); int value = fileSize - 8; num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "CHUNK_SIZE"); byte[] bytes2 = Encoding.ASCII.GetBytes("WAVE"); return num + WriteBytesToMemoryStream(ref stream, bytes2, "FORMAT"); } private static int WriteFileFormat(ref MemoryStream stream, int channels, int sampleRate, ushort bitDepth) { int num = 0; int num2 = 24; byte[] bytes = Encoding.ASCII.GetBytes("fmt "); num += WriteBytesToMemoryStream(ref stream, bytes, "FMT_ID"); int value = 16; num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "SUBCHUNK_SIZE"); ushort value2 = 1; num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value2), "AUDIO_FORMAT"); ushort value3 = Convert.ToUInt16(channels); num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value3), "CHANNELS"); num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(sampleRate), "SAMPLE_RATE"); int value4 = sampleRate * channels * BytesPerSample(bitDepth); num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value4), "BYTE_RATE"); ushort value5 = Convert.ToUInt16(channels * BytesPerSample(bitDepth)); num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value5), "BLOCK_ALIGN"); return num + WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(bitDepth), "BITS_PER_SAMPLE"); } private static int WriteFileData(ref MemoryStream stream, AudioClip audioClip, ushort bitDepth) { int num = 0; int num2 = 8; float[] array = new float[audioClip.samples * audioClip.channels]; audioClip.GetData(array, 0); byte[] bytes = ConvertAudioClipDataToInt16ByteArray(array); byte[] bytes2 = Encoding.ASCII.GetBytes("data"); num += WriteBytesToMemoryStream(ref stream, bytes2, "DATA_ID"); int value = Convert.ToInt32(audioClip.samples * 2); num += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(value), "SAMPLES"); return num + WriteBytesToMemoryStream(ref stream, bytes, "DATA"); } private static byte[] ConvertAudioClipDataToInt16ByteArray(float[] data) { MemoryStream memoryStream = new MemoryStream(); int count = 2; short num = short.MaxValue; for (int i = 0; i < data.Length; i++) { memoryStream.Write(BitConverter.GetBytes(Convert.ToInt16(data[i] * (float)num)), 0, count); } byte[] result = memoryStream.ToArray(); memoryStream.Dispose(); return result; } private static int WriteBytesToMemoryStream(ref MemoryStream stream, byte[] bytes, string tag = "") { int num = bytes.Length; stream.Write(bytes, 0, num); return num; } public static ushort BitDepth(AudioClip audioClip) { return Convert.ToUInt16((float)(audioClip.samples * audioClip.channels) * audioClip.length / (float)audioClip.frequency); } private static int BytesPerSample(ushort bitDepth) { return bitDepth / 8; } private static int BlockSize(ushort bitDepth) { return bitDepth switch { 32 => 4, 16 => 2, 8 => 1, _ => throw new Exception(bitDepth + " bit depth is not supported."), }; } private static string FormatCode(ushort code) { switch (code) { case 1: return "PCM"; case 2: return "ADPCM"; case 3: return "IEEE"; case 7: return "μ-law"; case 65534: return "WaveFormatExtensable"; default: Debug.LogWarning((object)("Unknown wav code format:" + code)); return ""; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string id = null, string name = null, string version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null) { } } } namespace H3MP.Networking { public class Networking { public static bool ServerRunning() { if (CustomSosigLoaderPlugin.h3mpEnabled) { return isServerRunning(); } return false; } private static bool isServerRunning() { if ((Object)(object)Mod.managerObject == (Object)null) { return false; } return true; } public static bool IsClient() { if (CustomSosigLoaderPlugin.h3mpEnabled) { return isClient(); } return false; } private static bool isClient() { if ((Object)(object)Mod.managerObject == (Object)null) { return false; } if (!ThreadManager.host) { return true; } return false; } public static bool IsHost() { if (CustomSosigLoaderPlugin.h3mpEnabled) { return isHosting(); } return false; } private static bool isHosting() { if ((Object)(object)Mod.managerObject == (Object)null) { return false; } if (ThreadManager.host) { return true; } return false; } public static int GetPlayerCount() { if (CustomSosigLoaderPlugin.h3mpEnabled) { return GetNetworkPlayerCount(); } return 1; } private static int GetNetworkPlayerCount() { return GameManager.players.Count; } public static int[] GetPlayerIDs() { int[] array = new int[GameManager.players.Count]; int num = 0; foreach (KeyValuePair<int, PlayerManager> player in GameManager.players) { array[num] = player.Key; num++; } return array; } public static int GetLocalID() { return GameManager.ID; } public static int RegisterHostCustomPacket(string identifier) { if (Mod.registeredCustomPacketIDs.ContainsKey(identifier)) { return Mod.registeredCustomPacketIDs[identifier]; } return Server.RegisterCustomPacketType(identifier, 0); } public static PlayerData GetPlayer(int i) { return PlayerData.GetPlayer(i); } } public class PlayerData { public Transform head; public string username; public Transform handLeft; public Transform handRight; public int ID; public float health; public int iff; public static PlayerData GetPlayer(int i) { return new PlayerData { head = GameManager.players[i].head, username = GameManager.players[i].username, handLeft = GameManager.players[i].leftHand, handRight = GameManager.players[i].rightHand }; } } } namespace CustomSosigLoader { internal class Custom_SosigData { public static MeshRenderer GetSosigMeshRenderer(string title, Transform geoParent) { for (int i = 0; i < geoParent.childCount; i++) { if (((Object)geoParent.GetChild(i)).name == title) { return ((Component)geoParent.GetChild(i)).GetComponent<MeshRenderer>(); } } return null; } public static void UpdateSosigLink(SosigLink link, Vector3 bodyScale, Vector3 linkScale, Material sosigMaterial, bool stopSever, MeshRenderer geo) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0024: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_0144: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)link == (Object)null) { return; } CapsuleCollider val = (CapsuleCollider)link.C; val.height *= linkScale.y; val.radius *= ((linkScale.x > linkScale.z) ? linkScale.x : linkScale.z); CharacterJoint val2 = (((Object)(object)link.J != (Object)null) ? link.J : ((Component)link).GetComponent<CharacterJoint>()); if (Object.op_Implicit((Object)(object)val2)) { ((Joint)val2).autoConfigureConnectedAnchor = false; ((Joint)val2).anchor = new Vector3(0f, ((Joint)val2).anchor.y * bodyScale.y, 0f); ((Joint)val2).connectedAnchor = new Vector3(0f, ((Joint)val2).connectedAnchor.y * bodyScale.y, 0f); } ((Renderer)geo).sharedMaterial = sosigMaterial; ((Component)geo).transform.localScale = linkScale; if (stopSever) { link.m_isJointSevered = true; } if (link.m_wearables.Count <= 0) { return; } foreach (SosigWearable wearable in link.m_wearables) { ((Component)wearable).gameObject.transform.localScale = ((Component)geo).transform.localScale; } } } [Serializable] public class Custom_OutfitConfig { public string name; public string[] Headwear; public float Chance_Headwear = 0f; public bool HeadUsesTorsoIndex = false; public bool ForceWearAllHead = false; public string[] Eyewear; public float Chance_Eyewear = 0f; public bool ForceWearAllEye = false; public string[] Torsowear; public float Chance_Torsowear = 0f; public bool ForceWearAllTorso = false; public string[] Pantswear; public float Chance_Pantswear = 0f; public bool PantsUsesTorsoIndex = false; public bool ForceWearAllPants = false; public string[] Pantswear_Lower; public float Chance_Pantswear_Lower = 0f; public bool PantsLowerUsesPantsIndex = false; public bool ForceWearAllPantsLower = false; public string[] Backpacks; public float Chance_Backpacks = 0f; public bool ForceWearAllBackpacks = false; public string[] TorsoDecoration; public float Chance_TorsoDecoration = 0f; public bool ForceWearAllTorsoDecoration = false; public string[] Belt; public float Chance_Belt = 0f; public bool ForceWearAllBelt = false; public string[] Facewear; public float Chance_Facewear = 0f; public bool ForceWearAllFace = false; public SosigOutfitConfig Initialize() { SosigOutfitConfig val = ScriptableObject.CreateInstance<SosigOutfitConfig>(); val.HeadUsesTorsoIndex = HeadUsesTorsoIndex; val.PantsUsesTorsoIndex = PantsUsesTorsoIndex; val.PantsLowerUsesPantsIndex = PantsLowerUsesPantsIndex; val.Headwear = new List<FVRObject>(); Global.ItemIDToList(Headwear, val.Headwear); val.Eyewear = new List<FVRObject>(); Global.ItemIDToList(Eyewear, val.Eyewear); val.Torsowear = new List<FVRObject>(); Global.ItemIDToList(Torsowear, val.Torsowear); val.Pantswear = new List<FVRObject>(); Global.ItemIDToList(Pantswear, val.Pantswear); val.Pantswear_Lower = new List<FVRObject>(); Global.ItemIDToList(Pantswear_Lower, val.Pantswear_Lower); val.Backpacks = new List<FVRObject>(); Global.ItemIDToList(Backpacks, val.Backpacks); val.TorosDecoration = new List<FVRObject>(); Global.ItemIDToList(TorsoDecoration, val.TorosDecoration); val.Belt = new List<FVRObject>(); Global.ItemIDToList(Belt, val.Belt); val.Facewear = new List<FVRObject>(); Global.ItemIDToList(Facewear, val.Facewear); val.Chance_Headwear = Chance_Headwear; val.Chance_Eyewear = Chance_Eyewear; val.Chance_Torsowear = Chance_Torsowear; val.Chance_Pantswear = Chance_Pantswear; val.Chance_Pantswear_Lower = Chance_Pantswear_Lower; val.Chance_Backpacks = Chance_Backpacks; val.Chance_TorosDecoration = Chance_TorsoDecoration; val.Chance_Belt = Chance_Belt; val.Chance_Facewear = Chance_Facewear; return val; } } [Serializable] public class Custom_Sosig { public string name; public SosigEnemyID baseSosigID = (SosigEnemyID)0; public string voiceSet = ""; public float voicePitch = 1.15f; public float voiceVolume = 0.4f; public Vector3 scaleBody = Vector3.one; public Vector3 scaleHead = Vector3.one; public Vector3 scaleTorso = Vector3.one; public Vector3 scaleLegsUpper = Vector3.one; public Vector3 scaleLegsLower = Vector3.one; public bool hideHeadMesh = false; public bool hideTorsoMesh = false; public bool hideLegsUpperMesh = false; public bool hideLegsLowerMesh = false; public string customSkin = ""; public Color color; public float metallic = 0f; public float specularity = 0.3f; public float specularTint = 0f; public float roughness = 1f; public float normalStrength = 1f; public bool specularHighlights = true; public bool glossyReflections = true; public string directory; public Texture2D albedo; public Texture2D normalmap; public Texture2D masr; } [Serializable] public class Custom_SosigConfigTemplate { public string name; [Header("AIEntityParams")] public float ViewDistance = 250f; public Vector3 StateSightRangeMults = new Vector3(0.1f, 0.35f, 1f); public float HearingDistance = 300f; public Vector3 StateHearingRangeMults = new Vector3(0.6f, 1f, 1f); public float MaxFOV = 105f; public Vector3 StateFOVMults = new Vector3(0.5f, 0.6f, 1f); [Header("Core Identity Params")] public bool HasABrain = true; public bool RegistersPassiveThreats = false; public bool DoesAggroOnFriendlyFire = false; public float SearchExtentsModifier = 1f; public bool DoesDropWeaponsOnBallistic = true; public bool CanPickup_Ranged = true; public bool CanPickup_Melee = true; public bool CanPickup_Other = true; [Header("TargetPrioritySystemParams")] public int TargetCapacity = 5; public float TargetTrackingTime = 2f; public float NoFreshTargetTime = 1.5f; public float AssaultPointOverridesSkirmishPointWhenFurtherThan = 200f; public float TimeInSkirmishToAlert = 1f; [Header("Movement Params")] public float RunSpeed = 3.5f; public float WalkSpeed = 1.4f; public float SneakSpeed = 0.6f; public float CrawlSpeed = 0.3f; public float TurnSpeed = 2f; public float MaxJointLimit = 6f; public float MovementRotMagnitude = 10f; [Header("Damage Params")] public bool AppliesDamageResistToIntegrityLoss = false; public float TotalMustard = 100f; public float BleedDamageMult = 0.5f; public float BleedRateMultiplier = 1f; public float BleedVFXIntensity = 0.2f; public float DamMult_Projectile = 1f; public float DamMult_Explosive = 1f; public float DamMult_Melee = 1f; public float DamMult_Piercing = 1f; public float DamMult_Blunt = 1f; public float DamMult_Cutting = 1f; public float DamMult_Thermal = 1f; public float DamMult_Chilling = 1f; public float DamMult_EMP = 1f; public List<float> LinkDamageMultipliers; public List<float> LinkStaggerMultipliers; public List<Vector2> StartingLinkIntegrity; public List<float> StartingChanceBrokenJoint; [Header("Shudder Params")] public float ShudderThreshold = 2f; [Header("Confusion Params")] public float ConfusionThreshold = 0.3f; public float ConfusionMultiplier = 6f; public float ConfusionTimeMax = 4f; [Header("Stun Params")] public float StunThreshold = 1.4f; public float StunMultiplier = 2f; public float StunTimeMax = 4f; [Header("Unconsciousness Params")] public bool CanBeKnockedOut = true; public float MaxUnconsciousTime = 90f; [Header("Resistances")] public bool CanBeGrabbed = true; public bool CanBeSevered = true; public bool CanBeStabbed = true; [Header("Suppression")] public bool CanBeSurpressed = true; public float SuppressionMult = 1f; [Header("Death Flags")] public bool DoesJointBreakKill_Head = true; public bool DoesJointBreakKill_Upper = false; public bool DoesJointBreakKill_Lower = false; public bool DoesSeverKill_Head = true; public bool DoesSeverKill_Upper = true; public bool DoesSeverKill_Lower = true; public bool DoesExplodeKill_Head = true; public bool DoesExplodeKill_Upper = true; public bool DoesExplodeKill_Lower = true; [Header("SpawnOnLinkDestroy")] public bool UsesLinkSpawns = false; public List<string> LinkSpawns; public List<float> LinkSpawnChance; public SosigConfigTemplate Initialize() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) SosigConfigTemplate val = ScriptableObject.CreateInstance<SosigConfigTemplate>(); val.ViewDistance = ViewDistance; val.StateSightRangeMults = StateSightRangeMults; val.HearingDistance = HearingDistance; val.StateHearingRangeMults = StateHearingRangeMults; val.MaxFOV = MaxFOV; val.StateFOVMults = StateFOVMults; val.HasABrain = HasABrain; val.RegistersPassiveThreats = RegistersPassiveThreats; val.DoesAggroOnFriendlyFire = DoesAggroOnFriendlyFire; val.SearchExtentsModifier = SearchExtentsModifier; val.DoesDropWeaponsOnBallistic = DoesDropWeaponsOnBallistic; val.CanPickup_Ranged = CanPickup_Ranged; val.CanPickup_Melee = CanPickup_Melee; val.CanPickup_Other = CanPickup_Other; val.TargetCapacity = TargetCapacity; val.TargetTrackingTime = TargetTrackingTime; val.NoFreshTargetTime = NoFreshTargetTime; val.AssaultPointOverridesSkirmishPointWhenFurtherThan = AssaultPointOverridesSkirmishPointWhenFurtherThan; val.RunSpeed = RunSpeed; val.WalkSpeed = WalkSpeed; val.SneakSpeed = SneakSpeed; val.CrawlSpeed = CrawlSpeed; val.TurnSpeed = TurnSpeed; val.MaxJointLimit = MaxJointLimit; val.MovementRotMagnitude = MovementRotMagnitude; val.AppliesDamageResistToIntegrityLoss = AppliesDamageResistToIntegrityLoss; val.TotalMustard = TotalMustard; val.BleedDamageMult = BleedDamageMult; val.BleedRateMultiplier = BleedRateMultiplier; val.BleedVFXIntensity = BleedVFXIntensity; val.DamMult_Projectile = DamMult_Projectile; val.DamMult_Explosive = DamMult_Explosive; val.DamMult_Melee = DamMult_Melee; val.DamMult_Piercing = DamMult_Piercing; val.DamMult_Blunt = DamMult_Blunt; val.DamMult_Cutting = DamMult_Cutting; val.DamMult_Thermal = DamMult_Thermal; val.DamMult_Chilling = DamMult_Chilling; val.DamMult_EMP = DamMult_EMP; val.LinkDamageMultipliers = LinkDamageMultipliers; val.LinkStaggerMultipliers = LinkStaggerMultipliers; val.StartingLinkIntegrity = StartingLinkIntegrity; val.StartingChanceBrokenJoint = StartingChanceBrokenJoint; val.ShudderThreshold = ShudderThreshold; val.ConfusionThreshold = ConfusionThreshold; val.ConfusionMultiplier = ConfusionMultiplier; val.ConfusionTimeMax = ConfusionTimeMax; val.StunThreshold = StunThreshold; val.StunMultiplier = StunMultiplier; val.StunTimeMax = StunTimeMax; val.CanBeKnockedOut = CanBeKnockedOut; val.MaxUnconsciousTime = MaxUnconsciousTime; val.CanBeGrabbed = CanBeGrabbed; val.CanBeSevered = CanBeSevered; val.CanBeStabbed = CanBeStabbed; val.CanBeSurpressed = CanBeSurpressed; val.SuppressionMult = SuppressionMult; val.DoesJointBreakKill_Head = DoesJointBreakKill_Head; val.DoesJointBreakKill_Upper = DoesJointBreakKill_Upper; val.DoesJointBreakKill_Lower = DoesJointBreakKill_Lower; val.DoesSeverKill_Head = DoesSeverKill_Head; val.DoesSeverKill_Upper = DoesSeverKill_Upper; val.DoesSeverKill_Lower = DoesSeverKill_Lower; val.DoesExplodeKill_Head = DoesExplodeKill_Head; val.DoesExplodeKill_Upper = DoesExplodeKill_Upper; val.DoesExplodeKill_Lower = DoesExplodeKill_Lower; val.UsesLinkSpawns = UsesLinkSpawns; if (val.LinkSpawns == null) { val.LinkSpawns = new List<FVRObject>(); } Global.ItemIDToList(LinkSpawns.ToArray(), val.LinkSpawns); val.LinkSpawnChance = LinkSpawnChance; return val; } } [Serializable] public class Custom_SosigEnemyTemplate { public string DisplayName = "New Sosig"; public int SosigEnemyCategory = 0; public int SosigEnemyID = -1; public Custom_Sosig[] CustomSosigs; public Custom_OutfitConfig[] OutfitConfigs; public Custom_SosigConfigTemplate[] Configs; public Custom_SosigConfigTemplate[] ConfigsEasy; public string[] WeaponOptions; public string[] WeaponOptionsSecondary; public string[] WeaponOptionsTertiary; public float SecondaryChance = 0f; public float TertiaryChance = 0f; public SosigEnemyTemplate Initialize() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) SosigEnemyTemplate val = ScriptableObject.CreateInstance<SosigEnemyTemplate>(); val.OutfitConfig = new List<SosigOutfitConfig>(); for (int i = 0; i < OutfitConfigs.Length; i++) { val.OutfitConfig.Add(OutfitConfigs[i].Initialize()); } val.ConfigTemplates = new List<SosigConfigTemplate>(); for (int j = 0; j < Configs.Length; j++) { val.ConfigTemplates.Add(Configs[j].Initialize()); } val.ConfigTemplates_Easy = new List<SosigConfigTemplate>(); if (ConfigsEasy.Length != 0) { for (int k = 0; k < ConfigsEasy.Length; k++) { val.ConfigTemplates.Add(ConfigsEasy[k].Initialize()); } } else { val.ConfigTemplates_Easy.AddRange(val.ConfigTemplates); } val.SosigPrefabs = new List<FVRObject>(); for (int l = 0; l < CustomSosigs.Length; l++) { SosigEnemyTemplate val2 = ManagerSingleton<IM>.Instance.odicSosigObjsByID[CustomSosigs[l].baseSosigID]; FVRObject item = val2.SosigPrefabs[Random.Range(0, val2.SosigPrefabs.Count)]; val.SosigPrefabs.Add(item); } val.WeaponOptions = new List<FVRObject>(); Global.ItemIDToList(WeaponOptions, val.WeaponOptions); val.WeaponOptions_Secondary = new List<FVRObject>(); Global.ItemIDToList(WeaponOptionsSecondary, val.WeaponOptions_Secondary); val.WeaponOptions_Tertiary = new List<FVRObject>(); Global.ItemIDToList(WeaponOptionsTertiary, val.WeaponOptions_Tertiary); val.SecondaryChance = SecondaryChance; val.TertiaryChance = TertiaryChance; return val; } public void ExportJson() { using StreamWriter streamWriter = new StreamWriter(Paths.PluginPath + "\\Sosig_Squad-SupplyRaid\\" + DisplayName + ".json"); string value = JsonUtility.ToJson((object)this, true); streamWriter.Write(value); } } internal class Global { public static Texture2D whiteSosig; public static List<string> GetCustomSosigDirectories() { return Directory.GetFiles(Paths.PluginPath, "*.csosig", SearchOption.AllDirectories).ToList(); } public static void LoadCustomSosigs() { List<string> customSosigDirectories = GetCustomSosigDirectories(); if (customSosigDirectories.Count == 0) { CustomSosigLoaderPlugin.Logger.LogInfo((object)"No Custom Sosigs were found!"); return; } for (int i = 0; i < customSosigDirectories.Count; i++) { using StreamReader streamReader = new StreamReader(customSosigDirectories[i]); string text = streamReader.ReadToEnd(); Custom_SosigEnemyTemplate custom_SosigEnemyTemplate; try { custom_SosigEnemyTemplate = JsonUtility.FromJson<Custom_SosigEnemyTemplate>(text); } catch (Exception ex) { CustomSosigLoaderPlugin.Logger.LogInfo((object)ex.Message); break; } for (int j = 0; j < custom_SosigEnemyTemplate.CustomSosigs.Length; j++) { custom_SosigEnemyTemplate.CustomSosigs[j].directory = customSosigDirectories[i]; } CustomSosigLoaderPlugin.customSosigs.Add(custom_SosigEnemyTemplate.SosigEnemyID, custom_SosigEnemyTemplate); CustomSosigLoaderPlugin.Logger.LogInfo((object)("Custom Sosig Loader - Loaded " + custom_SosigEnemyTemplate.SosigEnemyID + " - " + custom_SosigEnemyTemplate.DisplayName)); } } public static void LoadSosigMaterial(Custom_Sosig customSosig) { if (!(customSosig.customSkin == "CustomSosig_Base")) { string text = Path.GetDirectoryName(customSosig.directory) + "\\" + customSosig.customSkin; customSosig.albedo = LoadTexture(text + ".png"); customSosig.normalmap = LoadTexture(text + "_Normal.png"); customSosig.masr = LoadTexture(text + "_MARS.png"); } } public static void ItemIDToList(string[] itemIDs, List<FVRObject> input) { if (itemIDs == null) { CustomSosigLoaderPlugin.Logger.LogInfo((object)"Item IDs missing"); return; } if (input == null) { CustomSosigLoaderPlugin.Logger.LogInfo((object)"Item IDs Input missing"); return; } for (int i = 0; i < itemIDs.Length; i++) { if (IM.OD.ContainsKey(itemIDs[i]) && IM.OD.TryGetValue(itemIDs[i], out var value)) { input.Add(value); } else { CustomSosigLoaderPlugin.Logger.LogInfo((object)("Custom Sosig Loader - Could not find |" + itemIDs[i] + "|")); } } } public static Texture2D LoadTexture(string path) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown Texture2D val = null; if (File.Exists(path) && (Object)(object)val == (Object)null) { byte[] array = File.ReadAllBytes(path); val = new Texture2D(2, 2); val.LoadImage(array); } if ((Object)(object)val == (Object)null) { CustomSosigLoaderPlugin.Logger.LogWarning((object)("Custom Sosig Loader - Texture Not Found: " + path)); return null; } return val; } public static void LoadWhiteSosigTexture(string textureName) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown string text = Paths.PluginPath + "\\Sosig_Squad-Custom_Sosig_Loader\\" + textureName; Texture2D val = null; if (File.Exists(text) && (Object)(object)val == (Object)null) { byte[] array = File.ReadAllBytes(text); val = new Texture2D(2, 2); val.LoadImage(array); } if ((Object)(object)val == (Object)null) { CustomSosigLoaderPlugin.Logger.LogError((object)("Custom Sosig Loader - Texture Not Found: " + text)); whiteSosig = null; } ((Object)val).name = textureName; whiteSosig = val; } public static void LoadCustomVoiceLines() { CustomSosigLoaderPlugin.Logger.LogInfo((object)"Loading Custom Voice Lines"); try { string[] directories = Directory.GetDirectories(Paths.PluginPath, "*", SearchOption.AllDirectories); List<string> list = new List<string>(); string[] array = directories; foreach (string text in array) { string text2 = Path.Combine(text, "voicelines"); if (!Directory.Exists(text2)) { continue; } string[] files = Directory.GetFiles(text, "*.yaml", SearchOption.TopDirectoryOnly); if (files.Length == 0) { continue; } string[] array2 = files; foreach (string yamlFilePath in array2) { VoiceSet voicelines = GetVoicelines(yamlFilePath); string name = voicelines.name; float pitch = voicelines.pitch; float volume = voicelines.volume; if (!string.IsNullOrEmpty(name) && !list.Contains(name)) { SosigSpeechSet val = ScriptableObject.CreateInstance<SosigSpeechSet>(); ((Object)val).name = name; val.BasePitch = pitch; val.BaseVolume = volume; val.OnAssault = new List<AudioClip>(); val.OnBackBreak = new List<AudioClip>(); val.OnBeingAimedAt = new List<AudioClip>(); val.OnCall_Assistance = new List<AudioClip>(); val.OnCall_Skirmish = new List<AudioClip>(); val.OnConfusion = new List<AudioClip>(); val.OnDeath = new List<AudioClip>(); val.OnDeathAlt = new List<AudioClip>(); val.OnInvestigate = new List<AudioClip>(); val.OnJointBreak = new List<AudioClip>(); val.OnJointSever = new List<AudioClip>(); val.OnJointSlice = new List<AudioClip>(); val.OnMedic = new List<AudioClip>(); val.OnNeckBreak = new List<AudioClip>(); val.OnPain = new List<AudioClip>(); val.OnReloading = new List<AudioClip>(); val.OnRespond_Assistance = new List<AudioClip>(); val.OnRespond_Skirmish = new List<AudioClip>(); val.OnSearchingForGuns = new List<AudioClip>(); val.OnSkirmish = new List<AudioClip>(); val.OnTakingCover = new List<AudioClip>(); val.OnWander = new List<AudioClip>(); val.Test = new List<AudioClip>(); list.Add(name); AddAllAudioFromDirectory(Path.Combine(text2, "state_wander"), val.OnWander); AddAllAudioFromDirectory(Path.Combine(text2, "state_skirmish"), val.OnSkirmish); AddAllAudioFromDirectory(Path.Combine(text2, "state_reload"), val.OnReloading); AddAllAudioFromDirectory(Path.Combine(text2, "state_investigate"), val.OnInvestigate); AddAllAudioFromDirectory(Path.Combine(text2, "pain_joint_slice"), val.OnJointSlice); AddAllAudioFromDirectory(Path.Combine(text2, "pain_joint_sever"), val.OnJointSever); AddAllAudioFromDirectory(Path.Combine(text2, "pain_joint_break"), val.OnJointBreak); AddAllAudioFromDirectory(Path.Combine(text2, "pain_default"), val.OnPain); AddAllAudioFromDirectory(Path.Combine(text2, "pain_break_neck"), val.OnNeckBreak); AddAllAudioFromDirectory(Path.Combine(text2, "pain_break_back"), val.OnBackBreak); CustomSosigLoaderPlugin.customVoicelines.Add(name, val); CustomSosigLoaderPlugin.Logger.LogInfo((object)("Custom Sosig Loader: Loaded voicelines - " + name)); break; } } } } catch (Exception ex) { Console.WriteLine("An error occurred: " + ex.Message); } } public static void AddAllAudioFromDirectory(string path, List<AudioClip> list) { string[] files = Directory.GetFiles(path, "*.wav", SearchOption.TopDirectoryOnly); string[] array = files; foreach (string filePath in array) { AudioClip val = LoadWav(filePath); if ((Object)(object)val != (Object)null) { list.Add(val); } } } public static AudioClip LoadWav(string filePath) { try { return WavUtility.ToAudioClip(filePath); } catch (Exception ex) { CustomSosigLoaderPlugin.Logger.LogError((object)("An error occurred while loading the .wav file: " + ex.Message)); return null; } } private static VoiceSet GetVoicelines(string yamlFilePath) { try { VoiceSet voiceSet = new VoiceSet(); string[] array = File.ReadAllLines(yamlFilePath); string[] array2 = array; foreach (string text in array2) { if (text.Trim().StartsWith("name:")) { voiceSet.name = text.Substring(text.IndexOf("name: ") + "name:".Length).Trim(); } if (text.Trim().StartsWith("base_pitch:")) { voiceSet.pitch = float.Parse(text.Substring(text.IndexOf("base_pitch: ") + "base_pitch:".Length).Trim()); } if (text.Trim().StartsWith("base_volume:")) { voiceSet.volume = float.Parse(text.Substring(text.IndexOf("base_volume: ") + "base_volume:".Length).Trim()); } } return voiceSet; } catch (Exception ex) { Console.WriteLine("Custom Sosig Loader: An error occurred while reading the file: " + ex.Message); } return null; } public static Sosig GetSosig(Transform start) { Sosig val = ((Component)start.root).GetComponent<Sosig>(); if ((Object)(object)val == (Object)null) { SosigWearable component = ((Component)start).GetComponent<SosigWearable>(); if ((Object)(object)component != (Object)null) { val = component.S; } } if ((Object)(object)val == (Object)null) { val = ((Component)start).GetComponent<Sosig>(); } return val; } public static Quaternion SmoothRotateTowards(Vector3 direction, Quaternion currentRotation, float turnSpeed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.LookRotation(direction); return Quaternion.RotateTowards(currentRotation, val, turnSpeed * Time.deltaTime); } public static bool IsSosigDead(Sosig sosig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if ((int)sosig.BodyState == 3 || sosig.Mustard <= 0f || (int)sosig.m_diedFromType > 0) { return true; } return false; } } public class VoiceSet { public string name = ""; public float pitch = 1.15f; public float volume = 0.4f; } public class SosigMP : MonoBehaviour { public static SosigMP instance; private int sosigUpdate_ID = -1; private void Awake() { instance = this; } public void Start() { if (CustomSosigLoaderPlugin.h3mpEnabled) { StartNetworking(); } } private void StartNetworking() { if (Networking.ServerRunning() && (Networking.IsHost() || Client.isFullyConnected)) { SetupPacketTypes(); } } private void SetupPacketTypes() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown if (Networking.IsHost()) { if (Mod.registeredCustomPacketIDs.ContainsKey("CSL_Update")) { sosigUpdate_ID = Mod.registeredCustomPacketIDs["CSL_Update"]; } else { sosigUpdate_ID = Server.RegisterCustomPacketType("CSL_Update", 0); } Mod.customPacketHandlers[sosigUpdate_ID] = new CustomPacketHandler(CustomSosig_Handler); } else if (Mod.registeredCustomPacketIDs.ContainsKey("CSL_Update")) { sosigUpdate_ID = Mod.registeredCustomPacketIDs["CSL_Update"]; Mod.customPacketHandlers[sosigUpdate_ID] = new CustomPacketHandler(CustomSosig_Handler); } else { ClientSend.RegisterCustomPacketType("CSL_Update"); Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(CustomSosig_Received); } } public void CustomSosig_Send(Sosig sosig, int sosigID, int customIndex) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown TrackedSosig component = ((Component)sosig).gameObject.GetComponent<TrackedSosig>(); if (Networking.ServerRunning() && !Networking.IsClient() && !Object.op_Implicit((Object)(object)component)) { Packet val = new Packet(sosigUpdate_ID); val.Write(((TrackedObjectData)component.sosigData).trackedID); val.Write(sosigID); val.Write(customIndex); ServerSend.SendTCPDataToAll(val, true); Debug.Log((object)("Server - Sending Custom sosig data to " + ((TrackedObject)component).data.trackedID + " ID: " + sosigID)); } } private void CustomSosig_Handler(int clientID, Packet packet) { int num = packet.ReadInt(true); int num2 = packet.ReadInt(true); int customIndex = packet.ReadInt(true); Debug.Log((object)("Client - Sosig data: " + num + " ID " + num2)); if (Client.objects.Length > num && Client.objects[num] != null) { Sosig component = ((Component)Client.objects[num].physical).gameObject.GetComponent<Sosig>(); CustomSosigLoaderPlugin.customSosigIDs.TryGetValue((SosigEnemyID)num2, out var value); Hooks.SetupCustomSosig(component, value, customIndex); } } private void CustomSosig_Received(string identifier, int index) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (identifier == "CSL_Update") { sosigUpdate_ID = index; Mod.customPacketHandlers[index] = new CustomPacketHandler(CustomSosig_Handler); Mod.CustomPacketHandlerReceived -= new CustomPacketHandlerReceivedDelegate(CustomSosig_Received); } } } [HarmonyPatch] internal static class Hooks { [HarmonyPatch(typeof(Sosig))] [HarmonyPatch("Configure")] [HarmonyPrefix] public static void Configure_Prefix(Sosig __instance, SosigConfigTemplate t) { SetupCustomSosig(__instance, t); } public static void SetupCustomSosig(Sosig sosig, SosigConfigTemplate t, int customIndex = -1) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected I4, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected I4, but got Unknown if (!CustomSosigLoaderPlugin.customSosigConfigs.ContainsKey(t)) { return; } SosigEnemyID valueOrDefault = CustomSosigLoaderPlugin.customSosigConfigs.GetValueOrDefault(t); if ((int)valueOrDefault <= 0) { return; } int key = (int)valueOrDefault; if (!CustomSosigLoaderPlugin.customSosigs.ContainsKey(key)) { return; } Custom_SosigEnemyTemplate valueOrDefault2 = CustomSosigLoaderPlugin.customSosigs.GetValueOrDefault(key); if (valueOrDefault2 != null) { if (customIndex == -1) { customIndex = Random.Range(0, valueOrDefault2.CustomSosigs.Length); } ModifySosig(sosig, valueOrDefault2, customIndex); if (CustomSosigLoaderPlugin.h3mpEnabled && Networking.IsHost()) { SosigMP.instance.CustomSosig_Send(sosig, (int)valueOrDefault, customIndex); } } } public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) { dictionary.TryGetValue(key, out var value); return value; } public static void ModifySosig(Sosig sosig, Custom_SosigEnemyTemplate template, int customIndex) { //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_0383: Expected O, but got Unknown //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Expected O, but got Unknown //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Expected O, but got Unknown if (template == null) { CustomSosigLoaderPlugin.Logger.LogInfo((object)"Missing Template"); } Custom_Sosig custom_Sosig = template.CustomSosigs[customIndex]; Custom_SosigConfigTemplate custom_SosigConfigTemplate = template.Configs[Random.Range(0, template.Configs.Length)]; bool flag = !custom_SosigConfigTemplate.CanBeSevered; if (!flag && (custom_Sosig.scaleHead.y * custom_Sosig.scaleBody.y > 1f || custom_Sosig.scaleTorso.y * custom_Sosig.scaleBody.y > 1f || custom_Sosig.scaleLegsUpper.y * custom_Sosig.scaleBody.y > 1f || custom_Sosig.scaleLegsLower.y * custom_Sosig.scaleBody.y > 1f)) { flag = true; } MeshRenderer sosigMeshRenderer = Custom_SosigData.GetSosigMeshRenderer("Geo_Head", ((Component)sosig.Links[0]).transform); MeshRenderer sosigMeshRenderer2 = Custom_SosigData.GetSosigMeshRenderer("Geo_Torso", ((Component)sosig.Links[1]).transform); MeshRenderer sosigMeshRenderer3 = Custom_SosigData.GetSosigMeshRenderer("Geo_UpperLink", ((Component)sosig.Links[2]).transform); MeshRenderer sosigMeshRenderer4 = Custom_SosigData.GetSosigMeshRenderer("Geo_LowerLink", ((Component)sosig.Links[3]).transform); ((Renderer)sosigMeshRenderer).enabled = !custom_Sosig.hideHeadMesh; ((Renderer)sosigMeshRenderer2).enabled = !custom_Sosig.hideTorsoMesh; ((Renderer)sosigMeshRenderer3).enabled = !custom_Sosig.hideLegsUpperMesh; ((Renderer)sosigMeshRenderer4).enabled = !custom_Sosig.hideLegsLowerMesh; Material material = ((Renderer)sosigMeshRenderer).material; if (custom_Sosig.customSkin.Contains("CustomSosig_Base")) { material.SetTexture("_MainTex", (Texture)(object)CustomSosigLoaderPlugin.customSosigTexture); } else if (custom_Sosig.customSkin != "") { if (Object.op_Implicit((Object)(object)custom_Sosig.albedo)) { material.SetTexture("_MainTex", (Texture)(object)custom_Sosig.albedo); } if (Object.op_Implicit((Object)(object)custom_Sosig.normalmap)) { material.SetTexture("_BumpMap", (Texture)(object)custom_Sosig.normalmap); } if (Object.op_Implicit((Object)(object)custom_Sosig.masr)) { material.SetTexture("_SpecTex", (Texture)(object)custom_Sosig.masr); } } material.SetColor("_Color", custom_Sosig.color); material.SetFloat("_Metallic", custom_Sosig.metallic); material.SetFloat("_Specularity", custom_Sosig.specularity); material.SetFloat("_SpecularTint", custom_Sosig.specularTint); material.SetFloat("_Roughness", custom_Sosig.roughness); material.SetFloat("_BumpScale", custom_Sosig.normalStrength); material.SetInt("_SpecularHighlights", custom_Sosig.specularHighlights ? 1 : 0); material.SetInt("_GlossyReflections", custom_Sosig.glossyReflections ? 1 : 0); ((Renderer)sosigMeshRenderer).sharedMaterial = material; sosig.GibMaterial = material; if (sosig.Links.Count >= 1) { Custom_SosigData.UpdateSosigLink(sosig.Links[0], custom_Sosig.scaleBody, custom_Sosig.scaleHead, material, flag, (MeshRenderer)sosig.Renderers[0]); } if (sosig.Links.Count >= 2) { Custom_SosigData.UpdateSosigLink(sosig.Links[1], custom_Sosig.scaleBody, custom_Sosig.scaleTorso, material, flag, (MeshRenderer)sosig.Renderers[1]); } if (sosig.Links.Count >= 3) { Custom_SosigData.UpdateSosigLink(sosig.Links[2], custom_Sosig.scaleBody, custom_Sosig.scaleLegsUpper, material, flag, (MeshRenderer)sosig.Renderers[2]); } if (sosig.Links.Count >= 4) { Custom_SosigData.UpdateSosigLink(sosig.Links[3], custom_Sosig.scaleBody, custom_Sosig.scaleLegsUpper, material, flag, (MeshRenderer)sosig.Renderers[3]); } ((Component)sosig).transform.localScale = custom_Sosig.scaleBody; float num = ((custom_Sosig.scaleBody.x > custom_Sosig.scaleBody.z) ? custom_Sosig.scaleBody.x : custom_Sosig.scaleBody.z); if (num > sosig.Agent.radius) { sosig.Agent.radius = sosig.Agent.radius * ((custom_Sosig.scaleBody.x > custom_Sosig.scaleBody.z) ? custom_Sosig.scaleBody.x : custom_Sosig.scaleBody.z); } NavMeshAgent agent = sosig.Agent; agent.height *= custom_Sosig.scaleBody.y; if (custom_Sosig.voiceSet != "") { CustomSosigLoaderPlugin.customVoicelines.TryGetValue(custom_Sosig.voiceSet, out var value); if ((Object)(object)value != (Object)null) { sosig.Speech = value; } return; } SosigSpeechSet val = ScriptableObject.CreateInstance<SosigSpeechSet>(); val.OnAssault = sosig.Speech.OnAssault; val.OnBackBreak = sosig.Speech.OnBackBreak; val.OnBeingAimedAt = sosig.Speech.OnBeingAimedAt; val.OnCall_Assistance = sosig.Speech.OnCall_Assistance; val.OnCall_Skirmish = sosig.Speech.OnCall_Skirmish; val.OnConfusion = sosig.Speech.OnConfusion; val.OnDeath = sosig.Speech.OnDeath; val.OnDeathAlt = sosig.Speech.OnDeathAlt; val.OnInvestigate = sosig.Speech.OnInvestigate; val.OnJointBreak = sosig.Speech.OnJointBreak; val.OnJointSever = sosig.Speech.OnJointSever; val.OnJointSlice = sosig.Speech.OnJointSlice; val.OnMedic = sosig.Speech.OnMedic; val.OnNeckBreak = sosig.Speech.OnNeckBreak; val.OnPain = sosig.Speech.OnPain; val.OnReloading = sosig.Speech.OnReloading; val.OnRespond_Assistance = sosig.Speech.OnRespond_Assistance; val.OnRespond_Skirmish = sosig.Speech.OnRespond_Skirmish; val.OnSearchingForGuns = sosig.Speech.OnSearchingForGuns; val.OnSkirmish = sosig.Speech.OnSkirmish; val.OnTakingCover = sosig.Speech.OnTakingCover; val.OnWander = sosig.Speech.OnWander; val.Test = sosig.Speech.Test; val.LessTalkativeSkirmish = sosig.Speech.LessTalkativeSkirmish; val.UseAltDeathOnHeadExplode = sosig.Speech.UseAltDeathOnHeadExplode; val.ForceDeathSpeech = sosig.Speech.ForceDeathSpeech; val.BasePitch = custom_Sosig.voicePitch; val.BaseVolume = custom_Sosig.voiceVolume; sosig.Speech = val; } } [BepInPlugin("Sosig_Squad.CustomSosigLoader", "Custom Sosig Loader", "1.0.6")] [BepInProcess("h3vr.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CustomSosigLoaderPlugin : BaseUnityPlugin { public delegate void SosigsLoadedComplete(); [CompilerGenerated] private sealed class <SetupSosigTemplates>d__24 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CustomSosigLoaderPlugin <>4__this; private Dictionary<int, Custom_SosigEnemyTemplate>.Enumerator <>s__1; private KeyValuePair<int, Custom_SosigEnemyTemplate> <customTemplate>5__2; private SosigEnemyTemplate <template>5__3; private List<string> <customSkins>5__4; private int <i>5__5; private SosigEnemyID <id>5__6; private int <i>5__7; private List<SosigEnemyID> <sosigIDs>5__8; private List<SosigEnemyTemplate> <enemyTemplates>5__9; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetupSosigTemplates>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(Dictionary<int, Custom_SosigEnemyTemplate>.Enumerator); <customTemplate>5__2 = default(KeyValuePair<int, Custom_SosigEnemyTemplate>); <template>5__3 = null; <customSkins>5__4 = null; <sosigIDs>5__8 = null; <enemyTemplates>5__9 = null; <>1__state = -2; } private bool MoveNext() { //IL_00f2: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_026b: 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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Invalid comparison between Unknown and I4 //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; Logger.LogInfo((object)("Custom Sosigs count: " + customSosigs.Count)); Logger.LogInfo((object)("Sosigs count: " + ManagerSingleton<IM>.Instance.odicSosigObjsByID.Count)); <>s__1 = customSosigs.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <template>5__3 = null; <customSkins>5__4 = null; <customTemplate>5__2 = default(KeyValuePair<int, Custom_SosigEnemyTemplate>); break; } if (<>s__1.MoveNext()) { <customTemplate>5__2 = <>s__1.Current; <template>5__3 = <customTemplate>5__2.Value.Initialize(); <template>5__3.DisplayName = <customTemplate>5__2.Value.DisplayName; <template>5__3.SosigEnemyID = (SosigEnemyID)<customTemplate>5__2.Value.SosigEnemyID; <template>5__3.SosigEnemyCategory = (SosigEnemyCategory)<customTemplate>5__2.Value.SosigEnemyCategory; <template>5__3.SosigPrefabs = new List<FVRObject>(); <customSkins>5__4 = new List<string>(); <i>5__5 = 0; while (<i>5__5 < <customTemplate>5__2.Value.CustomSosigs.Length) { <id>5__6 = <customTemplate>5__2.Value.CustomSosigs[<i>5__5].baseSosigID; <template>5__3.SosigPrefabs = ManagerSingleton<IM>.Instance.odicSosigObjsByID[<id>5__6].SosigPrefabs; if (<customTemplate>5__2.Value.CustomSosigs[<i>5__5].customSkin != "") { Global.LoadSosigMaterial(<customTemplate>5__2.Value.CustomSosigs[<i>5__5]); } <i>5__5++; } <i>5__7 = 0; while (<i>5__7 < <template>5__3.ConfigTemplates.Count) { if (!customSosigConfigs.ContainsKey(<template>5__3.ConfigTemplates[<i>5__7])) { customSosigConfigs.Add(<template>5__3.ConfigTemplates[<i>5__7], <template>5__3.SosigEnemyID); } if (!customSosigIDs.ContainsKey(<template>5__3.SosigEnemyID)) { customSosigIDs.Add(<template>5__3.SosigEnemyID, <template>5__3.ConfigTemplates[<i>5__7]); } <i>5__7++; } if (!ManagerSingleton<IM>.Instance.olistSosigCats.Contains(<template>5__3.SosigEnemyCategory)) { ManagerSingleton<IM>.Instance.olistSosigCats.Add(<template>5__3.SosigEnemyCategory); } if (!ManagerSingleton<IM>.Instance.odicSosigIDsByCategory.ContainsKey(<template>5__3.SosigEnemyCategory)) { <sosigIDs>5__8 = new List<SosigEnemyID>(); ManagerSingleton<IM>.Instance.odicSosigIDsByCategory.Add(<template>5__3.SosigEnemyCategory, <sosigIDs>5__8); <enemyTemplates>5__9 = new List<SosigEnemyTemplate>(); ManagerSingleton<IM>.Instance.odicSosigObjsByCategory.Add(<template>5__3.SosigEnemyCategory, <enemyTemplates>5__9); <sosigIDs>5__8 = null; <enemyTemplates>5__9 = null; } if ((int)<template>5__3.SosigEnemyID != -1) { ManagerSingleton<IM>.Instance.odicSosigIDsByCategory[<template>5__3.SosigEnemyCategory].Add(<template>5__3.SosigEnemyID); ManagerSingleton<IM>.Instance.odicSosigObjsByCategory[<template>5__3.SosigEnemyCategory].Add(<template>5__3); if (!ManagerSingleton<IM>.Instance.odicSosigObjsByID.ContainsKey(<template>5__3.SosigEnemyID)) { ManagerSingleton<IM>.Instance.odicSosigObjsByID.Add(<template>5__3.SosigEnemyID, <template>5__3); } } <>2__current = null; <>1__state = 1; return true; } <>m__Finally1(); <>s__1 = default(Dictionary<int, Custom_SosigEnemyTemplate>.Enumerator); Logger.LogInfo((object)("Sosigs Total count: " + ManagerSingleton<IM>.Instance.odicSosigObjsByID.Count)); CustomSosigsLoaded = true; if (CustomSosigLoaderPlugin.SosigsLoadedCompleted != null) { CustomSosigLoaderPlugin.SosigsLoadedCompleted(); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool h3mpEnabled = false; public static bool supplyRaidEnabled = false; public static bool otherLoaderEnabled = false; public static bool tnhFramework = false; public static bool CustomSosigsLoaded = false; public static SosigMP sosigMP; public static Dictionary<int, Custom_SosigEnemyTemplate> customSosigs = new Dictionary<int, Custom_SosigEnemyTemplate>(); public static Dictionary<SosigConfigTemplate, SosigEnemyID> customSosigConfigs = new Dictionary<SosigConfigTemplate, SosigEnemyID>(); public static Dictionary<SosigEnemyID, SosigConfigTemplate> customSosigIDs = new Dictionary<SosigEnemyID, SosigConfigTemplate>(); public static Texture2D customSosigTexture; public static Dictionary<string, SosigSpeechSet> customVoicelines = new Dictionary<string, SosigSpeechSet>(); public static bool screenshotSosigs = false; public static bool screenshotSosigGear = false; public static int vehicleAgentID = 1; internal static ManualLogSource Logger { get; private set; } public static event SosigsLoadedComplete SosigsLoadedCompleted; private void Awake() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; h3mpEnabled = Chainloader.PluginInfos.ContainsKey("VIP.TommySoucy.H3MP"); supplyRaidEnabled = Chainloader.PluginInfos.ContainsKey("com.Packer.SupplyRaid"); otherLoaderEnabled = Chainloader.PluginInfos.ContainsKey("h3vr.otherloader"); tnhFramework = Chainloader.PluginInfos.ContainsKey("h3vr.tnhframework"); LoaderStatus.ProgressUpdated += new StatusUpdate(LoadCustomSosigCheck); } private void Start() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (h3mpEnabled) { sosigMP = new GameObject().AddComponent<SosigMP>(); Object.DontDestroyOnLoad((Object)(object)((Component)sosigMP).gameObject); } } private void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown LoaderStatus.ProgressUpdated -= new StatusUpdate(LoadCustomSosigCheck); } private void LoadCustomSosigs() { Logger.LogInfo((object)"Custom Sosig Loader: Loading Sosigs"); Logger.LogInfo((object)"Custom Sosig Loader: Start Sosig Capture - Right Shift + O"); Logger.LogInfo((object)"Custom Sosig Loader: Stop Sosig Capture - Right Shift + P"); Logger.LogInfo((object)"Custom Sosig Loader: Start Gear Capture - Right Shift + U"); Logger.LogInfo((object)"Custom Sosig Loader: Stop Gear Capture - Right Shift + I"); Global.LoadCustomVoiceLines(); Global.LoadWhiteSosigTexture("CustomSosig_Base.png"); Global.LoadCustomSosigs(); ((MonoBehaviour)this).StartCoroutine(SetupSosigTemplates()); Harmony.CreateAndPatchAll(typeof(Hooks), (string)null); } private void LoadCustomSosigCheck(float progress) { if (!CustomSosigsLoaded && !(progress < 1f)) { LoadCustomSosigs(); } } private void Update() { if (Input.GetKey((KeyCode)303) && Input.GetKeyUp((KeyCode)116)) { Logger.LogInfo((object)"Printing all Sosig Clothing"); PrintAllFVRObjects(); } if (Input.GetKey((KeyCode)303) && Input.GetKeyUp((KeyCode)111)) { Logger.LogInfo((object)"Right Shift + O Pressed - Start Sosig Capture"); if (!screenshotSosigs) { screenshotSosigs = true; ((MonoBehaviour)this).StartCoroutine(SosigScreenshots.RunSosigCapture()); } } if (Input.GetKey((KeyCode)303) && Input.GetKeyUp((KeyCode)112)) { Logger.LogInfo((object)"Right Shift + P Pressed - Stop Sosig Capture"); screenshotSosigs = false; } if (Input.GetKey((KeyCode)303) && Input.GetKeyUp((KeyCode)117)) { Logger.LogInfo((object)"Right Shift + U Pressed - Start Gear Capture"); if (!screenshotSosigGear) { screenshotSosigGear = true; ((MonoBehaviour)this).StartCoroutine(SosigScreenshots.RunSosigGearCapture()); } } if (Input.GetKey((KeyCode)303) && Input.GetKeyUp((KeyCode)105)) { Logger.LogInfo((object)"Right Shift + I Pressed - Stop Gear Capture"); screenshotSosigGear = false; } } public IEnumerator SetupSosigTemplates() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetupSosigTemplates>d__24(0) { <>4__this = this }; } public void PrintAllFVRObjects() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 foreach (string key in IM.OD.Keys) { if (IM.OD.TryGetValue(key, out var value) && Object.op_Implicit((Object)(object)value) && (int)value.Category == 60) { Logger.LogInfo((object)value.DisplayName); } } } } public class SosigScreenshots { [CompilerGenerated] private sealed class <RunSosigCapture>d__8 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private IEnumerator <>s__1; private SosigEnemyID <pieceType>5__2; private string <enumName>5__3; private SosigEnemyTemplate <newSosig>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunSosigCapture>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 2) <= 6u) { try { } finally { <>m__Finally1(); } } <>s__1 = null; <enumName>5__3 = null; <newSosig>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected I4, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; CreateScreenshotSetup(); <>2__current = null; <>1__state = 1; result = true; goto end_IL_0000; case 1: <>1__state = -1; captureCamera.fov = 15f; captureCamera.fieldOfView = 15f; CustomSosigLoaderPlugin.screenshotSosigs = true; CustomSosigLoaderPlugin.Logger.LogInfo((object)("Screen Capture Started at " + DateTime.Now)); <>s__1 = Enum.GetValues(typeof(SosigEnemyID)).GetEnumerator(); <>1__state = -3; break; case 2: <>1__state = -3; <>2__current = null; <>1__state = 3; result = true; goto end_IL_0000; case 3: <>1__state = -3; <>2__current = null; <>1__state = 4; result = true; goto end_IL_0000; case 4: <>1__state = -3; TakeScreenshot((int)<pieceType>5__2 + "_" + <enumName>5__3, "/Sosigs/"); <>2__current = null; <>1__state = 5; result = true; goto end_IL_0000; case 5: <>1__state = -3; <>2__current = null; <>1__state = 6; result = true; goto end_IL_0000; case 6: <>1__state = -3; currentSosig.DeSpawnSosig(); <>2__current = null; <>1__state = 7; result = true; goto end_IL_0000; case 7: <>1__state = -3; <>2__current = null; <>1__state = 8; result = true; goto end_IL_0000; case 8: <>1__state = -3; <enumName>5__3 = null; <newSosig>5__4 = null; break; } while (true) { if (<>s__1.MoveNext()) { <pieceType>5__2 = (SosigEnemyID)<>s__1.Current; if (!CustomSosigLoaderPlugin.screenshotSosigs) { CustomSosigLoaderPlugin.Logger.LogInfo((object)("Screen Capture force stopped at " + DateTime.Now)); if (Object.op_Implicit((Object)(object)currentSosig)) { currentSosig.DeSpawnSosig(); } result = false; <>m__Finally1(); break; } <enumName>5__3 = Enum.GetName(typeof(SosigEnemyID), <pieceType>5__2); CustomSosigLoaderPlugin.Logger.LogInfo((object)(((object)(SosigEnemyID)(ref <pieceType>5__2)).ToString() + " - " + <enumName>5__3)); ManagerSingleton<IM>.Instance.odicSosigObjsByID.TryGetValue(<pieceType>5__2, out <newSosig>5__4); if (!((Object)(object)<newSosig>5__4 == (Object)null)) { currentSosig = SosigAPI.Spawn(<newSosig>5__4, _spawnOptions, spawnPoint.position, spawnPoint.rotation); if (!((Object)(object)currentSosig == (Object)null)) { <>2__current = null; <>1__state = 2; result = true; break; } } continue; } <>m__Finally1(); <>s__1 = null; if (Object.op_Implicit((Object)(object)captureCamera)) { Object.Destroy((Object)(object)((Component)captureCamera).gameObject); } CustomSosigLoaderPlugin.Logger.LogInfo((object)("Screen Capture Complete at " + DateTime.Now)); result = false; break; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__1 is IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RunSosigGearCapture>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private List<FVRObject> <gearList>5__1; private List<FVRObject>.Enumerator <>s__2; private FVRObject <gear>5__3; private GameObject <spawnObject>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RunSosigGearCapture>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 2) <= 4u) { try { } finally { <>m__Finally1(); } } <gearList>5__1 = null; <>s__2 = default(List<FVRObject>.Enumerator); <gear>5__3 = null; <spawnObject>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) bool result; try { switch (<>1__state) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; CreateScreenshotSetup(); <gearList>5__1 = GearSosigClothing(); <>2__current = null; <>1__state = 1; result = true; goto end_IL_0000; case 1: <>1__state = -1; captureCamera.fov = 7.5f; captureCamera.fieldOfView = 7.5f; CustomSosigLoaderPlugin.screenshotSosigGear = true; CustomSosigLoaderPlugin.Logger.LogInfo((object)("Sosig Gear Started at " + DateTime.Now)); <>s__2 = <gearList>5__1.GetEnumerator(); <>1__state = -3; break; case 2: <>1__state = -3; <>2__current = null; <>1__state = 3; result = true; goto end_IL_0000; case 3: <>1__state = -3; <>2__current = null; <>1__state = 4; result = true; goto end_IL_0000; case 4: <>1__state = -3; TakeScreenshot(<gear>5__3.ItemID, "/Gear/"); <>2__current = null; <>1__state = 5; result = true; goto end_IL_0000; case 5: <>1__state = -3; if (Object.op_Implicit((Object)(object)currentGear)) { Object.Destroy((Object)(object)currentGear); } <>2__current = null; <>1__state = 6; result = true; goto end_IL_0000; case 6: <>1__state = -3; <spawnObject>5__4 = null; <gear>5__3 = null; break; } while (true) { if (<>s__2.MoveNext()) { <gear>5__3 = <>s__2.Current; if (!CustomSosigLoaderPlugin.screenshotSosigGear) { CustomSosigLoaderPlugin.Logger.LogInfo((object)("Sosig Gear force stopped at " + DateTime.Now)); if (Object.op_Implicit((Object)(object)currentGear)) { Object.Destroy((Object)(object)currentGear); } result = false; <>m__Finally1(); break; } <spawnObject>5__4 = ((AnvilAsset)<gear>5__3).GetGameObject(); if (Object.op_Implicit((Object)(object)<spawnObject>5__4)) { currentGear = Object.Instantiate<GameObject>(<spawnObject>5__4).gameObject; } if ((Object)(object)<spawnObject>5__4 == (Object)null || (Object)(object)currentGear == (Object)null) { continue; } currentGear.transform.position = spawnPoint.position + Vector3.up; currentGear.transform.rotation = Quaternion.Euler(0f, 180f, 0f); <>2__current = null; <>1__state = 2; result = true; break; } <>m__Finally1(); <>s__2 = default(List<FVRObject>.Enumerator); if (Object.op_Implicit((Object)(object)currentGear)) { Object.Destroy((Object)(object)currentGear); } CustomSosigLoaderPlugin.Logger.LogInfo((object)("Sosig Gear Complete at " + DateTime.Now)); result = false; break; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static Camera captureCamera; public static Transform spawnPoint; public static Sosig currentSosig; public static GameObject currentGear; public static readonly SpawnOptions _spawnOptions = new SpawnOptions { SpawnState = (SosigOrder)0, SpawnActivated = true, EquipmentMode = (EquipmentSlots)7, SpawnWithFullAmmo = true, IFF = 0 }; public static void CreateScreenshotSetup() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0023: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_00ff: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)captureCamera != (Object)null)) { GameObject val = new GameObject(); val.transform.position = Vector3.up * 150f; captureCamera = val.AddComponent<Camera>(); captureCamera.fov = 15f; captureCamera.fieldOfView = 15f; captureCamera.targetTexture = new RenderTexture(1024, 1024, 1, (RenderTextureFormat)0, (RenderTextureReadWrite)2); captureCamera.Render(); spawnPoint = new GameObject().transform; spawnPoint.parent = val.transform; spawnPoint.localPosition = new Vector3(0f, -1f, 10f); spawnPoint.rotation = Quaternion.Euler(0f, 180f, 0f); Material val2 = new Material(Shader.Find("Unlit/Color")); val2.SetColor("_Color", Color.green); GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3); ((Renderer)val3.GetComponent<MeshRenderer>()).material = val2; val3.transform.parent = ((Component)spawnPoint).transform; val3.transform.localPosition = new Vector3(0f, 0f, -2f); val3.transform.localScale = new Vector3(10f, 10f, 1f); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); ((Renderer)val4.GetComponent<MeshRenderer>()).material = val2; val4.transform.parent = spawnPoint; val4.transform.localPosition = new Vector3(0f, -0.51f, 0f); val4.transform.localScale = new Vector3(10f, 1f, 10f); val4.AddComponent<NavMeshSurface>().BuildNavMesh(); GameObject val5 = new GameObject(); Light val6 = val5.AddComponent<Light>(); val6.intensity = 4f; val6.type = (LightType)2; val6.range = 30f; val5.transform.parent = spawnPoint; val5.transform.localPosition = new Vector3(1.5f, 3f, 3f); } } public static List<FVRObject> GearSosigClothing() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 List<FVRObject> list = new List<FVRObject>(); foreach (string key in IM.OD.Keys) { if (IM.OD.TryGetValue(key, out var value) && Object.op_Implicit((Object)(object)value) && (int)value.Category == 60) { list.Add(value); } } return list; } public static IEnumerator RunSosigGearCapture() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunSosigGearCapture>d__7(0); } public static IEnumerator RunSosigCapture() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RunSosigCapture>d__8(0); } public static void TakeScreenshot(string nameID, string directory) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) RenderTexture active = RenderTexture.active; RenderTexture.active = captureCamera.targetTexture; captureCamera.Render(); Texture2D val = new Texture2D(((Texture)captureCamera.targetTexture).width, ((Texture)captureCamera.targetTexture).height, (TextureFormat)4, false, true); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)captureCamera.targetTexture).width, (float)((Texture)captureCamera.targetTexture).height), 0, 0); val.Apply(); RenderTexture.active = active; byte[] array = val.EncodeToPNG(); string text = nameID + ".png"; string text2 = Application.persistentDataPath + directory; try { if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); } } catch (Exception ex) { CustomSosigLoaderPlugin.Logger.LogInfo((object)ex.Message); return; } text2 += text; using FileStream fileStream = new FileStream(text2, FileMode.OpenOrCreate); CustomSosigLoaderPlugin.Logger.LogInfo((object)("Write to file: " + text2)); fileStream.Write(array, 0, array.Length); } } public class CSL_Ally : MonoBehaviour { [HideInInspector] public Sosig sosig; [HideInInspector] public SosigWearable wearable; [HideInInspector] public Transform followPlayer; private float timeout = 0f; public float followDistance = 4f; [HideInInspector] private bool followSide = false; public void Start() { if ((Object)(object)sosig == (Object)null) { Global.GetSosig(((Component)this).transform); } if ((Object)(object)sosig == (Object)null) { Debug.Log((object)"Failed to find sosig body on Ally Wearable"); ((Behaviour)this).enabled = false; } else { SetAlly(); followSide = Random.Range(0, 10) > 5; } } private void Update() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sosig == (Object)null) && !(timeout > Time.time)) { timeout = Time.time + Random.Range(0f, 5f); if (!InCombat(sosig.CurrentOrder) && Vector3.SqrMagnitude(followPlayer.position) > followDistance) { SetWaypointToPlayer(); } } } public static bool InCombat(SosigOrder order) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected I4, but got Unknown switch ((int)order) { default: return false; case 2: case 3: case 4: case 5: case 7: case 8: case 11: case 12: return true; } } private void SetWaypointToPlayer() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (followSide ? (followPlayer.forward + followPlayer.right) : (followPlayer.forward - followPlayer.right)); NavMeshHit val2 = default(NavMeshHit); Vector3 item = ((!NavMesh.SamplePosition(followPlayer.position - val * followDistance, ref val2, followDistance, -1)) ? followPlayer.position : ((NavMeshHit)(ref val2)).position); List<Vector3> list = new List<Vector3>(2) { item, item }; List<Vector3> list2 = new List<Vector3>(2); Quaternion rotation = followPlayer.rotation; list2.Add(((Quaternion)(ref rotation)).eulerAngles); rotation = followPlayer.rotation; list2.Add(((Quaternion)(ref rotation)).eulerAngles); List<Vector3> list3 = list2; sosig.CommandPathTo(list, list3, 1f, Vector2.one * 4f, 2f, (SosigMoveSpeed)4, (PathLoopType)4, (List<Sosig>)null, 0.2f, 1f, true, 50f); } private void SetAlly() { sosig.SetIFF(GM.CurrentPlayerBody.GetPlayerIFF()); if (!((Object)(object)followPlayer != (Object)null)) { if (CustomSosigLoaderPlugin.h3mpEnabled) { followPlayer = GM.CurrentPlayerBody.Head; } else { followPlayer = GM.CurrentPlayerBody.Head; } } } } public class CSL_PassiveFollower : MonoBehaviour { [HideInInspector] public Sosig sosig; [HideInInspector] public Transform followPlayer; private float timeout = 0f; public float followDistance = 4f; [HideInInspector] private bool followSide = false; public void Start() { if ((Object)(object)sosig == (Object)null) { sosig = Global.GetSosig(((Component)this).transform); } if ((Object)(object)sosig == (Object)null) { Debug.Log((object)"Failed to find sosig body on Ally Wearable"); ((Behaviour)this).enabled = false; } else { SetAlly(); followSide = Random.Range(0, 10) > 5; } } private void Update() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sosig == (Object)null) && !(timeout > Time.time)) { timeout = Time.time + Random.Range(0f, 5f); if (Vector3.SqrMagnitude(followPlayer.position) > followDistance) { SetWaypointToPlayer(); } } } private void SetWaypointToPlayer() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (followSide ? (followPlayer.forward + followPlayer.right) : (followPlayer.forward - followPlayer.right)); NavMeshHit val2 = default(NavMeshHit); Vector3 item = ((!NavMesh.SamplePosition(followPlayer.position - val * followDistance, ref val2, followDistance, -1)) ? followPlayer.position : ((NavMeshHit)(ref val2)).position); List<Vector3> list = new List<Vector3>(2) { item, item }; List<Vector3> list2 = new List<Vector3>(2); Quaternion rotation = followPlayer.rotation; list2.Add(((Quaternion)(ref rotation)).eulerAngles); rotation = followPlayer.rotation; list2.Add(((Quaternion)(ref rotation)).eulerAngles); List<Vector3> list3 = list2; sosig.CommandPathTo(list, list3, 1f, Vector2.one * 4f, 2f, (SosigMoveSpeed)4, (PathLoopType)4, (List<Sosig>)null, 0.2f, 1f, true, 50f); } private void SetAlly() { sosig.SetIFF(GM.CurrentPlayerBody.GetPlayerIFF()); if (!((Object)(object)followPlayer != (Object)null)) { ((object)sosig).GetType().GetField("IgnoresNeedForWeapons").SetValue(sosig, true); if (CustomSosigLoaderPlugin.h3mpEnabled) { followPlayer = GM.CurrentPlayerBody.Head; } else { followPlayer = GM.CurrentPlayerBody.Head; } } } } public class CSL_Vehicle : MonoBehaviour { [Serializable] public class WheelType { public enum WheelEnum { Straight, Turns, InverseTurns } public Transform wheel; public WheelEnum type; [Tooltip("How much the wheel can visually turn")] public float maxTurnAngle = 40f; [Tooltip("Is this wheel included in the vehicle's surface angle calculation (Should only include corner wheels)")] public bool surfaceAngleCalculation = false; [HideInInspector] public Vector3 wheelRotation = Vector3.zero; [HideInInspector] public Vector3 startLocalPosition = Vector3.zero; } public SosigWearable wearable; [Header("Spawning")] public Transform vehicleCenter; [Header("Health")] [Tooltip("Maximum health for this vehicle")] public float healthMax = 20f; [Tooltip("Current health for this vehicle")] public float healthCurrent = 20f; protected float damageTimeout = 0f; [Header("Wheels")] public float wheelRadius = 0.5f; public LayerMask wheelCollision; public bool wheelsSpin = true; public WheelType[] wheels; [Header("Agent")] [Tooltip("The size of the vehicle, radius should match the width of the vehicle (How narrow of an area it can drive through)")] public float agentRadius = 3f; [Tooltip("How tall the vehicle is")] public float agentHeight = 3f; [Tooltip("Rate the vehicle gets up to speed")] public float agentAccerlation = 2f; [Tooltip("How far it stops from its move waypoint, should be minimum Agent Radius")] public float agentStoppingDistance = 5f; [Header("Movement")] [Tooltip("Speed the vehicle turns at minimum")] public float turnSpeedMin = 1f; [Tooltip("Speed the vehicle turns moving at max speed")] public float turnSpeedMax = 45f; [Tooltip("How fast the vehicle aligns to the surface angle")] public float angleTurnRate = 15f; protected Transform muzzle; [Header("Turret")] [Tooltip("Head of the turret")] public Transform turretBase; [Tooltip("The barrels pivot point")] public Transform turretBarrel; public Transform turretMuzzle; [Tooltip("Degrees per second the turret turns to aim at its target")] public float aimSpeed = 45f; public bool hideSosigWeapon = true; public bool vehicleAlignsToSurface = true; [Header("Sosig")] public Transform sosigIconsPoint; public Transform sosigVision; [HideInInspector] public Sosig sosig; protected Vector2 currentVelocity; protected Vector3 lastPosition; protected Vector2 sosigLocalVelocityNormal; protected Vector3 localTargetPos; [Header("Visuals")] public Animator bodyAnimator; public Animator turretAnimator; [Tooltip("Alive Objects get disabled when killed")] public GameObject[] aliveObjects; [Tooltip("Death Objects get enabled when killed")] public GameObject[] deathObjects; [Tooltip("Damaged Objects get enabled when mustard reaches amount percentage")] public GameObject[] damagedObjects; [Range(0f, 1f)] [Tooltip("Percentage of health remaining when the damaged objects get enabled")] public float damagedThreshold = 0.5f; protected float healthDebug = 0f; private bool isDead = false; public void Start() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00b3: Expected O, but got Unknown sosig = Global.GetSosig(((Component)this).transform); if ((Object)(object)wearable == (Object)null) { wearable = ((Component)this).GetComponent<SosigWearable>(); } if ((Object)(object)sosig == (Object)null) { ((Behaviour)this).enabled = false; CustomSosigLoaderPlugin.Logger.LogError((object)("Vehicle Script - Missing Sosig is the CSL Vehicle component setup correctly? " + ((Object)this).name)); return; } for (int i = 0; i < wheels.Length; i++) { wheels[i].startLocalPosition = wheels[i].wheel.localPosition; } GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(VehicleKillEvent); ((MonoBehaviour)this).Invoke("LateSosigSetup", 0.5f); } private void Update() { SosigUpdate(); } private void FixedUpdate() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sosig == (Object)null) && ((Behaviour)sosig.Agent).enabled && !isDead) { currentVelocity = SosigLocalVelocity(); sosigLocalVelocityNormal = SosigClampedLocalVelocity(); if (vehicleAlignsToSurface) { SurfaceAngle(); } UpdateVisuals(); WeaponUpdate(); } } public void Damage(float amount = 1f, VehicleDamageEffect effect = VehicleDamageEffect.None, float effectTime = 0f) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //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: Expected O, but got Unknown if (Time.time < damageTimeout) { return; } damageTimeout = 0.3f; Damage val = new Damage(); val.Dam_Blinding = 0f; val.Dam_Cutting = 0f; val.Dam_Chilling = 0f; val.Dam_EMP = 0f; val.Dam_Piercing = 0f; val.Dam_Stunning = 0f; val.Dam_Thermal = 0f; val.Dam_TotalKinetic = 0f; val.Dam_TotalEnergetic = 0f; val.Class = (DamageClass)0; wearable.Damage(new Damage(val)); healthCurrent -= amount; switch (effect) { case VehicleDamageEffect.Stun: sosig.m_isStunned = true; sosig.m_stunTimeLeft = effectTime; break; case VehicleDamageEffect.Confused: sosig.m_isConfused = true; sosig.m_confusedTime = effectTime; break; case VehicleDamageEffect.Freeze: sosig.m_isFrozen = true; sosig.m_debuffTime_Freeze = effectTime; break; } if (healthCurrent <= healthMax * damagedThreshold) { for (int i = 0; i < damagedObjects.Length; i++) { if (!damagedObjects[i].activeSelf) { damagedObjects[i].SetActive(true); } } } if (healthCurrent <= 0f) { sosig.KillSosig(); } } private void LateSosigSetup() { //IL_00f4: 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_0121: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < sosig.Links.Count; i++) { sosig.Links[i].m_isJointSevered = true; } sosig.DamMult_Explosive = 0f; ((Component)sosig.E).transform.SetParent(vehicleCenter, false); sosig.Agent.radius = agentRadius; sosig.Agent.height = agentHeight; sosig.Agent.acceleration = agentAccerlation; sosig.Agent.stoppingDistance = agentStoppingDistance; ((Component)this).transform.SetParent(((Component)sosig.Agent).transform); ((Component)this).transform.position = ((Component)sosig.Agent).transform.position; ((Component)this).transform.rotation = ((Component)sosig.Agent).transform.rotation; muzzle = new GameObject().transform; muzzle.SetParent(turretMuzzle); muzzle.SetPositionAndRotation(turretMuzzle.position, turretMuzzle.rotation); for (int j = 0; j < sosig.Hands.Count; j++) { sosig.Hands[j].Root = muzzle; sosig.Hands[j].Target = muzzle; sosig.Hands[j].Point_Aimed = muzzle; sosig.Hands[j].Point_AtRest = muzzle; sosig.Hands[j].Point_HipFire = muzzle; sosig.Hands[j].Point_ShieldHold = muzzle; if ((Object)(object)sosig.Hands[j].HeldObject != (Object)null) { sosig.Hands[j].HeldObject.O.RootRigidbody.isKinematic = true; } } for (int k = 0; k < sosig.Inventory.Slots.Count; k++) { sosig.Inventory.Slots[k].Target = muzzle; } sosig.CoreTarget.position = turretMuzzle.position; sosig.Pose_Standing = turretMuzzle; sosig.Pose_Crouching = turretMuzzle; sosig.Pose_Prone = turretMuzzle; sosig.m_targetPose = turretMuzzle; sosig.Agent.autoTraverseOffMeshLink = false; sosig.DoesDropWeaponsOnBallistic = false; for (int l = 0; l < aliveObjects.Length; l++) { if ((Object)(object)aliveObjects[l] != (Object)null) { aliveObjects[l].SetActive(true); } } for (int m = 0; m < deathObjects.Length; m++) { if ((Object)(object)deathObjects[m] != (Object)null) { deathObjects[m].SetActive(false); } } for (int n = 0; n < damagedObjects.Length; n++) { if ((Object)(object)damagedObjects[n] != (Object)null) { damagedObjects[n].SetActive(false); } } if (sosig.HeadIcons != null) { for (int num = 0; num < sosig.HeadIcons.Count; num++) { if ((Object)(object)sosig.HeadIcons[num] != (Object)null) { sosig.HeadIcons[num].transform.SetParent(sosigIconsPoint); sosig.HeadIcons[num].transform.position = sosigIconsPoint.position; sosig.HeadIcons[num].transform.localScale = sosigIconsPoint.localScale * 2f; } } } HideSosigWeapon(); for (int num2 = 0; num2 < sosig.Meshes.Length; num2++) { ((Renderer)((Component)sosig.Meshes[num2]).GetComponent<MeshRenderer>()).enabled = false; } for (int num3 = 0; num3 < sosig.Links.Count; num3++) { ((Component)sosig.Links[num3]).transform.localScale = Vector3.one * 0.01f; } } private void OnDisable() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(VehicleKillEvent); } protected virtual void VehicleKillEvent(Sosig s) { if (!((Object)(object)s == (Object)(object)sosig) || isDead || (Object)(object)sosig == (Object)null) { return; } if (sosig.m_linksDestroyed != null) { for (int i = 0; i < sosig.m_linksDestroyed.Length; i++) { sosig.m_linksDestroyed[i] = true; } } for (int j = 0; j < damagedObjects.Length; j++) { if ((Object)(object)dama