Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Commando Skin Pack v0.1.0
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/ActionFigurePlaytest/ActionFigurePlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE5; [BepInPlugin("eclipseplaytest.commando.e5", "Action Figure Playtest", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ActionFigurePlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e5"; public const string Version = "0.1.1"; private static ActionFigurePlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(ActionFigurePlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E5_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E5_REGISTRATION_BEGIN async loader 0.1.1"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE5")) { throw new InvalidOperationException("Action Figure already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE5_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE5" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE5_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE5"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE5"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E5_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Action Figure (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E5_REGISTERED count=1 revision=004 unlocked=true version=0.1.1"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E5_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoActionFigurePlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/ClockworkInfantryPlaytest/ClockworkInfantryPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE4; [BepInPlugin("eclipseplaytest.commando.e4", "Clockwork Infantry Playtest", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ClockworkInfantryPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e4"; public const string Version = "0.1.1"; private static ClockworkInfantryPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(ClockworkInfantryPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E4_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E4_REGISTRATION_BEGIN async loader 0.1.1"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE4")) { throw new InvalidOperationException("Clockwork Infantry already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE4_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE4" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE4_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE4"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE4"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E4_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Clockwork Infantry (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E4_REGISTERED count=1 revision=002 unlocked=true version=0.1.1"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E4_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoClockworkInfantryPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/ExpeditionMarshalPlaytest/ExpeditionMarshalPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE3; [BepInPlugin("eclipseplaytest.commando.e3", "Expedition Marshal Playtest", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ExpeditionMarshalPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e3"; public const string Version = "0.1.2"; private static ExpeditionMarshalPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(ExpeditionMarshalPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E3_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E3_REGISTRATION_BEGIN async loader 0.1.2"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE3")) { throw new InvalidOperationException("Expedition Marshal already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE3_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE3" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE3_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE3"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE3"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E3_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Expedition Marshal (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E3_REGISTERED count=1 revision=004 unlocked=true version=0.1.2"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E3_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoExpeditionMarshalPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/ExtinctionProtocolPlaytest/ExtinctionProtocolPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE8; [BepInPlugin("eclipseplaytest.commando.e8", "Extinction Protocol Playtest", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ExtinctionProtocolPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e8"; public const string Version = "0.1.2"; private static ExtinctionProtocolPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(ExtinctionProtocolPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E8_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E8_REGISTRATION_BEGIN async loader 0.1.2"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE8")) { throw new InvalidOperationException("Extinction Protocol already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE8_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE8" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE8_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE8"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE8"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E8_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Extinction Protocol (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E8_REGISTERED count=1 revision=004 unlocked=true version=0.1.2"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E8_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoExtinctionProtocolPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/FrontierRecruitPlaytest/FrontierRecruitPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE1; [BepInPlugin("eclipseplaytest.commando.e1", "Frontier Recruit Playtest", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FrontierRecruitPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e1"; public const string Version = "0.1.1"; private static FrontierRecruitPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(FrontierRecruitPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E1_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E1_REGISTRATION_BEGIN async loader 0.1.1"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE1")) { throw new InvalidOperationException("Frontier Recruit already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE1_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE1" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE1_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE1"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE1"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E1_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Frontier Recruit (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E1_REGISTERED count=1 revision=007 unlocked=true version=0.1.1"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E1_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoFrontierRecruitPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/OneManBandPlaytest/OneManBandPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE7; [BepInPlugin("eclipseplaytest.commando.e7", "One-Man Band Playtest", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class OneManBandPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e7"; public const string Version = "0.1.2"; private static OneManBandPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(OneManBandPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E7_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E7_REGISTRATION_BEGIN async loader 0.1.2"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE7")) { throw new InvalidOperationException("One-Man Band already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE7_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE7" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE7_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE7"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE7"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E7_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - One-Man Band (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E7_REGISTERED count=1 revision=004 unlocked=true version=0.1.2"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E7_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoOneManBandPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/QuartermasterPlaytest/QuartermasterPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE6; [BepInPlugin("eclipseplaytest.commando.e6", "Quartermaster Playtest", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class QuartermasterPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e6"; public const string Version = "0.1.2"; private static QuartermasterPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(QuartermasterPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E6_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E6_REGISTRATION_BEGIN async loader 0.1.2"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE6")) { throw new InvalidOperationException("Quartermaster already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE6_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE6" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE6_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE6"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE6"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E6_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Quartermaster (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E6_REGISTERED count=1 revision=003 unlocked=true version=0.1.2"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E6_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoQuartermasterPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }
BepInEx/plugins/Local-Eclipse_Commando_Skins_Playtest/VacuumBreacherPlaytest/VacuumBreacherPlaytest.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using HG.Reflection; using R2API; using R2API.Utils; using RoR2; using RoR2.UI.MainMenu; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: AssemblyVersion("0.0.0.0")] namespace EclipsePlaytestCommandoE2; [BepInPlugin("eclipseplaytest.commando.e2", "Vacuum Breacher Playtest", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class VacuumBreacherPlaytest : BaseUnityPlugin { public const string Guid = "eclipseplaytest.commando.e2"; public const string Version = "0.1.1"; private static VacuumBreacherPlaytest instance; private readonly List<AsyncOperationHandle> retainedAssets = new List<AsyncOperationHandle>(); private float registrationDeadline; private string folder; private SkinDef skin; private Mesh mesh; private Material material; private GameObject modelPrefab; private int rendererIndex; private bool registered; private void Awake() { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); instance = this; SystemInitializerInjector.InjectDependency(typeof(SkinCatalog), typeof(VacuumBreacherPlaytest)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SyncDisplaySkins)); MainMenuController.OnMainMenuInitialised += SyncDisplaySkins; } [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static IEnumerator InitializeSkin() { if (!Object.op_Implicit((Object)(object)instance)) { yield break; } instance.registrationDeadline = Time.realtimeSinceStartup + 45f; IEnumerator routine = instance.RegisterAsync(); while (true) { bool flag; try { flag = routine.MoveNext(); } catch (Exception ex) { ((BaseUnityPlugin)instance).Logger.LogError((object)("ECLIPSEPLAYTEST_COMMANDO_E2_REGISTRATION_FAILED: " + ex)); break; } if (!flag) { break; } yield return null; } (routine as IDisposable)?.Dispose(); } private IEnumerator RegisterAsync() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E2_REGISTRATION_BEGIN async loader 0.1.1"); GameObject val = BodyCatalog.FindBodyPrefab("CommandoBody"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("CommandoBody is missing."); } modelPrefab = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController controller = modelPrefab.GetComponent<ModelSkinController>(); SkinDef baseSkin = controller.skins[0]; SkinDefParams baseParams = baseSkin.skinDefParams; if (!Object.op_Implicit((Object)(object)baseParams) && baseSkin.skinDefParamsAddress != null && ((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKeyIsValid()) { AsyncOperationHandle<SkinDefParams> load = Addressables.LoadAssetAsync<SkinDefParams>(((AssetReference)baseSkin.skinDefParamsAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<SkinDefParams>.op_Implicit(load)); while (!load.IsDone) { CheckLoadDeadline("skin parameters"); yield return null; } baseParams = load.Result; } if (!Object.op_Implicit((Object)(object)baseParams)) { throw new InvalidOperationException("Commando's base skin parameters are unavailable."); } SkinnedMeshRenderer[] componentsInChildren = modelPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer target = componentsInChildren.First((SkinnedMeshRenderer r) => r.bones.Length == 78 && r.bones.Any((Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == "head")); rendererIndex = Array.IndexOf(componentsInChildren, target); Mesh referenceMesh = target.sharedMesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { MeshReplacement val2 = baseParams.meshReplacements.First((MeshReplacement r) => (Object)(object)r.renderer == (Object)(object)target); referenceMesh = val2.mesh; if (!Object.op_Implicit((Object)(object)referenceMesh)) { AsyncOperationHandle<Mesh> load2 = Addressables.LoadAssetAsync<Mesh>(((AssetReference)val2.meshAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Mesh>.op_Implicit(load2)); while (!load2.IsDone) { CheckLoadDeadline("reference mesh"); yield return null; } referenceMesh = load2.Result; } } if (!Object.op_Implicit((Object)(object)referenceMesh) || referenceMesh.bindposes.Length != target.bones.Length) { throw new InvalidOperationException("The installed Commando bind pose does not match the renderer."); } RendererInfo originalInfo = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)target); Material val3 = originalInfo.defaultMaterial; if (!Object.op_Implicit((Object)(object)val3) && originalInfo.defaultMaterialAddress != null) { AsyncOperationHandle<Material> load3 = Addressables.LoadAssetAsync<Material>(((AssetReference)originalInfo.defaultMaterialAddress).RuntimeKey); retainedAssets.Add(AsyncOperationHandle<Material>.op_Implicit(load3)); while (!load3.IsDone) { CheckLoadDeadline("material"); yield return null; } val3 = load3.Result; } if (!Object.op_Implicit((Object)(object)val3)) { val3 = ((Renderer)target).sharedMaterial; } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.shader)) { throw new InvalidOperationException("Commando's game shader is unavailable."); } if (controller.skins.Any((SkinDef s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name == "skinEclipsePlaytestCommandoE2")) { throw new InvalidOperationException("Vacuum Breacher already registered."); } mesh = ReadMesh(Path.Combine(folder, "assets", "body.meshbin"), target, referenceMesh); ((Object)mesh).name = "EclipsePlaytestCommandoE2_Body"; material = new Material(val3) { name = "matEclipsePlaytestCommandoE2" }; material.SetTexture("_MainTex", (Texture)(object)ReadTexture("assets/albedo-spec.png", linear: false)); material.SetTexture("_NormalTex", (Texture)(object)ReadTexture("assets/normal.png", linear: true)); material.SetColor("_Color", Color.white); material.SetFloat("_NormalStrength", 0.5f); material.SetFloat("_Smoothness", 0.28f); material.SetFloat("_SpecularStrength", 0.5f); material.SetFloat("_SpecularExponent", 8f); material.SetFloat("_EmPower", 0f); material.SetTexture("_EmTex", (Texture)(object)Texture2D.blackTexture); material.DisableKeyword("LIMBREMOVAL"); material.SetFloat("_LimbRemovalOn", 0f); List<RendererInfo> list = new List<RendererInfo>(); List<MeshReplacement> list2 = new List<MeshReplacement>(); RendererInfo item = originalInfo; item.defaultMaterial = material; item.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item); list2.Add(new MeshReplacement { renderer = (Renderer)(object)target, mesh = mesh, meshAddress = new AssetReferenceT<Mesh>("") }); string[] array = new string[2] { "l", "r" }; foreach (string side in array) { MeshRenderer gun = modelPrefab.GetComponentsInChildren<MeshRenderer>(true).Single((MeshRenderer r) => Object.op_Implicit((Object)(object)((Component)r).transform.parent) && ((Object)((Component)r).transform.parent).name == "gun." + side); if (!Object.op_Implicit((Object)(object)((Component)gun).GetComponent<MeshFilter>())) { throw new InvalidOperationException("Native pistol MeshFilter missing."); } Mesh val4 = ReadMesh(Path.Combine(folder, "assets", "pistol-" + side + ".meshbin"), target, referenceMesh); ((Object)val4).name = "EclipsePlaytestCommandoE2_Pistol_" + side; RendererInfo item2 = baseParams.rendererInfos.First((RendererInfo r) => (Object)(object)r.renderer == (Object)(object)gun); item2.defaultMaterial = material; item2.defaultMaterialAddress = new AssetReferenceT<Material>(""); list.Add(item2); list2.Add(new MeshReplacement { renderer = (Renderer)(object)gun, mesh = val4, meshAddress = new AssetReferenceT<Mesh>("") }); } SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>(); ((Object)val5).name = "paramsEclipsePlaytestCommandoE2"; val5.rendererInfos = list.ToArray(); val5.meshReplacements = list2.ToArray(); skin = ScriptableObject.CreateInstance<SkinDef>(); ((Object)skin).name = "skinEclipsePlaytestCommandoE2"; skin.nameToken = "ECLIPSEPLAYTEST_COMMANDO_E2_NAME"; LanguageAPI.Add(skin.nameToken, "Commando - Vacuum Breacher (Playtest)"); skin.icon = CreateIcon((Color32[])(object)new Color32[4] { new Color32((byte)187, (byte)154, (byte)100, byte.MaxValue), new Color32((byte)58, (byte)66, (byte)65, byte.MaxValue), new Color32((byte)202, (byte)175, (byte)126, byte.MaxValue), new Color32((byte)40, (byte)45, (byte)49, byte.MaxValue) }); skin.unlockableDef = null; skin.rootObject = modelPrefab; skin.baseSkins = (SkinDef[])(object)new SkinDef[1] { baseSkin }; skin.skinDefParams = val5; controller.skins = controller.skins.Concat((IEnumerable<SkinDef>)(object)new SkinDef[1] { skin }).ToArray(); registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"ECLIPSEPLAYTEST_COMMANDO_E2_REGISTERED count=1 revision=003 unlocked=true version=0.1.1"); } private static Sprite CreateIcon(Color32[] colors) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = ((i > j) ? ((i <= 63 - j) ? 1 : 0) : ((i > 63 - j) ? 2 : 3)); array[i * 64 + j] = (Color32)((j < 2 || j > 61 || i < 2 || i > 61 || Math.Abs(i - j) < 2 || Math.Abs(i - (63 - j)) < 2) ? new Color32((byte)48, (byte)48, (byte)48, byte.MaxValue) : colors[num]); } } val.SetPixels32(array); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); } private void CheckLoadDeadline(string asset) { if (Time.realtimeSinceStartup > registrationDeadline) { throw new TimeoutException("Stopped loading " + asset + "; continuing startup without the skin."); } } private void SyncDisplaySkins() { if (!registered) { return; } SurvivorDef val = SurvivorCatalog.allSurvivorDefs.FirstOrDefault((Func<SurvivorDef, bool>)((SurvivorDef s) => Object.op_Implicit((Object)(object)s) && Object.op_Implicit((Object)(object)s.bodyPrefab) && ((Object)s.bodyPrefab).name == "CommandoBody")); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.displayPrefab)) { CharacterModel componentInChildren = val.displayPrefab.GetComponentInChildren<CharacterModel>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ModelSkinController val2 = ((Component)componentInChildren).GetComponent<ModelSkinController>() ?? ((Component)componentInChildren).gameObject.AddComponent<ModelSkinController>(); val2.skins = (SkinDef[])modelPrefab.GetComponent<ModelSkinController>().skins.Clone(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("ECLIPSEPLAYTEST_COMMANDO_E2_DISPLAY_READY skins=" + val2.skins.Length)); } } } private Texture2D ReadTexture(string name, bool linear) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, linear) { name = name, anisoLevel = 4, filterMode = (FilterMode)2 }; if (!ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(folder, name)), false)) { throw new InvalidDataException("Cannot decode " + name); } return val; } private Mesh ReadMesh(string path, SkinnedMeshRenderer renderer, Mesh reference) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path)); if (new string(binaryReader.ReadChars(4)) != "PWE1") { throw new InvalidDataException("Invalid mesh signature."); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); if (num < 3 || num > 200000 || num2 < 3 || num2 > 1200000 || num2 % 3 != 0 || num3 != 78) { throw new InvalidDataException("Invalid mesh dimensions."); } int[] array = new int[num3]; for (int i = 0; i < num3; i++) { int num4 = binaryReader.ReadInt32(); if (num4 < 1 || num4 > 128) { throw new InvalidDataException("Invalid bone name."); } string name = Encoding.UTF8.GetString(binaryReader.ReadBytes(num4)); array[i] = Array.FindIndex(renderer.bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == name); if (array[i] < 0) { throw new InvalidDataException("Missing reference bone: " + name); } } Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num]; for (int num5 = 0; num5 < num; num5++) { array2[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[num5] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array4[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); int[] array6 = new int[4]; for (int num6 = 0; num6 < 4; num6++) { int num7 = binaryReader.ReadInt32(); if (num7 < 0 || num7 >= num3) { throw new InvalidDataException("Bone out of range."); } array6[num6] = array[num7]; } float[] array7 = new float[4]; for (int num8 = 0; num8 < 4; num8++) { array7[num8] = binaryReader.ReadSingle(); } if (array7.Any((float n) => float.IsNaN(n) || float.IsInfinity(n) || n < 0f) || Math.Abs(array7.Sum() - 1f) > 0.002f) { throw new InvalidDataException("Invalid skin weight."); } if (!Finite(array2[num5]) || !Finite(array3[num5])) { throw new InvalidDataException("Non-finite vertex."); } int num9 = num5; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[0]; ((BoneWeight)(ref val)).boneIndex1 = array6[1]; ((BoneWeight)(ref val)).boneIndex2 = array6[2]; ((BoneWeight)(ref val)).boneIndex3 = array6[3]; ((BoneWeight)(ref val)).weight0 = array7[0]; ((BoneWeight)(ref val)).weight1 = array7[1]; ((BoneWeight)(ref val)).weight2 = array7[2]; ((BoneWeight)(ref val)).weight3 = array7[3]; array5[num9] = val; } int[] array8 = new int[num2]; for (int num10 = 0; num10 < num2; num10++) { array8[num10] = binaryReader.ReadInt32(); if (array8[num10] < 0 || array8[num10] >= num) { throw new InvalidDataException("Triangle out of range."); } } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException("Unexpected trailing mesh data."); } Mesh val2 = new Mesh { name = "CommandoVacuumBreacherPlaytest", indexFormat = (IndexFormat)(num > 65535), vertices = array2, normals = array3, uv = array4, boneWeights = array5, bindposes = reference.bindposes, triangles = array8 }; val2.RecalculateBounds(); val2.RecalculateTangents(); return val2; } private static bool Finite(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x + v.y + v.z)) { return !float.IsInfinity(v.x + v.y + v.z); } return false; } }