Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of DroneAutoRepair v1.0.1
DroneAutoRepair/DroneAutoRepair.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.Drone; using EntityStates.Turret1; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using R2API; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; [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("DroneAutoRepair")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DroneAutoRepair")] [assembly: AssemblyTitle("DroneAutoRepair")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 DroneAutoRepair { internal class DroneDownedState : BaseState { public class RigidbodyCollisionListener : MonoBehaviour { public DroneDownedState deathState; private void OnCollisionEnter(Collision collision) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) DroneDownedState droneDownedState = deathState; ContactPoint contact = collision.GetContact(0); droneDownedState.OnImpactServer(((ContactPoint)(ref contact)).point); } } public static GameObject droneExplosion = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/OmniExplosionVFXDroneDeath.prefab").WaitForCompletion(); public static GameObject megaDroneExplosion = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/OmniExplosionVFXMegaDrone.prefab").WaitForCompletion(); public GameObject deathExplosionEffect; public string initialSoundString = "Play_drone_deathpt1"; public string deathSoundString = "Play_drone_deathpt2"; public float deathEffectRadius = 2f; public float forceAmount = 30f; [SerializeField] public float deathDuration = 5f; private RigidbodyCollisionListener rigidbodyCollisionListener; private GameObject OwnerObject; private bool hasImpacted; private Vector3 impactPoint; private Quaternion impactRotation; private bool exploded; private bool isMegaDrone; public override void OnEnter() { //IL_000f: 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_007e: 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_0110: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown ((BaseState)this).OnEnter(); isMegaDrone = (Object)(object)DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(((EntityState)this).characterBody.bodyIndex)) == (Object)(object)DroneDefs.MegaDrone; Util.PlaySound(initialSoundString, ((EntityState)this).gameObject); if (Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyMotor)) { ((Behaviour)((EntityState)this).rigidbodyMotor.forcePID).enabled = false; ((EntityState)this).rigidbodyMotor.rigid.useGravity = true; ((EntityState)this).rigidbodyMotor.rigid.AddForce(Vector3.up * forceAmount, (ForceMode)0); ((EntityState)this).rigidbodyMotor.rigid.collisionDetectionMode = (CollisionDetectionMode)1; } if (Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyDirection)) { ((Behaviour)((EntityState)this).rigidbodyDirection).enabled = false; } deathExplosionEffect = (isMegaDrone ? megaDroneExplosion : droneExplosion); deathEffectRadius = (isMegaDrone ? 5f : 2f); if (Object.op_Implicit((Object)(object)deathExplosionEffect)) { EffectManager.SpawnEffect(deathExplosionEffect, new EffectData { origin = ((EntityState)this).characterBody.corePosition, scale = ((EntityState)this).characterBody.radius + deathEffectRadius }, false); } if (((EntityState)this).isAuthority) { rigidbodyCollisionListener = ((EntityState)this).gameObject.AddComponent<RigidbodyCollisionListener>(); rigidbodyCollisionListener.deathState = this; } CharacterMaster master = ((EntityState)this).characterBody.master; object obj; if (master == null) { obj = null; } else { MinionOwnership minionOwnership = master.minionOwnership; obj = ((minionOwnership != null) ? minionOwnership.ownerMaster : null); } if (Object.op_Implicit((Object)obj)) { CharacterBody body = ((EntityState)this).characterBody.master.minionOwnership.ownerMaster.GetBody(); OwnerObject = (Object.op_Implicit((Object)(object)body) ? ((Component)body).gameObject : null); } ((EntityState)this).characterBody.baseRegen = 0f; ((EntityState)this).characterBody.levelRegen = 0f; ((EntityState)this).characterBody.regen = 0f; } public override void FixedUpdate() { //IL_0041: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) ((EntityState)this).FixedUpdate(); if (!NetworkServer.active) { return; } if (hasImpacted) { ((EntityState)this).rigidbodyMotor.rigid.velocity = new Vector3(0f, 0f, 0f); ((EntityState)this).rigidbodyMotor.rigid.angularVelocity = new Vector3(0f, 0f, 0f); ((EntityState)this).rigidbodyMotor.rigid.position = impactPoint; ((EntityState)this).rigidbodyMotor.rigid.rotation = impactRotation; ((EntityState)this).healthComponent.health = Mathf.Max(((EntityState)this).healthComponent.health, 1f); ((EntityState)this).healthComponent.Heal(1f / 30f * ((EntityState)this).healthComponent.fullHealth * Time.fixedDeltaTime, default(ProcChainMask), false); if (((EntityState)this).healthComponent.health >= ((EntityState)this).healthComponent.fullHealth) { Respawn(); } } else if (((EntityState)this).fixedAge > deathDuration) { OnImpactServer(((EntityState)this).rigidbodyMotor.rigid.position); } } public void Explode() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (!exploded) { exploded = true; if (Object.op_Implicit((Object)(object)deathExplosionEffect)) { EffectManager.SpawnEffect(deathExplosionEffect, new EffectData { origin = ((EntityState)this).characterBody.corePosition, scale = ((EntityState)this).characterBody.radius + deathEffectRadius }, false); } if (Object.op_Implicit((Object)(object)rigidbodyCollisionListener)) { EntityState.Destroy((Object)(object)rigidbodyCollisionListener); } Util.PlaySound(deathSoundString, ((EntityState)this).gameObject); } } public virtual void OnImpactServer(Vector3 contactPoint) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00f2: Unknown result type (might be due to invalid IL or missing references) if (!hasImpacted && NetworkServer.active) { hasImpacted = true; impactPoint = contactPoint; Explode(); if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.master) && Object.op_Implicit((Object)(object)((EntityState)this).rigidbodyMotor)) { ((EntityState)this).rigidbodyMotor.rigid.useGravity = false; ((EntityState)this).rigidbodyMotor.rigid.velocity = new Vector3(0f, 0f, 0f); ((EntityState)this).rigidbodyMotor.rigid.angularVelocity = new Vector3(0f, 0f, 0f); ((EntityState)this).rigidbodyMotor.rigid.position = impactPoint; impactRotation = ((EntityState)this).rigidbodyMotor.rigid.rotation; } } } public override void OnExit() { EntityState.Destroy((Object)(object)((Component)((EntityState)this).GetModelTransform()).gameObject); ((EntityState)this).OnExit(); } public void Respawn() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) ((EntityState)this).characterBody.master.Respawn(((EntityState)this).characterBody.transform.position, ((EntityState)this).characterBody.transform.rotation, false); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("zombieseatflesh7.DroneAutoRepair", "DroneAutoRepair", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "zombieseatflesh7.DroneAutoRepair"; public const string PluginAuthor = "zombieseatflesh7"; public const string PluginName = "DroneAutoRepair"; public const string PluginVersion = "1.0.1"; public static ManualLogSource Logger; public static ConfigEntry<float> costMult; public void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; CharacterDeathBehavior.OnDeath += new hook_OnDeath(On_Death); SummonMasterBehavior.OpenSummonReturnMaster += new hook_OpenSummonReturnMaster(On_OpenSummon); PurchaseInteraction.Awake += new hook_Awake(On_PurchaseInteraction_Awake); DroneVendorTerminalBehavior.DispatchDrone += new Manipulator(IL_VendorDispatchDrone); DroneVendorMultiShopController.Start += new Manipulator(IL_DroneMultishopStart); bool flag = default(bool); ContentAddition.AddEntityState<DroneDownedState>(ref flag); ContentAddition.AddEntityState<TurretDownedState>(ref flag); costMult = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Drone Cost Multiplier", 1f, "Multiplier to the cost of drones."); } private void On_Death(orig_OnDeath orig, CharacterDeathBehavior self) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00a0: Unknown result type (might be due to invalid IL or missing references) Type stateType = ((SerializableEntityStateType)(ref self.deathState)).stateType; if ((int)((Component)self).gameObject.GetComponent<TeamComponent>().teamIndex == 1 && (stateType == typeof(DeathState) || stateType == typeof(MegaDroneDeathState))) { self.deathState = new SerializableEntityStateType(typeof(DroneDownedState)); } else if ((int)((Component)self).gameObject.GetComponent<TeamComponent>().teamIndex == 1 && stateType == typeof(DeathState)) { self.deathState = new SerializableEntityStateType(typeof(TurretDownedState)); } orig.Invoke(self); } private CharacterMaster On_OpenSummon(orig_OpenSummonReturnMaster orig, SummonMasterBehavior self, Interactor activator) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 CharacterMaster val = orig.Invoke(self, activator); DroneDef droneDef = DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(val.GetBody().bodyIndex)); if ((int)val.teamIndex == 1 && val.hasBody && Object.op_Implicit((Object)(object)droneDef)) { val.destroyOnBodyDeath = false; } return val; } private void On_PurchaseInteraction_Awake(orig_Awake orig, PurchaseInteraction self) { orig.Invoke(self); SummonMasterBehavior val = default(SummonMasterBehavior); bool flag = ((Component)self).gameObject.TryGetComponent<SummonMasterBehavior>(ref val) && ((Object)val.masterPrefab).name == "Turret1Master"; if (self.isDrone || flag) { self.Networkcost = (int)Mathf.Floor((float)self.Networkcost * costMult.Value); } } private void IL_VendorDispatchDrone(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); try { val.GotoNext(new Func<Instruction, bool>[2] { (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, 2), (Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterMaster>(i, "get_inventory") }); val.Emit(OpCodes.Ldloc_2); val.EmitDelegate<Action<CharacterMaster>>((Action<CharacterMaster>)delegate(CharacterMaster master) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 DroneDef droneDef = DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(master.GetBody().bodyIndex)); if ((int)master.teamIndex == 1 && master.hasBody && Object.op_Implicit((Object)(object)droneDef) && (Object)(object)droneDef != (Object)(object)DroneDefs.EquipmentDrone) { master.destroyOnBodyDeath = false; } }); } catch (Exception ex) { Logger.LogError((object)ex); } } private void IL_DroneMultishopStart(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); try { val.GotoNext(new Func<Instruction, bool>[1] { (Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<DroneVendorMultiShopController>(i, "set_Networkcost") }); val.EmitDelegate<Func<int, int>>((Func<int, int>)((int cost) => (int)((float)cost * costMult.Value))); } catch (Exception ex) { Logger.LogError((object)ex); } } } internal class TurretDownedState : BaseState { public GameObject deathExplosion = DroneDownedState.droneExplosion; private Transform cachedModelTransform; private float deathDuration; private bool exploded; public override void OnEnter() { ((BaseState)this).OnEnter(); cachedModelTransform = (Object.op_Implicit((Object)(object)((EntityState)this).modelLocator) ? ((EntityState)this).modelLocator.modelTransform : null); PlayDeathAnimation(); ((EntityState)this).characterBody.baseRegen = 0f; ((EntityState)this).characterBody.levelRegen = 0f; ((EntityState)this).characterBody.regen = 0f; } protected void PlayDeathAnimation(float crossfadeDuration = 0.1f) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Animator modelAnimator = ((EntityState)this).GetModelAnimator(); if (Object.op_Implicit((Object)(object)modelAnimator)) { int layerIndex = modelAnimator.GetLayerIndex("Body"); modelAnimator.PlayInFixedTime("Death", layerIndex); modelAnimator.Update(0f); AnimatorStateInfo currentAnimatorStateInfo = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex); deathDuration = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).length; } } public override void FixedUpdate() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown ((EntityState)this).FixedUpdate(); if (NetworkServer.active && ((EntityState)this).fixedAge > deathDuration) { if (Object.op_Implicit((Object)(object)deathExplosion) && !exploded) { exploded = true; EffectManager.SpawnEffect(deathExplosion, new EffectData { origin = ((EntityState)this).transform.position, scale = 2f }, true); } ((EntityState)this).healthComponent.health = Mathf.Max(((EntityState)this).healthComponent.health, 1f); ((EntityState)this).healthComponent.Heal(1f / 30f * ((EntityState)this).healthComponent.fullHealth * Time.fixedDeltaTime, default(ProcChainMask), false); if (((EntityState)this).healthComponent.health >= ((EntityState)this).healthComponent.fullHealth) { Respawn(); } } } public override void OnExit() { if (Object.op_Implicit((Object)(object)cachedModelTransform)) { EntityState.Destroy((Object)(object)((Component)cachedModelTransform).gameObject); } ((EntityState)this).OnExit(); } public void Respawn() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) ((EntityState)this).characterBody.master.Respawn(((EntityState)this).characterBody.transform.position, ((EntityState)this).characterBody.transform.rotation, false); } } }