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 Sojourn Railgunner v1.0.0
SojournRailgunner.dll
Decompiled 21 hours 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 SojournRailgunner { 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 Texture2D ReadTexture(string name, bool mipmaps = true, TextureWrapMode wrap = (TextureWrapMode)1) { //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_0037: 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, mipmaps) { name = Path.GetFileNameWithoutExtension(name) }; ImageConversion.LoadImage(val, memoryStream.ToArray()); ((Texture)val).wrapMode = wrap; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; val.Apply(mipmaps, 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("_SpecularExponent", 4f); 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"); } val.SetFloat("_Cull", 2f); return val; } private static string ReadString(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32())); } } internal static class GunFit { public static readonly Vector3 LeftHandDelta = new Vector3(0.16133f, -0f, 0.08835f); } [DefaultExecutionOrder(10000)] public class SojournController : MonoBehaviour { private const float FullWeightDistance = 0.4f; private const float ZeroWeightDistance = 0.6f; internal static SkinDef skin; private Transform upper; private Transform lower; private Transform hand; private Transform grip; private Transform gunRoot; private ModelSkinController skins; private CharacterModel model; public float lastWeight = -1f; public float lastDistance = -1f; public bool lastActive; private Renderer[] lightRenderers = (Renderer[])(object)new Renderer[0]; private Light[] lights = (Light[])(object)new Light[0]; private bool lightsHidden; private bool solved; private Quaternion solvedLower; private Quaternion solvedUpper; private void Awake() { skins = ((Component)this).GetComponent<ModelSkinController>(); model = ((Component)this).GetComponent<CharacterModel>(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { switch (((Object)val).name) { case "upper_arm.l": upper = val; break; case "lower_arm.l": lower = val; break; case "hand.l": hand = val; break; case "GripIK.l": grip = val; break; case "GunRoot": gunRoot = val; break; } } List<Renderer> list = new List<Renderer>(); List<Light> list2 = new List<Light>(); componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "backpack") { list.AddRange(((Component)val2).GetComponentsInChildren<Renderer>(true)); list2.AddRange(((Component)val2).GetComponentsInChildren<Light>(true)); } else if (((Object)val2).name == "StatusLED, Rail" || (((Object)val2).name == "PowerLED, Barrel" && ((Object)val2.parent).name != "backpack")) { list.AddRange(((Component)val2).GetComponents<Renderer>()); list2.AddRange(((Component)val2).GetComponentsInChildren<Light>(true)); } } lightRenderers = list.ToArray(); lights = list2.ToArray(); } private void SetLights(bool on) { Renderer[] array = lightRenderers; foreach (Renderer val in array) { if (Object.op_Implicit((Object)(object)val)) { val.enabled = on; } } Light[] array2 = lights; foreach (Light val2 in array2) { if (Object.op_Implicit((Object)(object)val2)) { ((Behaviour)val2).enabled = on; } } lightsHidden = !on; } private bool SkinActive() { if (!Object.op_Implicit((Object)(object)skins) || !Object.op_Implicit((Object)(object)skin) || skins.skins == null) { return false; } int currentSkinIndex = skins.currentSkinIndex; if (currentSkinIndex >= 0 && currentSkinIndex < skins.skins.Length) { return (Object)(object)skins.skins[currentSkinIndex] == (Object)(object)skin; } if (Object.op_Implicit((Object)(object)model) && model.baseRendererInfos != null) { return Array.Exists(model.baseRendererInfos, delegate(RendererInfo r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Renderer renderer = r.renderer; SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); return val != null && Object.op_Implicit((Object)(object)val.sharedMesh) && ((Object)val.sharedMesh).name == "sj_body"; }); } return false; } private void LateUpdate() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) bool flag = SkinActive(); if (flag) { SetLights(on: false); } else if (lightsHidden) { SetLights(on: true); } lastActive = Object.op_Implicit((Object)(object)upper) && Object.op_Implicit((Object)(object)lower) && Object.op_Implicit((Object)(object)hand) && Object.op_Implicit((Object)(object)grip) && Object.op_Implicit((Object)(object)gunRoot) && flag; if (lastActive && (!solved || !(lower.localRotation == solvedLower) || !(upper.localRotation == solvedUpper))) { float num = (lastWeight = 1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.4f, 0.6f, lastDistance = Vector3.Distance(hand.position, grip.position)))); if (!(num <= 0f)) { Vector3 target = hand.position + num * gunRoot.TransformVector(GunFit.LeftHandDelta); Quaternion rotation = hand.rotation; Solve(target); hand.rotation = rotation; solved = true; solvedLower = lower.localRotation; solvedUpper = upper.localRotation; } } } private void Solve(Vector3 target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) Vector3 position = upper.position; Vector3 position2 = lower.position; Vector3 position3 = hand.position; Vector3 val = position2 - position; float magnitude = ((Vector3)(ref val)).magnitude; val = position3 - position2; float magnitude2 = ((Vector3)(ref val)).magnitude; Vector3 val2 = target - position; float num = Mathf.Clamp(((Vector3)(ref val2)).magnitude, Mathf.Abs(magnitude - magnitude2) + 0.001f, magnitude + magnitude2 - 0.001f); Vector3 val3 = Vector3.Cross(position2 - position, position3 - position2); if (((Vector3)(ref val3)).sqrMagnitude < 1E-08f) { val3 = Vector3.Cross(position2 - position, Vector3.up); } ((Vector3)(ref val3)).Normalize(); float num2 = Vector3.Angle(position - position2, position3 - position2); float num3 = Mathf.Acos(Mathf.Clamp((magnitude * magnitude + magnitude2 * magnitude2 - num * num) / (2f * magnitude * magnitude2), -1f, 1f)) * 57.29578f; lower.rotation = Quaternion.AngleAxis(num2 - num3, val3) * lower.rotation; upper.rotation = Quaternion.FromToRotation(hand.position - position, val2) * upper.rotation; } } [BepInPlugin("com.chaz.sojournrailgunner", "SojournRailgunner", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SojournRailgunnerPlugin : BaseUnityPlugin { public const string PluginGUID = "com.chaz.sojournrailgunner"; public const string PluginName = "SojournRailgunner"; public const string PluginVersion = "1.0.0"; private const string SkinNameToken = "CHAZ_SOJOURNRAILGUNNER_SKIN_NAME"; internal static ManualLogSource Log; private static readonly string[] Hidden = new string[5] { "mdlRailgunBackpackMesh", "mdlRailGunBackpackScreen", "RailGunnerArmature/ROOT/base/stomach/backpack/AllBackpackVFX Root", "RailGunnerArmature/ROOT/base/stomach/backpack/StatusLED, Backpack", "RailGunnerArmature/ROOT/base/stomach/backpack/PowerLED, Barrel" }; public static SkinDef Skin { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { LanguageAPI.Add("CHAZ_SOJOURNRAILGUNNER_SKIN_NAME", "Sojourn"); AddSkin(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to add Sojourn skin: " + ex)); } } private void AddSkin() { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) GameObject body = SojournRailgunnerPlugin.Load<GameObject>("RoR2/DLC1/Railgunner/RailgunnerBody.prefab"); GameObject gameObject = ((Component)body.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController component = gameObject.GetComponent<ModelSkinController>(); SkinnedMeshRenderer val = FindRenderer(gameObject, "mdlRailGunnerBase"); SkinnedMeshRenderer val2 = FindRenderer(gameObject, "mdlRailGunnerMetal"); SkinnedMeshRenderer val3 = FindRenderer(gameObject, "mdlRailgunProto"); Dictionary<string, Matrix4x4> bindposes = Assets.ReadBindposes("bindposes.bin"); Mesh mesh = Assets.ReadSkinnedMesh("sj_body.hkm", val, bindposes); Mesh mesh2 = Assets.ReadSkinnedMesh("sj_hair.hkm", val2, bindposes); Mesh mesh3 = Assets.ReadSkinnedMesh("sj_gun.hkm", val3, bindposes); Material template = SojournRailgunnerPlugin.Load<Material>("RoR2/DLC1/Railgunner/matRailGunnerBase.mat"); Material m = Assets.MakeMaterial(template, "matSojournBody", Assets.ReadTexture("sj_body.png", mipmaps: true, (TextureWrapMode)1), cutout: false); Material m2 = Assets.MakeMaterial(template, "matSojournHair", Assets.ReadTexture("sj_hair.png", mipmaps: true, (TextureWrapMode)1), cutout: true); Material val4 = Assets.MakeMaterial(template, "matSojournGun", Assets.ReadTexture("sj_gun.png", mipmaps: true, (TextureWrapMode)1), cutout: false); val4.SetTexture("_EmTex", (Texture)(object)Assets.ReadTexture("sj_gun_em.png", mipmaps: true, (TextureWrapMode)1)); val4.SetColor("_EmColor", new Color(0.3f, 0.9f, 1f)); val4.SetFloat("_EmPower", 2.5f); List<GameObjectActivation> list = new List<GameObjectActivation>(); string[] hidden = Hidden; foreach (string text in hidden) { Transform val5 = gameObject.transform.Find(text); if (Object.op_Implicit((Object)(object)val5)) { list.Add(new GameObjectActivation { gameObject = ((Component)val5).gameObject, shouldActivate = false }); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Not found, left as is: " + text)); } } Skin = Skins.CreateNewSkinDef(new SkinDefParamsInfo { Name = "skinRailGunnerSojourn", NameToken = "CHAZ_SOJOURNRAILGUNNER_SKIN_NAME", Icon = Skins.CreateSkinIcon(Color32.op_Implicit(new Color32((byte)196, (byte)182, (byte)150, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)232, (byte)232, (byte)232, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)200, (byte)32, (byte)30, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)90, (byte)220, byte.MaxValue, byte.MaxValue))), RootObject = gameObject, BaseSkins = (SkinDef[])(object)new SkinDef[1] { component.skins[0] }, RendererInfos = (RendererInfo[])(object)new RendererInfo[3] { RendererInfo((Renderer)(object)val, m), RendererInfo((Renderer)(object)val2, m2), RendererInfo((Renderer)(object)val3, val4) }, MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[3] { new MeshReplacement { renderer = (Renderer)(object)val, mesh = mesh }, new MeshReplacement { renderer = (Renderer)(object)val2, mesh = mesh2 }, new MeshReplacement { renderer = (Renderer)(object)val3, mesh = mesh3 } }, GameObjectActivations = list.ToArray(), ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>(), MinionSkinReplacements = Array.Empty<MinionSkinReplacement>() }); if (!Skins.AddSkinToCharacter(body, Skin)) { throw new Exception("R2API refused the skin"); } SojournController.skin = Skin; gameObject.AddComponent<SojournController>(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { GameObject val6 = SurvivorCatalog.FindSurvivorDefFromBody(body)?.displayPrefab; CharacterModel val7 = (Object.op_Implicit((Object)(object)val6) ? val6.GetComponentInChildren<CharacterModel>(true) : null); if (Object.op_Implicit((Object)(object)val7) && !Object.op_Implicit((Object)(object)((Component)val7).GetComponent<SojournController>())) { ((Component)val7).gameObject.AddComponent<SojournController>(); } }); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Added Sojourn skin to Railgunner"); } internal 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 }; } } }