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 Brigitte Enforcer v1.0.0
BrigitteEnforcer.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 EntityStates; using EntityStates.Enforcer; using HarmonyLib; 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 BrigitteEnforcer { public class Barrier : MonoBehaviour { private static Texture2D fieldTex; private static Texture2D maskTex; private static Texture2D cellsTex; private static Texture2D rippleTex; private static Texture2D rampTex; private static Mesh rippleMesh; private static Material fieldTemplate; public static readonly Color Tint = new Color(0.55f, 0.85f, 1f, 1f); private const float CellsBoost = 0.45f; private const float CellsAlpha = 0.45f; private const float DeployTime = 0.18f; private const float RetractTime = 0.14f; private const float RippleTime = 0.45f; private const float FlashTime = 0.3f; private Material field; private Material cells; private Material rippleMat; private Renderer[] renderers; private float open; private float flash; private float width; private float height; private float bulge; private readonly List<(Transform t, Material m, float age)> ripples = new List<(Transform, Material, float)>(); public bool Visible => open > 0.001f; private static void LoadShared() { if (!Object.op_Implicit((Object)(object)fieldTemplate)) { fieldTex = Assets.ReadTexture("barrier.png", mipmaps: true, (TextureWrapMode)1); maskTex = Assets.ReadTexture("barrier_mask.png", mipmaps: true, (TextureWrapMode)1); cellsTex = Assets.ReadTexture("barrier_cells.png", mipmaps: true, (TextureWrapMode)0); rippleTex = Assets.ReadTexture("barrier_ripple.png", mipmaps: true, (TextureWrapMode)1); rampTex = Assets.ReadTexture("barrier_ramp.png", mipmaps: false, (TextureWrapMode)1); fieldTemplate = BrigitteEnforcerPlugin.Load<Material>("RoR2/DLC4/Enforcer/matEnfShieldInside.mat"); rippleMesh = Quad(); } } public static Barrier Create(string name, float w, float h, float b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) LoadShared(); GameObject val = new GameObject(name); Barrier barrier = val.AddComponent<Barrier>(); barrier.width = w; barrier.height = h; barrier.bulge = b; Mesh mesh = Panel(w, h, b); barrier.field = FxMaterial("matBrigitteBarrier", (Texture)(object)fieldTex, 1.2f); barrier.cells = FxMaterial("matBrigitteBarrierCells", (Texture)(object)maskTex, 0.45f); barrier.cells.EnableKeyword("USE_CLOUDS"); barrier.cells.SetFloat("_CloudsOn", 1f); barrier.cells.SetTexture("_Cloud1Tex", (Texture)(object)cellsTex); barrier.cells.SetTextureScale("_Cloud1Tex", new Vector2(w / 0.42f, h / 0.48f)); barrier.cells.SetTexture("_Cloud2Tex", (Texture)(object)cellsTex); barrier.cells.SetTextureScale("_Cloud2Tex", new Vector2(w / 0.9f, h / 1f)); barrier.cells.SetVector("_CutoffScroll", new Vector4(0.06f, 0.11f, -0.04f, 0f)); barrier.cells.SetFloat("_AlphaBoost", 0.45f); barrier.rippleMat = FxMaterial("matBrigitteBarrierRipple", (Texture)(object)rippleTex, 2.2f); barrier.renderers = (Renderer[])(object)new Renderer[2] { Layer(val.transform, "Field", mesh, barrier.field), Layer(val.transform, "Cells", mesh, barrier.cells) }; barrier.Apply(); return barrier; } private static Renderer Layer(Transform parent, string name, Mesh mesh, Material mat) { //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_0013: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; return (Renderer)(object)obj; } private static Material FxMaterial(string name, Texture tex, float boost) { //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_0012: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(fieldTemplate) { name = name }; string[] array = new string[4] { "USE_CLOUDS", "VERTEXOFFSET", "CUTOUT", "PRINT_CUTOFF" }; foreach (string text in array) { val.DisableKeyword(text); } val.SetFloat("_CloudsOn", 0f); val.SetFloat("_VertexOffsetOn", 0f); val.SetTexture("_MainTex", tex); val.SetTexture("_RemapTex", (Texture)(object)rampTex); val.SetColor("_TintColor", Tint); val.SetFloat("_Boost", boost); val.SetFloat("_AlphaBoost", 1f); val.SetFloat("_AlphaBias", 0f); val.SetFloat("_DistortionStrength", 0f); val.SetFloat("_FresnelPower", 0f); val.SetFloat("_Cull", 0f); val.SetFloat("_ExternalAlpha", 1f); return val; } private static Mesh Panel(float w, float h, float b) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_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_014c: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0171: Expected O, but got Unknown List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<Vector3> list3 = new List<Vector3>(); List<int> list4 = new List<int>(); for (int i = 0; i <= 6; i++) { for (int j = 0; j <= 24; j++) { float num = (float)j / 24f; float num2 = (float)i / 6f; float num3 = (num - 0.5f) * w; float num4 = 2f * num3 / w; list.Add(new Vector3(num3, (num2 - 0.5f) * h, b * (1f - num4 * num4))); Vector3 val = new Vector3(4f * b * num3 / (w * w) * 2f, 0f, 1f); list3.Add(((Vector3)(ref val)).normalized); list2.Add(new Vector2(num, num2)); } } for (int k = 0; k < 6; k++) { for (int l = 0; l < 24; l++) { int num5 = k * 25 + l; int num6 = num5 + 24 + 1; list4.AddRange(new int[6] { num5, num6, num5 + 1, num5 + 1, num6, num6 + 1 }); } } Mesh val2 = new Mesh { name = "BrigitteBarrier" }; val2.SetVertices(list); val2.SetNormals(list3); val2.SetUVs(0, list2); val2.SetTriangles(list4, 0); val2.RecalculateBounds(); return val2; } private static Mesh Quad() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh { name = "BrigitteBarrierRipple" }; val.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(-0.5f, 0.5f), new Vector3(0.5f, 0.5f) }; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }; val.normals = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; val.triangles = new int[6] { 0, 2, 1, 1, 2, 3 }; val.RecalculateBounds(); return val; } public void Tick(bool up, float dt) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) open = Mathf.MoveTowards(open, up ? 1f : 0f, dt / (up ? 0.18f : 0.14f)); flash = Mathf.Max(0f, flash - dt / 0.3f); for (int num = ripples.Count - 1; num >= 0; num--) { (Transform t, Material m, float age) tuple = ripples[num]; Transform item = tuple.t; Material item2 = tuple.m; float item3 = tuple.age; item3 += dt; if (item3 >= 0.45f || !Visible) { Object.Destroy((Object)(object)((Component)item).gameObject); Object.Destroy((Object)(object)item2); ripples.RemoveAt(num); } else { float num2 = item3 / 0.45f; item.localScale = Vector3.one * Mathf.Lerp(0.25f, 1.3f, 1f - (1f - num2) * (1f - num2)); item2.SetFloat("_ExternalAlpha", 1f - num2); ripples[num] = (item, item2, item3); } } Apply(); } private void Apply() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) float num = 1f - (1f - open) * (1f - open); Renderer[] array = renderers; for (int i = 0; i < array.Length; i++) { array[i].enabled = open > 0.001f; } ((Component)this).transform.localScale = new Vector3(Mathf.Lerp(0.12f, 1f, num), Mathf.Lerp(0.35f, 1f, num), 1f); float num2 = 1f + 0.8f * flash + 0.6f * ((open < 1f) ? (1f - open) : 0f); field.SetFloat("_ExternalAlpha", num); cells.SetFloat("_ExternalAlpha", num); field.SetColor("_TintColor", Tint * num2); cells.SetColor("_TintColor", Tint * (0.6f + 1.4f * flash)); } public void Hit(Vector3 world) { //IL_001a: 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_0020: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (Visible) { flash = 1f; Vector3 val = ((Component)this).transform.InverseTransformPoint(world); val.x = Mathf.Clamp(val.x, (0f - width) / 2f, width / 2f); val.y = Mathf.Clamp(val.y, (0f - height) / 2f, height / 2f); float num = 2f * val.x / width; val.z = bulge * (1f - num * num) + 0.02f; GameObject val2 = new GameObject("Ripple"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = val; val2.AddComponent<MeshFilter>().sharedMesh = rippleMesh; MeshRenderer obj = val2.AddComponent<MeshRenderer>(); Material item = (((Renderer)obj).sharedMaterial = new Material(rippleMat)); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; val2.transform.localScale = Vector3.one * 0.25f; ripples.Add((val2.transform, item, 0f)); if (ripples.Count > 6) { Object.Destroy((Object)(object)((Component)ripples[0].t).gameObject); Object.Destroy((Object)(object)ripples[0].m); ripples.RemoveAt(0); } } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)field)) { Object.Destroy((Object)(object)field); } if (Object.op_Implicit((Object)(object)cells)) { Object.Destroy((Object)(object)cells); } if (Object.op_Implicit((Object)(object)rippleMat)) { Object.Destroy((Object)(object)rippleMat); } foreach (var ripple in ripples) { Material item = ripple.m; if (Object.op_Implicit((Object)(object)item)) { Object.Destroy((Object)(object)item); } } } public static Action Reskin(MeshRenderer target, float w, float h, float b) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) LoadShared(); MeshFilter filter = ((Component)target).GetComponent<MeshFilter>(); Mesh oldMesh = filter.sharedMesh; Material[] oldMats = ((Renderer)target).sharedMaterials; Mesh mesh = Panel(w, h, b); mesh.subMeshCount = 2; mesh.SetTriangles(mesh.GetTriangles(0), 1); Material f = FxMaterial("matBrigitteBarrierBig", (Texture)(object)fieldTex, 1.2f); Material c = FxMaterial("matBrigitteBarrierBigCells", (Texture)(object)maskTex, 0.45f); c.EnableKeyword("USE_CLOUDS"); c.SetFloat("_CloudsOn", 1f); c.SetTexture("_Cloud1Tex", (Texture)(object)cellsTex); c.SetTextureScale("_Cloud1Tex", new Vector2(w * 2.06f / 0.6f, h * 1.82f / 0.7f)); c.SetTexture("_Cloud2Tex", (Texture)(object)cellsTex); c.SetTextureScale("_Cloud2Tex", new Vector2(w * 2.06f / 1.4f, h * 1.82f / 1.5f)); c.SetVector("_CutoffScroll", new Vector4(0.06f, 0.11f, -0.04f, 0f)); c.SetFloat("_AlphaBoost", 0.45f); filter.sharedMesh = mesh; ((Renderer)target).sharedMaterials = (Material[])(object)new Material[2] { f, c }; return delegate { if (Object.op_Implicit((Object)(object)filter)) { filter.sharedMesh = oldMesh; } if (Object.op_Implicit((Object)(object)target)) { ((Renderer)target).sharedMaterials = oldMats; } Object.Destroy((Object)(object)mesh); Object.Destroy((Object)(object)f); Object.Destroy((Object)(object)c); }; } } internal static class BarrierHits { private static EffectIndex blocked = (EffectIndex)(-1); private static EffectIndex absorbed = (EffectIndex)(-1); public static void Setup(Harmony harmony) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(EffectManager), "SpawnEffect", new Type[3] { typeof(EffectIndex), typeof(EffectData), typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(BarrierHits), "OnSpawn", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) blocked = Find("EnforcerDamageBlocked"); absorbed = Find("EnforcerDamageBlockedAbsorbedVariant"); }); } private static EffectIndex Find(string prefabName) { for (int i = 0; i < EffectCatalog.effectCount; i++) { EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)i); if (effectDef != null && Object.op_Implicit((Object)(object)effectDef.prefab) && ((Object)effectDef.prefab).name == prefabName) { return (EffectIndex)i; } } BrigitteEnforcerPlugin.Log.LogWarning((object)("Effect not found: " + prefabName)); return (EffectIndex)(-1); } private static void OnSpawn(EffectIndex effectIndex, EffectData effectData) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0030: 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) if ((int)effectIndex == -1 || effectData == null || (effectIndex != blocked && effectIndex != absorbed)) { return; } try { BrigitteController brigitteController = BrigitteController.Of(effectData.ResolveNetworkedObjectReference()); if (Object.op_Implicit((Object)(object)brigitteController)) { brigitteController.OnBlocked(effectData.origin, effectIndex == absorbed); } } catch (Exception ex) { BrigitteEnforcerPlugin.Log.LogDebug((object)("Barrier hit: " + ex.Message)); } } } [DefaultExecutionOrder(10000)] public class BrigitteController : MonoBehaviour { internal static SkinDef skin; public static float Width = 3.3f; public static float Height = 2.35f; public static float Bulge = 0.35f; public static float Distance = 1.4f; public static float ChestHeight = 1.25f; public static float MaxPitch = 30f; private ModelSkinController skinController; private CharacterModel characterModel; private EnforcerSurvivorController enforcer; private EntityStateMachine shieldMachine; private Barrier barrier; private MeshRenderer kineticModel; private Action restoreKinetic; public bool forceUp; public bool SkinActive { get { if (!Object.op_Implicit((Object)(object)skinController) || !Object.op_Implicit((Object)(object)skin)) { return false; } int currentSkinIndex = skinController.currentSkinIndex; if (currentSkinIndex >= 0 && currentSkinIndex < skinController.skins.Length) { return (Object)(object)skinController.skins[currentSkinIndex] == (Object)(object)skin; } return false; } } public static BrigitteController Of(GameObject bodyObject) { CharacterBody val = (Object.op_Implicit((Object)(object)bodyObject) ? bodyObject.GetComponent<CharacterBody>() : null); Transform val2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.modelLocator)) ? val.modelLocator.modelTransform : null); BrigitteController brigitteController = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<BrigitteController>() : null); if (!Object.op_Implicit((Object)(object)brigitteController) || !brigitteController.SkinActive) { return null; } return brigitteController; } private void Awake() { skinController = ((Component)this).GetComponent<ModelSkinController>(); characterModel = ((Component)this).GetComponent<CharacterModel>(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "KineticChargeShieldModel") { kineticModel = ((Component)val).GetComponent<MeshRenderer>(); } } } private bool ShieldRaised() { if (forceUp) { return true; } CharacterBody val = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.body : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive) { return false; } if (!Object.op_Implicit((Object)(object)enforcer)) { enforcer = ((Component)val).GetComponent<EnforcerSurvivorController>(); } if (!Object.op_Implicit((Object)(object)shieldMachine)) { shieldMachine = EntityStateMachine.FindByCustomName(((Component)val).gameObject, "Shield"); } if (Object.op_Implicit((Object)(object)enforcer) && enforcer.IsDefaultShieldEnabled) { return true; } EntityState val2 = (Object.op_Implicit((Object)(object)shieldMachine) ? shieldMachine.state : null); if (val2 != null && !(val2 is NotInShieldedState)) { return !(val2 is ProtectAndServeDeactivate); } return false; } private void LateUpdate() { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (!SkinActive) { if (Object.op_Implicit((Object)(object)barrier)) { Object.Destroy((Object)(object)((Component)barrier).gameObject); barrier = null; } if (restoreKinetic != null) { restoreKinetic(); restoreKinetic = null; } return; } if (Object.op_Implicit((Object)(object)kineticModel) && restoreKinetic == null) { restoreKinetic = Barrier.Reskin(kineticModel, 4.03f, 2.3f, 0.06f); } bool flag = ShieldRaised(); if (!Object.op_Implicit((Object)(object)barrier)) { if (!flag) { return; } barrier = Barrier.Create("BrigitteBarrierShield", Width, Height, Bulge); } CharacterBody val = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.body : null); Vector3 val2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inputBank)) ? val.inputBank.aimDirection : ((Component)this).transform.forward); Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(val2.x, 0f, val2.z); if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { forward = ((Component)this).transform.forward; } float num = Mathf.Clamp(Mathf.Asin(Mathf.Clamp(((Vector3)(ref val2)).normalized.y, -1f, 1f)) * 57.29578f, 0f - MaxPitch, MaxPitch); Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref forward)).normalized) * Quaternion.Euler(0f - num, 0f, 0f); Vector3 val4 = ((Component)this).transform.position + Vector3.up * ChestHeight; ((Component)barrier).transform.SetPositionAndRotation(val4 + val3 * new Vector3(0f, Height / 2f - ChestHeight, Distance), val3); barrier.Tick(flag, Time.deltaTime); } public void OnBlocked(Vector3 position, bool kinetic) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!kinetic && Object.op_Implicit((Object)(object)barrier)) { barrier.Hit(position); } } private void OnDisable() { if (Object.op_Implicit((Object)(object)barrier)) { ((Component)barrier).gameObject.SetActive(false); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)barrier)) { ((Component)barrier).gameObject.SetActive(true); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)barrier)) { Object.Destroy((Object)(object)((Component)barrier).gameObject); } restoreKinetic?.Invoke(); } } [BepInPlugin("com.chaz.brigitteenforcer", "BrigitteEnforcer", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BrigitteEnforcerPlugin : BaseUnityPlugin { public const string PluginGUID = "com.chaz.brigitteenforcer"; public const string PluginName = "BrigitteEnforcer"; public const string PluginVersion = "1.0.0"; private const string SkinNameToken = "CHAZ_BRIGITTEENFORCER_SKIN_NAME"; internal static ManualLogSource Log; public static SkinDef Skin { get; private set; } private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { LanguageAPI.Add("CHAZ_BRIGITTEENFORCER_SKIN_NAME", "Brigitte"); AddSkin(); BarrierHits.Setup(new Harmony("com.chaz.brigitteenforcer")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to add Brigitte skin: " + ex)); } } private void AddSkin() { //IL_0134: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0353: 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_0377: Unknown result type (might be due to invalid IL or missing references) GameObject val = BrigitteEnforcerPlugin.Load<GameObject>("RoR2/DLC4/Enforcer/Enforcer2Body.prefab"); GameObject gameObject = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject; ModelSkinController component = gameObject.GetComponent<ModelSkinController>(); SkinnedMeshRenderer val2 = FindRenderer(gameObject, "Enforcer_geo"); SkinnedMeshRenderer val3 = FindRenderer(gameObject, "Enforcer_Gun_low"); SkinnedMeshRenderer val4 = FindRenderer(gameObject, "Enforcer_Shield_low"); SkinnedMeshRenderer val5 = FindRenderer(gameObject, "FootLights"); SkinnedMeshRenderer val6 = FindRenderer(gameObject, "ShoulderLights"); Dictionary<string, Matrix4x4> bindposes = Assets.ReadBindposes("bindposes.bin"); Mesh mesh = Assets.ReadSkinnedMesh("bg_body.hkm", val2, bindposes); Mesh mesh2 = Assets.ReadSkinnedMesh("bg_flail.hkm", val3, bindposes); Mesh mesh3 = Assets.ReadSkinnedMesh("bg_shield.hkm", val4, bindposes); Mesh mesh4 = Assets.ReadSkinnedMesh("bg_hair.hkm", val5, bindposes); Material template = BrigitteEnforcerPlugin.Load<Material>("RoR2/DLC4/Enforcer/matEnforcer2Body.mat"); Material m = Assets.MakeMaterial(template, "matBrigitteBody", Assets.ReadTexture("bg_body.png", mipmaps: true, (TextureWrapMode)1), cutout: false); Material m2 = Assets.MakeMaterial(template, "matBrigitteFlail", Assets.ReadTexture("bg_flail.png", mipmaps: true, (TextureWrapMode)1), cutout: false); Material val7 = Assets.MakeMaterial(template, "matBrigitteShield", Assets.ReadTexture("bg_shield.png", mipmaps: true, (TextureWrapMode)1), cutout: false); val7.SetTexture("_EmTex", (Texture)(object)Assets.ReadTexture("bg_shield_em.png", mipmaps: true, (TextureWrapMode)1)); val7.SetColor("_EmColor", new Color(0.45f, 0.8f, 1f)); val7.SetFloat("_EmPower", 2f); Material m3 = Assets.MakeMaterial(template, "matBrigitteHair", Assets.ReadTexture("bg_hair.png", mipmaps: true, (TextureWrapMode)1), cutout: true); Skin = Skins.CreateNewSkinDef(new SkinDefParamsInfo { Name = "skinEnforcerBrigitte", NameToken = "CHAZ_BRIGITTEENFORCER_SKIN_NAME", Icon = Skins.CreateSkinIcon(Color32.op_Implicit(new Color32((byte)150, (byte)156, (byte)162, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)232, (byte)160, (byte)48, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)140, (byte)58, (byte)28, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)120, (byte)205, byte.MaxValue, byte.MaxValue))), RootObject = gameObject, BaseSkins = (SkinDef[])(object)new SkinDef[1] { component.skins[0] }, RendererInfos = (RendererInfo[])(object)new RendererInfo[4] { RendererInfo((Renderer)(object)val2, m), RendererInfo((Renderer)(object)val3, m2), RendererInfo((Renderer)(object)val4, val7), RendererInfo((Renderer)(object)val5, m3) }, MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[4] { new MeshReplacement { renderer = (Renderer)(object)val2, mesh = mesh }, new MeshReplacement { renderer = (Renderer)(object)val3, mesh = mesh2 }, new MeshReplacement { renderer = (Renderer)(object)val4, mesh = mesh3 }, new MeshReplacement { renderer = (Renderer)(object)val5, mesh = mesh4 } }, GameObjectActivations = (GameObjectActivation[])(object)new GameObjectActivation[2] { new GameObjectActivation { gameObject = ((Component)val5).gameObject, shouldActivate = true }, new GameObjectActivation { gameObject = ((Component)val6).gameObject, shouldActivate = false } }, ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>(), MinionSkinReplacements = Array.Empty<MinionSkinReplacement>() }); if (!Skins.AddSkinToCharacter(val, Skin)) { throw new Exception("R2API refused the skin"); } BrigitteController.skin = Skin; gameObject.AddComponent<BrigitteController>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Added Brigitte skin to Enforcer"); } 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 }; } } 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())); } } }