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 Zenyatta Seeker v1.0.0
ZenyattaSeeker.dll
Decompiled a day agousing System; 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 BepInEx.Logging; using Microsoft.CodeAnalysis; using R2API; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ZenyattaSeeker { internal static class OrbGhost { private class Spinner : MonoBehaviour { private void Update() { ((Component)this).transform.Rotate(220f * Time.deltaTime, 130f * Time.deltaTime, 0f, (Space)1); } } private const float PunchOrbSize = 2.4f; private const float FinisherOrbSize = 2.6f; public static GameObject CreatePunch(GameObject original, Mesh orb, Material material) { GameObject obj = PrefabAPI.InstantiateClone(original, "ZenyattaOrbPunchGhost", false); Transform val = obj.transform.Find("SeekerPrimaryWave"); MeshRenderer val2 = default(MeshRenderer); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<MeshRenderer>(ref val2)) { ((Renderer)val2).enabled = false; } AddOrb(obj.transform, orb, material, 2.4f); return obj; } public static GameObject CreateFinisher(GameObject original, Mesh orb, Material material) { GameObject obj = PrefabAPI.InstantiateClone(original, "ZenyattaOrbFinisherGhost", false); Transform val = obj.transform.Find("Sphere Fresnel/Sphere"); ParticleSystemRenderer val2 = default(ParticleSystemRenderer); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<ParticleSystemRenderer>(ref val2)) { ((Renderer)val2).enabled = false; } AddOrb(obj.transform, orb, material, 2.6f); return obj; } private static void AddOrb(Transform parent, Mesh orb, Material material, float size) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ZenyattaOrb"); val.transform.SetParent(parent, false); val.transform.localScale = Vector3.one * size; val.AddComponent<MeshFilter>().sharedMesh = orb; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; val.AddComponent<Spinner>(); } } [BepInPlugin("com.chaz.zenyattaseeker", "ZenyattaSeeker", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ZenyattaSeekerPlugin : BaseUnityPlugin { public const string PluginGUID = "com.chaz.zenyattaseeker"; public const string PluginName = "ZenyattaSeeker"; public const string PluginVersion = "1.0.0"; private const string SkinNameToken = "CHAZ_ZENYATTASEEKER_SKIN_NAME"; internal static ManualLogSource Log; public static SkinDef Skin { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { LanguageAPI.Add("CHAZ_ZENYATTASEEKER_SKIN_NAME", "Zenyatta"); AddSkin(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to add Zenyatta skin: " + ex)); } } private void AddSkin() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0365: 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_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0394: 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_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) GameObject val = Load<GameObject>("RoR2/DLC2/Seeker/SeekerBody.prefab"); GameObject gameObject = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController component = gameObject.GetComponent<ModelSkinController>(); SkinnedMeshRenderer val2 = FindRenderer(gameObject, "meshSeekerBody"); SkinnedMeshRenderer val3 = FindRenderer(gameObject, "meshSeekerCloth"); SkinnedMeshRenderer val4 = FindRenderer(gameObject, "meshSeekerGlass"); Dictionary<string, Matrix4x4> bindposes = Assets.ReadBindposes("bindposes.bin"); Mesh mesh = Assets.ReadSkinnedMesh("zen_body.hkm", val2, bindposes); Mesh mesh2 = Assets.ReadSkinnedMesh("zen_head.hkm", val3, bindposes); Mesh mesh3 = Assets.ReadSkinnedMesh("zen_orbs.hkm", val4, bindposes); Mesh orb = Assets.ReadStaticMesh("zen_orb.hkm"); Material template = Load<Material>("RoR2/DLC2/Seeker/matSeeker.mat"); Material m = Assets.MakeMaterial(template, "matZenyattaBody", Assets.ReadTexture("zen_body.png"), cutout: true); Material val5 = Assets.MakeMaterial(template, "matZenyattaHead", Assets.ReadTexture("zen_head.png"), cutout: true); val5.SetTexture("_EmTex", (Texture)(object)Assets.ReadTexture("zen_head_emission.png")); val5.SetColor("_EmColor", new Color(0.45f, 0.85f, 1f)); val5.SetFloat("_EmPower", 3f); Material val6 = Assets.MakeMaterial(template, "matZenyattaOrb", Assets.ReadTexture("zen_orb.png"), cutout: false); val6.SetTexture("_EmTex", (Texture)(object)Assets.ReadTexture("zen_orb_emission.png")); val6.SetColor("_EmColor", new Color(1f, 0.85f, 0.45f)); val6.SetFloat("_EmPower", 2f); List<ProjectileGhostReplacement> list = new List<ProjectileGhostReplacement>(); (string, string, bool)[] array = new(string, string, bool)[2] { ("SpiritPunchProjectile", "SpiritPunchGhost", false), ("SpiritPunchFinisherProjectile", "SpiritPunchFinisherGhost", true) }; for (int i = 0; i < array.Length; i++) { var (text, text2, flag) = array[i]; try { GameObject projectilePrefab = Load<GameObject>("RoR2/DLC2/Seeker/" + text + ".prefab"); GameObject original = Load<GameObject>("RoR2/DLC2/Seeker/" + text2 + ".prefab"); list.Add(new ProjectileGhostReplacement { projectilePrefab = projectilePrefab, projectileGhostReplacementPrefab = (flag ? OrbGhost.CreateFinisher(original, orb, val6) : OrbGhost.CreatePunch(original, orb, val6)) }); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("No orb for " + text + ": " + ex.Message)); } } Skin = Skins.CreateNewSkinDef(new SkinDefParamsInfo { Name = "skinSeekerZenyatta", NameToken = "CHAZ_ZENYATTASEEKER_SKIN_NAME", Icon = Skins.CreateSkinIcon(Color32.op_Implicit(new Color32((byte)232, (byte)184, (byte)60, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)214, (byte)214, (byte)206, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)176, (byte)128, (byte)36, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)150, (byte)40, (byte)36, byte.MaxValue))), RootObject = gameObject, BaseSkins = (SkinDef[])(object)new SkinDef[1] { component.skins[0] }, RendererInfos = (RendererInfo[])(object)new RendererInfo[3] { RendererInfo((Renderer)(object)val2, m), RendererInfo((Renderer)(object)val3, val5), RendererInfo((Renderer)(object)val4, val6) }, MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[3] { new MeshReplacement { renderer = (Renderer)(object)val2, mesh = mesh }, new MeshReplacement { renderer = (Renderer)(object)val3, mesh = mesh2 }, new MeshReplacement { renderer = (Renderer)(object)val4, mesh = mesh3 } }, ProjectileGhostReplacements = list.ToArray(), GameObjectActivations = Array.Empty<GameObjectActivation>(), MinionSkinReplacements = Array.Empty<MinionSkinReplacement>() }); if (!Skins.AddSkinToCharacter(val, Skin)) { throw new Exception("R2API refused the skin"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Added Zenyatta skin to Seeker"); } private static T Load<T>(string key) where T : Object { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) T val = Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion(); if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("Missing addressable " + key); } return val; } private static SkinnedMeshRenderer FindRenderer(GameObject model, string path) { Transform val = model.transform.Find(path); SkinnedMeshRenderer obj = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<SkinnedMeshRenderer>() : null); if (!Object.op_Implicit((Object)(object)obj)) { throw new Exception("Renderer not found: " + path); } return obj; } private static RendererInfo RendererInfo(Renderer r, Material m) { //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) return new RendererInfo { renderer = r, defaultMaterial = m, defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false }; } } internal static class Assets { private static Stream Open(string name) { return typeof(Assets).Assembly.GetManifestResourceStream(name) ?? throw new FileNotFoundException("Embedded resource missing: " + name); } public static Dictionary<string, Matrix4x4> ReadBindposes(string name) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(Open(name)); Dictionary<string, Matrix4x4> dictionary = new Dictionary<string, Matrix4x4>(); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string key = ReadString(binaryReader); Matrix4x4 value = default(Matrix4x4); for (int j = 0; j < 16; j++) { ((Matrix4x4)(ref value))[j / 4, j % 4] = binaryReader.ReadSingle(); } dictionary[key] = value; } return dictionary; } public static Mesh ReadSkinnedMesh(string name, SkinnedMeshRenderer target, Dictionary<string, Matrix4x4> bindposes) { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(Open(name)); if (new string(binaryReader.ReadChars(4)) != "HKM1") { throw new InvalidDataException(name); } int num = binaryReader.ReadInt32(); string[] array = new string[num]; for (int i = 0; i < num; i++) { array[i] = ReadString(binaryReader); } Transform[] bones = target.bones; Dictionary<string, int> byName = new Dictionary<string, int>(); for (int j = 0; j < bones.Length; j++) { if (Object.op_Implicit((Object)(object)bones[j]) && !byName.ContainsKey(((Object)bones[j]).name)) { byName[((Object)bones[j]).name] = j; } } Matrix4x4 value; int[] array2 = array.Select(delegate(string b) { if (!byName.TryGetValue(b, out value)) { throw new Exception(name + ": bone " + b + " not on " + ((Object)target).name); } return value; }).ToArray(); int num2 = binaryReader.ReadInt32(); Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector3[] array4 = (Vector3[])(object)new Vector3[num2]; Vector2[] array5 = (Vector2[])(object)new Vector2[num2]; for (int num3 = 0; num3 < num2; num3++) { array3[num3] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int num4 = 0; num4 < num2; num4++) { array4[num4] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int num5 = 0; num5 < num2; num5++) { array5[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array6 = new int[num2 * 4]; for (int num6 = 0; num6 < array6.Length; num6++) { array6[num6] = array2[binaryReader.ReadInt32()]; } BoneWeight[] array7 = (BoneWeight[])(object)new BoneWeight[num2]; for (int num7 = 0; num7 < num2; num7++) { float weight = binaryReader.ReadSingle(); float weight2 = binaryReader.ReadSingle(); float weight3 = binaryReader.ReadSingle(); float weight4 = binaryReader.ReadSingle(); int num8 = num7; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[num7 * 4]; ((BoneWeight)(ref val)).boneIndex1 = array6[num7 * 4 + 1]; ((BoneWeight)(ref val)).boneIndex2 = array6[num7 * 4 + 2]; ((BoneWeight)(ref val)).boneIndex3 = array6[num7 * 4 + 3]; ((BoneWeight)(ref val)).weight0 = weight; ((BoneWeight)(ref val)).weight1 = weight2; ((BoneWeight)(ref val)).weight2 = weight3; ((BoneWeight)(ref val)).weight3 = weight4; array7[num8] = val; } int num9 = binaryReader.ReadInt32(); int[] array8 = new int[num9]; for (int num10 = 0; num10 < num9; num10++) { array8[num10] = binaryReader.ReadInt32(); } Mesh val2 = new Mesh { name = Path.GetFileNameWithoutExtension(name) }; if (num2 > 65535) { val2.indexFormat = (IndexFormat)1; } val2.vertices = array3; val2.normals = array4; val2.uv = array5; val2.SetIndices(array8, (MeshTopology)0, 0); val2.boneWeights = array7; val2.bindposes = bones.Select((Transform b) => (!Object.op_Implicit((Object)(object)b) || !bindposes.TryGetValue(((Object)b).name, out value)) ? Matrix4x4.identity : value).ToArray(); val2.RecalculateTangents(); val2.RecalculateBounds(); return val2; } public static Mesh ReadStaticMesh(string name) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(Open(name)); if (new string(binaryReader.ReadChars(4)) != "HKM1") { throw new InvalidDataException(name); } int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { ReadString(binaryReader); } int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int k = 0; k < num2; k++) { array2[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int l = 0; l < num2; l++) { array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } binaryReader.BaseStream.Seek(num2 * 32, SeekOrigin.Current); int num3 = binaryReader.ReadInt32(); int[] array4 = new int[num3]; for (int m = 0; m < num3; m++) { array4[m] = binaryReader.ReadInt32(); } Mesh val = new Mesh { name = Path.GetFileNameWithoutExtension(name), vertices = array, normals = array2, uv = array3 }; val.SetIndices(array4, (MeshTopology)0, 0); val.RecalculateTangents(); val.RecalculateBounds(); return val; } public static Texture2D ReadTexture(string name) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown using Stream stream = Open(name); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(name) }; ImageConversion.LoadImage(val, memoryStream.ToArray()); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; val.Apply(true, true); return val; } public static Material MakeMaterial(Material template, string name, Texture2D tex, bool cutout) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(template) { name = name }; val.SetTexture("_MainTex", (Texture)(object)tex); val.SetColor("_Color", Color.white); val.SetTexture("_NormalTex", (Texture)null); val.SetFloat("_NormalStrength", 0f); val.SetColor("_EmColor", Color.black); val.SetTexture("_EmTex", (Texture)null); val.SetFloat("_EmPower", 0f); val.SetFloat("_SpecularStrength", 0.25f); val.SetFloat("_FlowmapOn", 0f); val.DisableKeyword("FLOWMAP"); val.SetFloat("_FEON", 0f); val.DisableKeyword("FRESNEL_EMISSION"); val.SetFloat("_LimbRemovalOn", 0f); val.DisableKeyword("LIMBREMOVAL"); val.SetFloat("_EnableCutout", cutout ? 1f : 0f); if (cutout) { val.EnableKeyword("CUTOUT"); } else { val.DisableKeyword("CUTOUT"); } return val; } private static string ReadString(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32())); } } }