Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of DefenseMatrixManager v1.1.1
DefenseMatrixManager.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using EntityStates; using EntityStates.EngiTurret.EngiTurretWeapon; using EntityStates.FalseSon; using EntityStates.GolemMonster; using EntityStates.Halcyonite; using EntityStates.PrimeMeridian; using EntityStates.TitanMonster; using HG; using Microsoft.CodeAnalysis; using On.EntityStates.EngiTurret.EngiTurretWeapon; using On.EntityStates.FalseSon; using On.EntityStates.GolemMonster; using On.EntityStates.Halcyonite; using On.EntityStates.PrimeMeridian; using On.EntityStates.TitanMonster; using On.RoR2; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DefenseMatrixManager")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7a72d8adbca622f0735d6df15715da190a8eecb3")] [assembly: AssemblyProduct("DefenseMatrixManager")] [assembly: AssemblyTitle("DefenseMatrixManager")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace DefenseMatrixManager { [Tooltip("Can be added to a GameObject to manage adding/removing colliders to the Defense Matrix Manager.")] [RequireComponent(typeof(TeamFilter))] public class DefenseMatrixComponent : MonoBehaviour { [Tooltip("Automatically add this to the Defense Matrix Manager on Start.")] public bool addOnStart = true; public DefenseMatrixManager.DefenseMatrixInfo? defenseMatrixInfo = null; public virtual void Start() { GenerateDefenseMatrixInfo(); if (addOnStart) { AddMatrix(); } } public virtual void GenerateDefenseMatrixInfo() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (defenseMatrixInfo != null) { RemoveMatrix(); } TeamFilter component = ((Component)this).GetComponent<TeamFilter>(); if (Object.op_Implicit((Object)(object)component)) { Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(); if (componentsInChildren != null && componentsInChildren.Length != 0) { defenseMatrixInfo = new DefenseMatrixManager.DefenseMatrixInfo(componentsInChildren, component.teamIndex); } } } public virtual void AddMatrix() { if (defenseMatrixInfo != null) { DefenseMatrixManager.AddMatrix(defenseMatrixInfo); } } public virtual void RemoveMatrix() { if (defenseMatrixInfo != null) { DefenseMatrixManager.RemoveMatrix(defenseMatrixInfo); } } public virtual void OnDestroy() { RemoveMatrix(); } } public static class DefenseMatrixManager { public class DefenseMatrixInfo { public Collider[] colliders; public TeamIndex teamIndex; public DefenseMatrixInfo(Collider[] colliders, TeamIndex teamIndex) { //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) this.colliders = colliders; this.teamIndex = teamIndex; } public void EnableColliders() { for (int i = 0; i < colliders.Length; i++) { if ((Object)(object)colliders[i] != (Object)null) { colliders[i].enabled = true; } } } public void DisableColliders() { for (int i = 0; i < colliders.Length; i++) { if ((Object)(object)colliders[i] != (Object)null) { colliders[i].enabled = false; } } } } private static List<DefenseMatrixInfo> activeDefenseMatrices = new List<DefenseMatrixInfo>(); public static DefenseMatrixInfo AddMatrix(DefenseMatrixInfo defenseMatrixInfo) { if (activeDefenseMatrices.Contains(defenseMatrixInfo)) { return defenseMatrixInfo; } if (defenseMatrixInfo != null && defenseMatrixInfo.colliders != null && defenseMatrixInfo.colliders.Length != 0) { activeDefenseMatrices.Add(defenseMatrixInfo); return defenseMatrixInfo; } return null; } public static void RemoveMatrix(DefenseMatrixInfo defenseMatrixInfo) { activeDefenseMatrices.Remove(defenseMatrixInfo); } public static void EnableMatrices(TeamIndex attackerTeam) { //IL_0019: 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) foreach (DefenseMatrixInfo activeDefenseMatrix in activeDefenseMatrices) { if (activeDefenseMatrix.teamIndex != attackerTeam) { activeDefenseMatrix.EnableColliders(); } } } public static void DisableMatrices(TeamIndex attackerTeam) { //IL_0019: 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) foreach (DefenseMatrixInfo activeDefenseMatrix in activeDefenseMatrices) { if (activeDefenseMatrix.teamIndex != attackerTeam) { activeDefenseMatrix.DisableColliders(); } } } internal static void Init() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown Stage.onStageStartGlobal += ClearDefenseMatrices; BlastAttack.Fire += new hook_Fire(BlastAttack_Fire); BulletAttack.Fire_FireArgs += new hook_Fire_FireArgs(BulletAttack_CheckDefenseMatrix); FireLaser.OnEnter += new hook_OnEnter(FireLaser_OnEnter); LaserFatherBurst.FireBurstLaser += new hook_FireBurstLaser(LaserFatherBurst_FireBurstLaser); TriLaser.FireTriLaser += new hook_FireTriLaser(TriLaser_FireTriLaser); ChargeLaser.Update += new hook_Update(ChargeLaser_Update); ChargeMegaLaser.FixedUpdate += new hook_FixedUpdate(ChargeMegaLaser_FixedUpdate); FireMegaLaser.FixedUpdate += new hook_FixedUpdate(FireMegaLaser_FixedUpdate); FireBeam.GetBeamEndPoint += new hook_GetBeamEndPoint(FireBeam_GetBeamEndPoint); ChargeTriLaser.Update += new hook_Update(ChargeTriLaser_Update); LaserFatherCharged.FixedUpdate += new hook_FixedUpdate(LaserFatherCharged_FixedUpdate); LunarGazeLaserCharge.Update += new hook_Update(LunarGazeLaserCharge_Update); LunarGazeLaserFire.UpdateTargettingLasers += new hook_UpdateTargettingLasers(LunarGazeLaserFire_UpdateTargettingLasers); LunarGazeLaserFire.RetractLasers += new hook_RetractLasers(LunarGazeLaserFire_RetractLasers); } private static void LunarGazeLaserFire_RetractLasers(orig_RetractLasers orig, LunarGazeLaserFire self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void LunarGazeLaserFire_UpdateTargettingLasers(orig_UpdateTargettingLasers orig, LunarGazeLaserFire self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void LunarGazeLaserCharge_Update(orig_Update orig, LunarGazeLaserCharge self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static Result BlastAttack_Fire(orig_Fire orig, BlastAttack self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000c: 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_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_012f: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0050: 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_0081: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) bool flag = (int)self.losType > 0; TeamIndex teamIndex = self.teamIndex; if (!flag && activeDefenseMatrices.Count > 0) { foreach (DefenseMatrixInfo activeDefenseMatrix in activeDefenseMatrices) { if (activeDefenseMatrix.teamIndex != teamIndex) { Collider[] colliders = activeDefenseMatrix.colliders; foreach (Collider val in colliders) { Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).extents; float num = Vector3Utils.ComponentMax(ref val2) * 0.5f; float num2 = (self.radius + num) * (self.radius + num); bounds = val.bounds; val2 = ((Bounds)(ref bounds)).center - self.position; if (((Vector3)(ref val2)).sqrMagnitude <= num2) { flag = true; self.losType = (LoSType)1; break; } } } if (flag) { break; } } } if (flag) { EnableMatrices(teamIndex); } Result result = orig.Invoke(self); if (flag) { DisableMatrices(teamIndex); } return result; } private static void LaserFatherCharged_FixedUpdate(orig_FixedUpdate orig, LaserFatherCharged self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void LaserFatherBurst_FireBurstLaser(orig_FireBurstLaser orig, LaserFatherBurst self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void TriLaser_FireTriLaser(orig_FireTriLaser orig, TriLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void ChargeTriLaser_Update(orig_Update orig, ChargeTriLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static Vector3 FireBeam_GetBeamEndPoint(orig_GetBeamEndPoint orig, FireBeam self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); Vector3 result = orig.Invoke(self); DisableMatrices(team); return result; } private static void FireMegaLaser_FixedUpdate(orig_FixedUpdate orig, FireMegaLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void ChargeMegaLaser_FixedUpdate(orig_FixedUpdate orig, ChargeMegaLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void ChargeLaser_Update(orig_Update orig, ChargeLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void FireLaser_OnEnter(orig_OnEnter orig, FireLaser self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) TeamIndex team = ((BaseState)self).GetTeam(); EnableMatrices(team); orig.Invoke(self); DisableMatrices(team); } private static void BulletAttack_CheckDefenseMatrix(orig_Fire_FireArgs orig, BulletAttack self, FireArgs args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) TeamIndex attackerTeam = (TeamIndex)(-1); if (Object.op_Implicit((Object)(object)self.owner)) { TeamComponent component = self.owner.GetComponent<TeamComponent>(); if (Object.op_Implicit((Object)(object)component)) { attackerTeam = component.teamIndex; } } EnableMatrices(attackerTeam); orig.Invoke(self, args); DisableMatrices(attackerTeam); } private static void ClearDefenseMatrices(Stage obj) { activeDefenseMatrices.Clear(); } } [BepInPlugin("com.Moffein.DefenseMatrixManager", "DefenseMatrixManager", "1.1.1")] public class Plugin : BaseUnityPlugin { private void Awake() { DefenseMatrixManager.Init(); } } }