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 DroneRespawn v1.0.1
DroneRespawn.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.Drone; using EntityStates.DroneCombiner; using EntityStates.Turret1; using HG.Reflection; using InLobbyConfig; using InLobbyConfig.Fields; using Microsoft.CodeAnalysis; using On.EntityStates.Drone; using On.EntityStates.DroneCombiner; using On.EntityStates.Turret1; using On.RoR2; using RoR2; using RoR2.CharacterAI; using RoR2.Navigation; using RoR2.Scripts.GameBehaviors; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DroneRespawn")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ee9c79599f61f3e48a4f25c13fb5ed0bc3e09ae1")] [assembly: AssemblyProduct("DroneRespawn")] [assembly: AssemblyTitle("DroneRespawn")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 DroneRespawn { public static class DroneItems { [CompilerGenerated] private static class <>O { public static hook_GetGeneratedOptionsFromInteractor <0>__PickupPickerController_GetGeneratedOptionsFromInteractor; } public static void Hook() { //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_001b: Expected O, but got Unknown object obj = <>O.<0>__PickupPickerController_GetGeneratedOptionsFromInteractor; if (obj == null) { hook_GetGeneratedOptionsFromInteractor val = PickupPickerController_GetGeneratedOptionsFromInteractor; <>O.<0>__PickupPickerController_GetGeneratedOptionsFromInteractor = val; obj = (object)val; } PickupPickerController.GetGeneratedOptionsFromInteractor += (hook_GetGeneratedOptionsFromInteractor)obj; } private static IEnumerable<ItemDef> UselessItems() { yield return Items.TreasureCache; yield return Items.TreasureCacheVoid; yield return Items.FreeChest; yield return Items.LowerPricedChests; yield return Items.ExtraShrineItem; yield return Items.Squid; yield return Items.OnLevelUpFreeUnlock; yield return Items.ScrapWhite; yield return Items.ScrapGreen; yield return Items.ScrapRed; yield return Items.ScrapYellow; yield return Items.RegeneratingScrap; yield return Items.GoldOnHurt; yield return Items.BarrageOnBoss; } private static List<Option> PickupPickerController_GetGeneratedOptionsFromInteractor(orig_GetGeneratedOptionsFromInteractor orig, PickupPickerController self, Interactor activator) { List<Option> list = orig.Invoke(self, activator); if (list != null && DroneRespawnPlugin.NoUselessItemsForDrones.Value && Object.op_Implicit((Object)(object)((Component)self).GetComponent<AssemblyStationController>())) { HashSet<ItemIndex> useless = new HashSet<ItemIndex>(from item in UselessItems() where Object.op_Implicit((Object)(object)item) select item.itemIndex); list.RemoveAll(delegate(Option option) { //IL_0006: 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_000c: 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) HashSet<ItemIndex> hashSet = useless; PickupDef pickupDef = PickupCatalog.GetPickupDef(option.pickup.pickupIndex); return hashSet.Contains((ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex))); }); } return list; } } public static class DroneMerge { [CompilerGenerated] private static class <>O { public static hook_StartDroneCombineSequence <0>__DroneCombinerCombining_StartDroneCombineSequence; } public static void Hook() { //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_001b: Expected O, but got Unknown object obj = <>O.<0>__DroneCombinerCombining_StartDroneCombineSequence; if (obj == null) { hook_StartDroneCombineSequence val = DroneCombinerCombining_StartDroneCombineSequence; <>O.<0>__DroneCombinerCombining_StartDroneCombineSequence = val; obj = (object)val; } DroneCombinerCombining.StartDroneCombineSequence += (hook_StartDroneCombineSequence)obj; } private static void DroneCombinerCombining_StartDroneCombineSequence(orig_StartDroneCombineSequence orig, DroneCombinerCombining self) { if (NetworkServer.active && DroneRespawnPlugin.MergedDronesKeepItems.Value) { KeepItems(self.toDestroy, self.toUpgrade); } orig.Invoke(self); } private unsafe static void KeepItems(CharacterBody removed, CharacterBody kept) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0083: 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_00ba: Invalid comparison between Unknown and I4 //IL_0092: 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_00c3: Invalid comparison between Unknown and I4 //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) Inventory val = ((Object.op_Implicit((Object)(object)removed) && Object.op_Implicit((Object)(object)removed.master)) ? removed.master.inventory : null); Inventory val2 = ((Object.op_Implicit((Object)(object)kept) && Object.op_Implicit((Object)(object)kept.master)) ? kept.master.inventory : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { return; } AllItemsEnumerator enumerator = ItemCatalog.allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; if (current != Items.DroneUpgradeHidden.itemIndex) { int num = val.GetItemCountPermanent(current) - val2.GetItemCountPermanent(current); if (num > 0) { val2.GiveItemPermanent(current, num); } } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } if ((int)val2.currentEquipmentIndex == -1 && (int)val.currentEquipmentIndex != -1) { EquipmentIndex currentEquipmentIndex = val.currentEquipmentIndex; EquipmentLocation activeEquipmentLocation = val2.activeEquipmentLocation; val2.SetEquipmentIndex(currentEquipmentIndex, ref activeEquipmentLocation); } } } public static class DroneRespawnAPI { public delegate void ReturnTimeModifier(CharacterMaster droneMaster, CharacterBody droneBody, ref float seconds); private static readonly List<Func<CharacterMaster, CharacterBody, bool>> exemptions = new List<Func<CharacterMaster, CharacterBody, bool>>(); private static readonly HashSet<DroneDef> exemptDrones = new HashSet<DroneDef>(); public static event ReturnTimeModifier ModifyReturnTime; public static void AddExemption(Func<CharacterMaster, CharacterBody, bool> isExempt) { if (isExempt != null && !exemptions.Contains(isExempt)) { exemptions.Add(isExempt); } } public static void RemoveExemption(Func<CharacterMaster, CharacterBody, bool> isExempt) { exemptions.Remove(isExempt); } public static void AddExemption(DroneDef droneDef) { if ((Object)(object)droneDef != (Object)null) { exemptDrones.Add(droneDef); } } public static void RemoveExemption(DroneDef droneDef) { exemptDrones.Remove(droneDef); } internal static bool IsExempt(CharacterMaster droneMaster, CharacterBody droneBody) { //IL_000d: 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) DroneDef val = (((Object)(object)droneBody != (Object)null) ? DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(droneBody.bodyIndex)) : null); if ((Object)(object)val != (Object)null && exemptDrones.Contains(val)) { return true; } Func<CharacterMaster, CharacterBody, bool>[] array = exemptions.ToArray(); foreach (Func<CharacterMaster, CharacterBody, bool> func in array) { try { if (func(droneMaster, droneBody)) { return true; } } catch (Exception arg) { Log.LogError($"An exemption failed: {arg}"); } } return false; } internal static float GetReturnTime(CharacterMaster droneMaster, CharacterBody droneBody, float seconds) { if (DroneRespawnAPI.ModifyReturnTime == null) { return seconds; } Delegate[] invocationList = DroneRespawnAPI.ModifyReturnTime.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { ReturnTimeModifier returnTimeModifier = (ReturnTimeModifier)invocationList[i]; try { returnTimeModifier(droneMaster, droneBody, ref seconds); } catch (Exception arg) { Log.LogError($"A return time modifier failed: {arg}"); } } return seconds; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Def.DroneRespawn", "DroneRespawn", "1.0.1")] public class DroneRespawnPlugin : BaseUnityPlugin { public const string PluginGUID = "Def.DroneRespawn"; public const string PluginAuthor = "Def"; public const string PluginName = "DroneRespawn"; public const string PluginVersion = "1.0.1"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> SecondsPerGold; public static ConfigEntry<float> EquipmentDroneSeconds; public static ConfigEntry<bool> MergedDronesKeepItems; public static ConfigEntry<bool> DroneTechDronesWait; public static ConfigEntry<bool> DronesEnterEveryStage; public static ConfigEntry<bool> NoUselessItemsForDrones; public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "Enabled", true, "A player's destroyed drone or turret leaves no broken one but comes back next to its owner after a while, like the Drone Operator's drones, also a drone lost over a pit. It keeps its items and equipment."); SecondsPerGold = ((BaseUnityPlugin)this).Config.Bind<float>("Main", "Seconds per gold", 1f, "How long a destroyed drone or turret takes to come back, per gold it costs to buy before the difficulty raises it, e.g. 40 seconds for a Gunner Drone (40 gold), 350 for a TC-280 (350 gold) and 35 for a Gunner Turret (35 gold). Each upgrade from the Drone Combiner Station adds 20%, as it does to the price."); EquipmentDroneSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Main", "Equipment Drone seconds", 100f, "How long an Equipment Drone takes to come back, whose repair costs an equipment rather than gold; also any other drone whose repair isn't paid in gold."); MergedDronesKeepItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Drone Combiner Station", "Merged drones keep items", true, "When the Drone Combiner Station merges two drones, the one it keeps gets the higher count of each item of the two, not their sum, and the other's equipment if it has none. Normally the other drone's items are lost."); DroneTechDronesWait = ((BaseUnityPlugin)this).Config.Bind<bool>("Drone Operator", "Drones wait for their Drone Operator", true, "A Drone Operator's drone that is destroyed while they are another survivor for a while, e.g. during a survivor swap, comes back as it was once they are a Drone Operator again, instead of being lost with its items. A player who was a Drone Operator only for a while loses the drones once they are their own survivor again."); DronesEnterEveryStage = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "Drones enter every stage", false, "Your drones also come along into the stages that normally keep allies out, e.g. the Bazaar or Void Fields."); NoUselessItemsForDrones = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "No useless items for drones", true, "The Drone Upgrade Station doesn't offer items that do nothing on a drone, e.g. Rusted Key, Sale Star or Roll of Pennies. The README lists them all."); if (ModCompatibilityInLobbyConfig.enabled) { ModCompatibilityInLobbyConfig.CreateFromBepInExConfigFile(((BaseUnityPlugin)this).Config, "Drone Respawn"); } DroneReturn.Hook(); DroneMerge.Hook(); DroneTechDrones.Hook(); DroneStageEntry.Hook(); DroneItems.Hook(); } } public static class DroneReturn { private class LostDrone { public CharacterMaster owner; public GameObject masterPrefab; public Dictionary<ItemIndex, int> items = new Dictionary<ItemIndex, int>(); public EquipmentIndex equipment; public float returnTime; public float returnSeconds; public bool onGround; } [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__DeathState_OnEnter; public static hook_OnImpactServer <1>__DeathState_OnImpactServer; public static hook_OnExit <2>__DeathState_OnExit; public static hook_OnEnter <3>__TurretDeathState_OnEnter; public static hook_OnExit <4>__TurretDeathState_OnExit; public static Action <5>__RoR2Application_onFixedUpdate; public static Action<Run> <6>__Run_onRunStartGlobal; } private static readonly List<LostDrone> lostDrones = new List<LostDrone>(); private static readonly ConditionalWeakTable<EntityState, LostDrone> dyingDrones = new ConditionalWeakTable<EntityState, LostDrone>(); private static bool Active { get { if (NetworkServer.active) { return DroneRespawnPlugin.Enabled.Value; } return false; } } public static void Hook() { //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_001b: Expected O, but got Unknown //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_003b: Expected O, but got Unknown //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_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown object obj = <>O.<0>__DeathState_OnEnter; if (obj == null) { hook_OnEnter val = DeathState_OnEnter; <>O.<0>__DeathState_OnEnter = val; obj = (object)val; } DeathState.OnEnter += (hook_OnEnter)obj; object obj2 = <>O.<1>__DeathState_OnImpactServer; if (obj2 == null) { hook_OnImpactServer val2 = DeathState_OnImpactServer; <>O.<1>__DeathState_OnImpactServer = val2; obj2 = (object)val2; } DeathState.OnImpactServer += (hook_OnImpactServer)obj2; object obj3 = <>O.<2>__DeathState_OnExit; if (obj3 == null) { hook_OnExit val3 = DeathState_OnExit; <>O.<2>__DeathState_OnExit = val3; obj3 = (object)val3; } DeathState.OnExit += (hook_OnExit)obj3; object obj4 = <>O.<3>__TurretDeathState_OnEnter; if (obj4 == null) { hook_OnEnter val4 = TurretDeathState_OnEnter; <>O.<3>__TurretDeathState_OnEnter = val4; obj4 = (object)val4; } DeathState.OnEnter += (hook_OnEnter)obj4; object obj5 = <>O.<4>__TurretDeathState_OnExit; if (obj5 == null) { hook_OnExit val5 = TurretDeathState_OnExit; <>O.<4>__TurretDeathState_OnExit = val5; obj5 = (object)val5; } DeathState.OnExit += (hook_OnExit)obj5; RoR2Application.onFixedUpdate += RoR2Application_onFixedUpdate; Run.onRunStartGlobal += Run_onRunStartGlobal; } private static void Run_onRunStartGlobal(Run run) { lostDrones.Clear(); } private static void DeathState_OnEnter(orig_OnEnter orig, DeathState self) { orig.Invoke(self); LostDrone lostDrone = ((Active && Object.op_Implicit((Object)(object)((EntityState)self).characterBody)) ? Note(((EntityState)self).characterBody, ReturnTime(self)) : null); if (lostDrone != null) { dyingDrones.Add((EntityState)(object)self, lostDrone); } } private static void TurretDeathState_OnEnter(orig_OnEnter orig, DeathState self) { orig.Invoke(self); LostDrone lostDrone = ((Active && Object.op_Implicit((Object)(object)((EntityState)self).characterBody)) ? Note(((EntityState)self).characterBody, ReturnTime(self)) : null); if (lostDrone != null) { lostDrone.onGround = true; dyingDrones.Add((EntityState)(object)self, lostDrone); } } private unsafe static LostDrone Note(CharacterBody body, float returnSeconds) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) CharacterMaster master = body.master; CharacterMaster val = ((Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.minionOwnership.ownerMaster) && Object.op_Implicit((Object)(object)master.minionOwnership.ownerMaster.playerCharacterMasterController)) ? master.minionOwnership.ownerMaster : null); if ((Object)(object)val == (Object)null || Object.op_Implicit((Object)(object)((Component)master).GetComponent<DroneRepairMaster>()) || DroneRespawnAPI.IsExempt(master, body)) { return null; } GameObject masterPrefab = MasterCatalog.GetMasterPrefab(master.masterIndex); if ((Object)(object)masterPrefab == (Object)null) { return null; } LostDrone lostDrone = new LostDrone { owner = val, masterPrefab = masterPrefab, equipment = (EquipmentIndex)((!Object.op_Implicit((Object)(object)master.inventory)) ? (-1) : ((int)master.inventory.currentEquipmentIndex)), returnSeconds = DroneRespawnAPI.GetReturnTime(master, body, returnSeconds) }; if (Object.op_Implicit((Object)(object)master.inventory)) { AllItemsEnumerator enumerator = ItemCatalog.allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; int itemCountPermanent = master.inventory.GetItemCountPermanent(current); if (itemCountPermanent > 0) { lostDrone.items[current] = itemCountPermanent; } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } } return lostDrone; } private static void DeathState_OnImpactServer(orig_OnImpactServer orig, DeathState self, Vector3 contactPoint) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!TakeOver(self)) { orig.Invoke(self, contactPoint); } } private static void DeathState_OnExit(orig_OnExit orig, DeathState self) { TakeOver(self); orig.Invoke(self); } private static bool TakeOver(DeathState self) { if (!Active || self.spawnedRepairObject || self.isGhost || self.hasExtraLife || !TakeOver((EntityState)(object)self)) { return false; } self.spawnedRepairObject = true; return true; } private static void TurretDeathState_OnExit(orig_OnExit orig, DeathState self) { if (Active && Object.op_Implicit((Object)(object)self.deadFormToSpawnOnDeath) && !self.isGhost && !self.hasExtraLife && TakeOver((EntityState)(object)self)) { self.deadFormToSpawnOnDeath = null; } orig.Invoke(self); } private static bool TakeOver(EntityState self) { if (!dyingDrones.TryGetValue(self, out var value)) { return false; } dyingDrones.Remove(self); value.returnTime = Run.instance.fixedTime + value.returnSeconds; lostDrones.Add(value); return true; } private static float ReturnTime(DeathState deathState) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) CharacterBody characterBody = ((EntityState)deathState).characterBody; DroneDef droneDef = DroneCatalog.GetDroneDef(DroneCatalog.GetDroneIndexFromBodyIndex(characterBody.bodyIndex)); return ReturnTime((Object.op_Implicit((Object)(object)droneDef) && Object.op_Implicit((Object)(object)droneDef.droneBrokenSpawnCard)) ? droneDef.droneBrokenSpawnCard : LegacyResourcesAPI.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscBroken" + BodyCatalog.GetBodyName(characterBody.bodyIndex).Replace("Body", "")), deathState.costCoefficient * (1f + (float)deathState.droneUpgradeCount * 0.2f)); } private static float ReturnTime(DeathState deathState) { return ReturnTime(deathState.deadFormToSpawnOnDeath, 1f); } private static float ReturnTime(SpawnCard spawnCard, float costCoefficient) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 PurchaseInteraction val = ((Object.op_Implicit((Object)(object)spawnCard) && Object.op_Implicit((Object)(object)spawnCard.prefab)) ? spawnCard.prefab.GetComponent<PurchaseInteraction>() : null); if (!Object.op_Implicit((Object)(object)val) || (int)val.costType != 1) { return DroneRespawnPlugin.EquipmentDroneSeconds.Value; } return Mathf.Max(0f, DroneRespawnPlugin.SecondsPerGold.Value) * (float)val.cost * costCoefficient; } private static void RoR2Application_onFixedUpdate() { if (!NetworkServer.active || lostDrones.Count == 0 || (Object)(object)Run.instance == (Object)null) { return; } for (int num = lostDrones.Count - 1; num >= 0; num--) { LostDrone lostDrone = lostDrones[num]; if ((Object)(object)lostDrone.owner == (Object)null) { lostDrones.RemoveAt(num); } else { CharacterBody body = lostDrone.owner.GetBody(); if (!((Object)(object)body == (Object)null) && body.healthComponent.alive && Run.instance.fixedTime >= lostDrone.returnTime) { lostDrones.RemoveAt(num); Return(lostDrone, body); } } } } private static void Return(LostDrone drone, CharacterBody ownerBody) { //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_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0083: 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_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0112: Invalid comparison between Unknown and I4 //IL_011b: 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) Vector3 position = ownerBody.footPosition + Vector3.up * 2f; RaycastHit val = default(RaycastHit); if (drone.onGround && Physics.Raycast(ownerBody.corePosition, Vector3.down, ref val, 100f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1)) { position = ((RaycastHit)(ref val)).point; } CharacterMaster val2 = new MasterSummon { masterPrefab = drone.masterPrefab, position = position, rotation = Quaternion.identity, summonerBodyObject = ((Component)ownerBody).gameObject, ignoreTeamMemberLimit = true, useAmbientLevel = true }.Perform(); if ((Object)(object)val2 == (Object)null) { return; } foreach (KeyValuePair<ItemIndex, int> item in drone.items) { item.Deconstruct(out var key, out var value); ItemIndex val3 = key; int num = value - val2.inventory.GetItemCountPermanent(val3); if (num > 0) { val2.inventory.GiveItemPermanent(val3, num); } } if ((int)drone.equipment != -1) { Inventory inventory = val2.inventory; EquipmentIndex equipment = drone.equipment; EquipmentLocation activeEquipmentLocation = val2.inventory.activeEquipmentLocation; inventory.SetEquipmentIndex(equipment, ref activeEquipmentLocation); } } } public static class DroneStageEntry { [CompilerGenerated] private static class <>O { public static hook_RespawnAllNPCs <0>__Stage_RespawnAllNPCs; } public static void Hook() { //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_001b: Expected O, but got Unknown object obj = <>O.<0>__Stage_RespawnAllNPCs; if (obj == null) { hook_RespawnAllNPCs val = Stage_RespawnAllNPCs; <>O.<0>__Stage_RespawnAllNPCs = val; obj = (object)val; } Stage.RespawnAllNPCs += (hook_RespawnAllNPCs)obj; } private static void Stage_RespawnAllNPCs(orig_RespawnAllNPCs orig, Stage self) { //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_0083: 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_0142: 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_0096: 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_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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0134: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self); if (!NetworkServer.active || !DroneRespawnPlugin.DronesEnterEveryStage.Value || !Object.op_Implicit((Object)(object)self.sceneDef) || !self.sceneDef.suppressNpcEntry) { return; } Transform playerSpawnTransform = self.GetPlayerSpawnTransform(); ReadOnlyCollection<CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList; for (int i = 0; i < readOnlyInstancesList.Count; i++) { CharacterMaster val = readOnlyInstancesList[i]; if (!IsPlayerDrone(val) || Object.op_Implicit((Object)(object)val.GetBodyObject()) || !Util.IsDontDestroyOnLoad(((Component)val).gameObject)) { continue; } Vector3 val2 = Vector3.zero; Quaternion val3 = Quaternion.identity; if (Object.op_Implicit((Object)(object)playerSpawnTransform)) { val2 = playerSpawnTransform.position; val3 = playerSpawnTransform.rotation; BaseAI component = ((Component)val).GetComponent<BaseAI>(); CharacterBody val4 = (Object.op_Implicit((Object)(object)val.bodyPrefab) ? val.bodyPrefab.GetComponent<CharacterBody>() : null); NodeGraph val5 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)val4)) ? component.GetDesiredSpawnNodeGraph() : null); if (Object.op_Implicit((Object)(object)val5)) { List<NodeIndex> list = new List<NodeIndex>(); val5.FindNodesInRange(val2, 10f, 100f, (HullMask)(1 << (int)val4.hullClassification), list); if (list.Count > 0) { val5.GetNodePosition(list[Random.Range(0, list.Count)], ref val2); } } } val.Respawn(val2, val3, true); } } private static bool IsPlayerDrone(CharacterMaster master) { //IL_0055: 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_0061: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.bodyPrefab) || !Object.op_Implicit((Object)(object)master.minionOwnership)) { return false; } CharacterMaster ownerMaster = master.minionOwnership.ownerMaster; CharacterBody val = default(CharacterBody); if (Object.op_Implicit((Object)(object)ownerMaster) && Object.op_Implicit((Object)(object)ownerMaster.playerCharacterMasterController) && master.bodyPrefab.TryGetComponent<CharacterBody>(ref val)) { return (val.bodyFlags & 0x400000) > 0; } return false; } } public static class DroneTechDrones { [CompilerGenerated] private static class <>O { public static hook_SetOwnedByDroneTech <0>__DroneRepairMaster_SetOwnedByDroneTech; public static hook_Explode <1>__DTDroneDeathState_Explode; public static hook_OnImpactServer <2>__DTDroneDeathState_OnImpactServer; } private static readonly HashSet<DroneRepairMaster> waiting = new HashSet<DroneRepairMaster>(); private static bool Active { get { if (NetworkServer.active) { return DroneRespawnPlugin.DroneTechDronesWait.Value; } return false; } } public static void Hook() { //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_001b: Expected O, but got Unknown //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_003b: Expected O, but got Unknown //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_005b: Expected O, but got Unknown object obj = <>O.<0>__DroneRepairMaster_SetOwnedByDroneTech; if (obj == null) { hook_SetOwnedByDroneTech val = DroneRepairMaster_SetOwnedByDroneTech; <>O.<0>__DroneRepairMaster_SetOwnedByDroneTech = val; obj = (object)val; } DroneRepairMaster.SetOwnedByDroneTech += (hook_SetOwnedByDroneTech)obj; object obj2 = <>O.<1>__DTDroneDeathState_Explode; if (obj2 == null) { hook_Explode val2 = DTDroneDeathState_Explode; <>O.<1>__DTDroneDeathState_Explode = val2; obj2 = (object)val2; } DTDroneDeathState.Explode += (hook_Explode)obj2; object obj3 = <>O.<2>__DTDroneDeathState_OnImpactServer; if (obj3 == null) { hook_OnImpactServer val3 = DTDroneDeathState_OnImpactServer; <>O.<2>__DTDroneDeathState_OnImpactServer = val3; obj3 = (object)val3; } DTDroneDeathState.OnImpactServer += (hook_OnImpactServer)obj3; } private static bool IsDroneTech(GameObject bodyPrefab) { if (Object.op_Implicit((Object)(object)bodyPrefab)) { return Object.op_Implicit((Object)(object)bodyPrefab.GetComponent<DroneTechRepairQueue>()); } return false; } private static GameObject OwnSurvivor(CharacterMaster owner) { if (!Object.op_Implicit((Object)(object)owner.originalBodyPrefab)) { return owner.bodyPrefab; } return owner.originalBodyPrefab; } private static bool IsDroneTechForLater(CharacterMaster owner) { CharacterBody val = (Object.op_Implicit((Object)(object)owner) ? owner.GetBody() : null); if (Object.op_Implicit((Object)(object)val) && !Object.op_Implicit((Object)(object)((Component)val).GetComponent<DroneTechRepairQueue>())) { return IsDroneTech(OwnSurvivor(owner)); } return false; } private static void DroneRepairMaster_SetOwnedByDroneTech(orig_SetOwnedByDroneTech orig, DroneRepairMaster self, bool ownedByDroneTech) { orig.Invoke(self, ownedByDroneTech); if (!Active || !Object.op_Implicit((Object)(object)self.droneMaster) || !Object.op_Implicit((Object)(object)self.ownerMaster)) { return; } if (ownedByDroneTech) { if (waiting.Remove(self) && !Object.op_Implicit((Object)(object)self.droneMaster.GetBody())) { Return(self); } } else if (IsDroneTechForLater(self.ownerMaster)) { self.droneMaster.destroyOnBodyDeath = false; } else if (!IsDroneTech(OwnSurvivor(self.ownerMaster))) { CharacterBody body = self.droneMaster.GetBody(); if (Object.op_Implicit((Object)(object)body)) { NetworkServer.Destroy(((Component)body).gameObject); } NetworkServer.Destroy(((Component)self.droneMaster).gameObject); } } private static void Return(DroneRepairMaster repairMaster) { //IL_001c: 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_0037: 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_0046: 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) CharacterBody body = repairMaster.ownerMaster.GetBody(); if (Object.op_Implicit((Object)(object)body)) { repairMaster.droneMaster.bodyPrefab = BodyCatalog.GetBodyPrefab(repairMaster.defaultBodyIndex); repairMaster.droneMaster.Respawn(body.footPosition + Vector3.up * 2f, Quaternion.identity, false); } } private static bool KeepsMaster(DTDroneDeathState deathState) { CharacterMaster val = (Object.op_Implicit((Object)(object)((EntityState)deathState).characterBody) ? ((EntityState)deathState).characterBody.master : null); DroneRepairMaster item = default(DroneRepairMaster); if (!Active || !Object.op_Implicit((Object)(object)val) || !((Component)val).TryGetComponent<DroneRepairMaster>(ref item) || !IsDroneTechForLater(val.minionOwnership.ownerMaster)) { return false; } waiting.RemoveWhere((DroneRepairMaster other) => !Object.op_Implicit((Object)(object)other)); waiting.Add(item); return true; } private static void DTDroneDeathState_Explode(orig_Explode orig, DTDroneDeathState self) { if (KeepsMaster(self)) { EntityState.Destroy((Object)(object)((EntityState)self).gameObject); } else { orig.Invoke(self); } } private static void DTDroneDeathState_OnImpactServer(orig_OnImpactServer orig, DTDroneDeathState self, Vector3 contactPoint) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!self.hasImpacted && KeepsMaster(self)) { self.hasImpacted = true; EntityState.Destroy((Object)(object)((EntityState)self).gameObject); } else { orig.Invoke(self, contactPoint); } } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void LogDebug(object data) { _logSource.LogDebug(data); } internal static void LogError(object data) { _logSource.LogError(data); } internal static void LogFatal(object data) { _logSource.LogFatal(data); } internal static void LogInfo(object data) { _logSource.LogInfo(data); } internal static void LogMessage(object data) { _logSource.LogMessage(data); } internal static void LogWarning(object data) { _logSource.LogWarning(data); } } public static class ModCompatibilityInLobbyConfig { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void CreateFromBepInExConfigFile(ConfigFile config, string displayName) { ModConfigCatalog.Add(ConfigFieldUtilities.CreateFromBepInExConfigFile(config, displayName)); } } }