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 DroneImprovements v1.2.1
DroneImprovements.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DroneImprovements.Hooks; using DroneImprovements.Skills; using EntityStates; using HG; using HG.Reflection; using IL.EntityStates; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.Orbs; using Rewired; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2.Networking; using RoR2.Orbs; using RoR2.Skills; using UnityEngine; using UnityEngine.Events; 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("DroneImprovements")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1")] [assembly: AssemblyProduct("DroneImprovements")] [assembly: AssemblyTitle("DroneImprovements")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.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 DroneImprovements { internal static class DroneBodyReport { public static void OnGameLoaded() { int num = 0; int num2 = 0; int num3 = 0; StringBuilder stringBuilder = new StringBuilder(); foreach (DroneDef allDroneDef in DroneCatalog.allDroneDefs) { GameObject remoteOpBody = allDroneDef.remoteOpBody; if (!Object.op_Implicit((Object)(object)remoteOpBody)) { continue; } num++; if (!Object.op_Implicit((Object)(object)remoteOpBody.GetComponent<Interactor>())) { DroneImprovementsPlugin.Log.LogWarning((object)(((Object)remoteOpBody).name + " has no Interactor, so it can't use interactables even with DroneSurvivorActions.")); } stringBuilder.Clear().Append(((Object)remoteOpBody).name).Append(':'); SkillLocator component = remoteOpBody.GetComponent<SkillLocator>(); if (Object.op_Implicit((Object)(object)component)) { AppendSkill(stringBuilder, "primary", component.primary); AppendSkill(stringBuilder, "secondary", component.secondary); AppendSkill(stringBuilder, "utility", component.utility); AppendSkill(stringBuilder, "special", component.special); if (HasFamily(component.utility, DroneSkills.DisconnectFamily)) { num2++; } if (HasFamily(component.special, DroneSkills.TeleportFamily)) { num3++; } } DroneImprovementsPlugin.Log.LogDebug((object)stringBuilder.ToString()); } DroneImprovementsPlugin.Log.LogInfo((object)($"{num} Remote Operation drones: {num2} with Disconnect, " + $"{num3} with Teleport to Player.")); } private static bool HasFamily(GenericSkill skill, SkillFamily family) { if (Object.op_Implicit((Object)(object)skill)) { return (Object)(object)skill.skillFamily == (Object)(object)family; } return false; } private static void AppendSkill(StringBuilder line, string slot, GenericSkill skill) { SkillFamily val = (Object.op_Implicit((Object)(object)skill) ? skill.skillFamily : null); SkillDef val2 = (Object.op_Implicit((Object)(object)val) ? val.defaultSkillDef : null); if (Object.op_Implicit((Object)(object)val2)) { string value = (string.IsNullOrEmpty(val2.skillName) ? ((Object)val2).name : val2.skillName); line.Append(' ').Append(slot).Append('=') .Append(value); } } } [BepInPlugin("revor.DroneImprovements", "DroneImprovements", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class DroneImprovementsPlugin : BaseUnityPlugin { public const string PluginGUID = "revor.DroneImprovements"; public const string PluginName = "DroneImprovements"; public const string PluginVersion = "1.2.1"; internal static ManualLogSource Log { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append("revor.DroneImprovements;1.2.1"); PluginConfig.Init(((BaseUnityPlugin)this).Config); HostSettings.Init(); DroneSkills.Init(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(DroneBodyReport.OnGameLoaded)); InteractionHooks.Init(); GoldHooks.Init(); FlightHooks.Init(); HoldoutZoneHooks.Init(); AllPlayersCheckHooks.Init(); ArenaVoidKillHooks.Init(); if (RiskOfOptionsCompat.IsInstalled) { RiskOfOptionsCompat.Init(); } } } internal static class DroneNetworking { private sealed class DisconnectRequestMessage : MessageBase { public GameObject droneObject; public override void Serialize(NetworkWriter writer) { writer.Write(droneObject); } public override void Deserialize(NetworkReader reader) { droneObject = reader.ReadGameObject(); } } public static void RequestDisconnect(CharacterBody drone) { if (!DroneUtil.IsDronePlayer(drone)) { return; } if (NetworkServer.active) { ServerDisconnect(drone); return; } NetworkConnection readyConnection = ClientScene.readyConnection; if (readyConnection != null) { readyConnection.Send((short)17392, (MessageBase)(object)new DisconnectRequestMessage { droneObject = ((Component)drone).gameObject }); } } [NetworkMessageHandler(msgType = 17392, server = true)] private static void HandleDisconnectRequest(NetworkMessage netMsg) { DisconnectRequestMessage disconnectRequestMessage = netMsg.ReadMessage<DisconnectRequestMessage>(); CharacterBody val = (Object.op_Implicit((Object)(object)disconnectRequestMessage.droneObject) ? disconnectRequestMessage.droneObject.GetComponent<CharacterBody>() : null); CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.master : null); PlayerCharacterMasterController val3 = (Object.op_Implicit((Object)(object)val2) ? val2.playerCharacterMasterController : null); NetworkUser val4 = (Object.op_Implicit((Object)(object)val3) ? val3.networkUser : null); if (Object.op_Implicit((Object)(object)val4)) { if (((NetworkBehaviour)val4).connectionToClient != netMsg.conn) { DroneImprovementsPlugin.Log.LogWarning((object)("Refused to disconnect " + val4.userName + "'s drone: the request came from another player's connection.")); } else { ServerDisconnect(val); } } } private static void ServerDisconnect(CharacterBody drone) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!DroneUtil.IsDronePlayer(drone)) { return; } CharacterMaster master = drone.master; if (!((Object)(object)master.GetBodyObject() != (Object)(object)((Component)drone).gameObject) && Object.op_Implicit((Object)(object)drone.healthComponent) && drone.healthComponent.alive) { DroneUtil.SpawnTeleportEffect(((Component)drone).gameObject, drone.corePosition, drone.radius); master.deathFootPosition = drone.footPosition; master.lostBodyToDeath = true; master.preventGameOver = false; master.preventRespawnUntilNextStageServer = true; master.inventory.SetEquipmentDisabled(false); if (Object.op_Implicit((Object)(object)((Component)drone).GetComponent<Inventory>())) { Object.Destroy((Object)(object)((Component)drone).gameObject); } else { master.DestroyBody(); } master.RestoreOriginalBodyPrefab(); DroneImprovementsPlugin.Log.LogInfo((object)(Util.GetBestMasterName(master) + " disconnected from their drone.")); } } } internal static class DroneTeleport { private static readonly float[] ringDistances = new float[4] { 4f, 6f, 2.5f, 9f }; private static readonly float[] flierHeights = new float[3] { 2.5f, 1.5f, 4f }; private static readonly float[] flierNodeLifts = new float[2] { 2f, 1f }; private const int DirectionsPerRing = 12; private const float DirectionStepDegrees = 30f; private const float MinClearanceRadius = 0.5f; private const float ClearanceMargin = 0.25f; private const float GroundProbeStartHeight = 2f; private const float GroundProbeDistance = 6f; private const float StandingLift = 0.1f; private const float SolidGroundSearchDistance = 150f; private const float NodeSearchRadius = 30f; private const float MinApproachSqrMagnitude = 0.01f; private const float MinDirectionSqrMagnitude = 0.0001f; private static readonly List<CharacterBody> extraTargets = new List<CharacterBody>(); public static bool TryTeleport(CharacterBody drone) { //IL_0013: 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_0020: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0045: 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) CharacterBody val = FindNearestTarget(drone); if (!Object.op_Implicit((Object)(object)val)) { return false; } Vector3 val2 = FindDestination(drone, val); DroneUtil.SpawnTeleportEffect(((Component)drone).gameObject, drone.corePosition, drone.radius); Vector3 val3 = drone.footPosition - drone.corePosition; TeleportHelper.TeleportBody(drone, val2 + val3, false); DroneUtil.SpawnTeleportEffect(((Component)drone).gameObject, val2, drone.radius); return true; } public static bool HasTarget(CharacterBody drone) { return Object.op_Implicit((Object)(object)FindNearestTarget(drone)); } private static CharacterBody FindNearestTarget(CharacterBody drone) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) CharacterBody best = null; float bestSqrDistance = float.PositiveInfinity; Vector3 corePosition = drone.corePosition; ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(drone.teamComponent.teamIndex); for (int i = 0; i < teamMembers.Count; i++) { CharacterBody body = teamMembers[i].body; if (DroneUtil.IsSurvivorPlayer(body) && IsConnected(body)) { ConsiderTarget(drone, corePosition, body, ref best, ref bestSqrDistance); } } extraTargets.Clear(); DroneTeleportApi.CollectTargets(drone, extraTargets); for (int j = 0; j < extraTargets.Count; j++) { ConsiderTarget(drone, corePosition, extraTargets[j], ref best, ref bestSqrDistance); } return best; } private static bool IsConnected(CharacterBody body) { CharacterMaster master = body.master; PlayerCharacterMasterController val = (Object.op_Implicit((Object)(object)master) ? master.playerCharacterMasterController : null); if (Object.op_Implicit((Object)(object)val)) { return val.isConnected; } return false; } private static void ConsiderTarget(CharacterBody drone, Vector3 origin, CharacterBody body, ref CharacterBody best, ref float bestSqrDistance) { //IL_0035: 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_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) if (Object.op_Implicit((Object)(object)body) && !((Object)(object)body == (Object)(object)drone) && !body.isRemoteOp && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive) { Vector3 val = body.corePosition - origin; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < bestSqrDistance) { bestSqrDistance = sqrMagnitude; best = body; } } } private static Vector3 FindDestination(CharacterBody drone, CharacterBody target) { //IL_0005: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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) //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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask); float num2 = Mathf.Max(drone.radius, 0.5f) + 0.25f; bool flag = !Object.op_Implicit((Object)(object)drone.characterMotor) || drone.characterMotor.isFlying; float num3 = drone.corePosition.y - drone.footPosition.y; Vector3 corePosition = target.corePosition; Vector3 footPosition = target.footPosition; Vector3 val = drone.corePosition - corePosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = -target.transform.forward; val.y = 0f; } val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward); float[] array = ringDistances; RaycastHit val5 = default(RaycastHit); foreach (float num4 in array) { for (int j = 0; j < 12; j++) { int num5 = ((j % 2 == 0) ? 1 : (-1)); Vector3 val2 = Quaternion.AngleAxis((float)((j + 1) / 2) * 30f * (float)num5, Vector3.up) * val; Vector3 val3 = footPosition + val2 * num4; if (flag) { float[] array2 = flierHeights; foreach (float num6 in array2) { Vector3 val4 = val3 + Vector3.up * num6; if (IsValidSpot(val4, corePosition, num2, num)) { return val4; } } } else if (Physics.Raycast(val3 + Vector3.up * 2f, Vector3.down, ref val5, 6f, num, (QueryTriggerInteraction)1)) { Vector3 val6 = ((RaycastHit)(ref val5)).point + Vector3.up * (num3 + 0.1f); if (IsValidSpot(val6, corePosition, num2, num)) { return val6; } } } } if (TryNodeGraphSpot(drone, target, flag, num3, num2, num, out var destinationCore)) { return destinationCore; } Vector3 val7 = corePosition + Vector3.up * (target.radius + num2); if (Physics.CheckSphere(val7, num2, num, (QueryTriggerInteraction)1) || Physics.Linecast(corePosition, val7, num, (QueryTriggerInteraction)1)) { return corePosition; } return val7; } private static bool IsValidSpot(Vector3 core, Vector3 anchor, float clearance, int worldMask) { //IL_0000: 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_000e: 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_001b: Unknown result type (might be due to invalid IL or missing references) if (Physics.CheckSphere(core, clearance, worldMask, (QueryTriggerInteraction)1)) { return false; } if (Physics.Linecast(anchor, core, worldMask, (QueryTriggerInteraction)1)) { return false; } return Physics.Raycast(core, Vector3.down, 150f, worldMask, (QueryTriggerInteraction)1); } private static bool TryNodeGraphSpot(CharacterBody drone, CharacterBody target, bool flier, float footToCore, float clearance, int worldMask, out Vector3 destinationCore) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0051: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_0073: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) destinationCore = default(Vector3); SceneInfo instance = SceneInfo.instance; NodeGraph val = (Object.op_Implicit((Object)(object)instance) ? instance.GetNodeGraph((GraphType)0) : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } NodeIndex val2 = val.FindClosestNode(target.footPosition, drone.hullClassification, 30f); Vector3 val3 = default(Vector3); if (val2 == NodeIndex.invalid || !val.GetNodePosition(val2, ref val3)) { return false; } if (flier) { float[] array = flierNodeLifts; foreach (float num in array) { if (IsClear(val3 + Vector3.up * num, clearance, worldMask, out destinationCore)) { return true; } } } return IsClear(val3 + Vector3.up * (footToCore + 0.1f), clearance, worldMask, out destinationCore); } private static bool IsClear(Vector3 core, float clearance, int worldMask, out Vector3 destinationCore) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) destinationCore = core; return !Physics.CheckSphere(core, clearance, worldMask, (QueryTriggerInteraction)1); } } public static class DroneTeleportApi { public static event Action<CharacterBody, List<CharacterBody>> CollectAdditionalTargets; internal static void CollectTargets(CharacterBody drone, List<CharacterBody> targets) { DroneTeleportApi.CollectAdditionalTargets?.Invoke(drone, targets); } } internal static class DroneUtil { public static bool IsDronePlayer(CharacterBody body) { if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled) { return body.isRemoteOp; } return false; } public static bool IsSurvivorPlayer(CharacterBody body) { if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled) { return !body.isRemoteOp; } return false; } public static int CountSurvivorPlayers() { if (!Object.op_Implicit((Object)(object)Run.instance)) { return 0; } int num = 0; ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers((TeamIndex)1); for (int i = 0; i < teamMembers.Count; i++) { CharacterBody body = teamMembers[i].body; if (IsSurvivorPlayer(body) && IsCurrentBody(body)) { num++; } } return num; } private static bool IsCurrentBody(CharacterBody body) { CharacterMaster master = body.master; if (Object.op_Implicit((Object)(object)master)) { return (Object)(object)master.GetBodyObject() == (Object)(object)((Component)body).gameObject; } return false; } public static int CountDronePlayers(TeamIndex teamIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) int num = 0; ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex); for (int i = 0; i < teamMembers.Count; i++) { if (IsDronePlayer(teamMembers[i].body)) { num++; } } return num; } public static int CountDronePlayers(List<CharacterBody> bodies) { int num = 0; for (int i = 0; i < bodies.Count; i++) { if (IsDronePlayer(bodies[i])) { num++; } } return num; } public static void SpawnTeleportEffect(GameObject subject, Vector3 position, float scale) { //IL_0025: 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_002b: 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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown GameObject val = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.GetTeleportEffectPrefab(subject) : null); if (Object.op_Implicit((Object)(object)val)) { EffectManager.SpawnEffect(val, new EffectData { origin = position, rotation = Quaternion.identity, scale = scale }, true); } } } internal static class EmbeddedSprites { public static Sprite Load(string resourceName) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0079: 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) byte[] array; using (Stream stream = typeof(EmbeddedSprites).Assembly.GetManifestResourceStream(resourceName)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Object)val).name = resourceName; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } internal static class HostSettings { private sealed class SettingsMessage : MessageBase { public bool survivorActions; public bool combatGold; public bool barrelGold; public bool shrineOfBloodGold; public bool dronesCanChargeHoldoutZones; public bool ignoreDronesForAllPlayerChecks; public bool spareDronesFromArenaVoidKill; public float sprintSpeedMultiplier; public override void Serialize(NetworkWriter writer) { writer.Write(survivorActions); writer.Write(combatGold); writer.Write(barrelGold); writer.Write(shrineOfBloodGold); writer.Write(dronesCanChargeHoldoutZones); writer.Write(ignoreDronesForAllPlayerChecks); writer.Write(spareDronesFromArenaVoidKill); writer.Write(sprintSpeedMultiplier); } public override void Deserialize(NetworkReader reader) { survivorActions = reader.ReadBoolean(); combatGold = reader.ReadBoolean(); barrelGold = reader.ReadBoolean(); shrineOfBloodGold = reader.ReadBoolean(); dronesCanChargeHoldoutZones = reader.ReadBoolean(); ignoreDronesForAllPlayerChecks = reader.ReadBoolean(); spareDronesFromArenaVoidKill = reader.ReadBoolean(); sprintSpeedMultiplier = reader.ReadSingle(); } } [CompilerGenerated] private static class <>O { public static EventHandler <0>__OnSurvivorActionsChanged; public static EventHandler <1>__OnHostSettingChanged; public static Action<NetworkClient> <2>__OnStartClient; public static NetworkUserGenericDelegate <3>__OnNetworkUserStart; public static Action<Run> <4>__OnRunStart; } private static bool receivedSurvivorActions; private static bool receivedCombatGold; private static bool receivedBarrelGold; private static bool receivedShrineOfBloodGold; private static bool receivedDronesCanChargeHoldoutZones; private static bool receivedIgnoreDronesForAllPlayerChecks; private static bool receivedSpareDronesFromArenaVoidKill; private static float receivedSprintSpeedMultiplier; public static bool SurvivorActions { get { if (!NetworkServer.active) { return receivedSurvivorActions; } return PluginConfig.DroneSurvivorActions.Value; } } public static bool CombatGold { get { if (!NetworkServer.active) { return receivedCombatGold; } return PluginConfig.DroneCombatGold.Value; } } public static bool BarrelGold { get { if (!NetworkServer.active) { return receivedBarrelGold; } return PluginConfig.DroneBarrelGold.Value; } } public static bool ShrineOfBloodGold { get { if (!NetworkServer.active) { return receivedShrineOfBloodGold; } return PluginConfig.DroneShrineOfBloodGold.Value; } } public static bool DronesCanChargeHoldoutZones { get { if (!NetworkServer.active) { return receivedDronesCanChargeHoldoutZones; } return PluginConfig.DronesCanChargeHoldoutZones.Value; } } public static bool IgnoreDronesForAllPlayerChecks { get { if (!NetworkServer.active) { return receivedIgnoreDronesForAllPlayerChecks; } return PluginConfig.IgnoreDronesForAllPlayerChecks.Value; } } public static bool SpareDronesFromArenaVoidKill { get { if (!NetworkServer.active) { return receivedSpareDronesFromArenaVoidKill; } return PluginConfig.SpareDronesFromArenaVoidKill.Value; } } public static float SprintSpeedMultiplier { get { if (!NetworkServer.active) { return receivedSprintSpeedMultiplier; } return PluginConfig.SprintSpeedMultiplier.Value; } } public static void Init() { //IL_015d: 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_0168: Expected O, but got Unknown ResetReceivedSettings(); PluginConfig.DroneSurvivorActions.SettingChanged += OnSurvivorActionsChanged; PluginConfig.DroneCombatGold.SettingChanged += OnHostSettingChanged; PluginConfig.DroneBarrelGold.SettingChanged += OnHostSettingChanged; PluginConfig.DroneShrineOfBloodGold.SettingChanged += OnHostSettingChanged; PluginConfig.DronesCanChargeHoldoutZones.SettingChanged += OnHostSettingChanged; PluginConfig.IgnoreDronesForAllPlayerChecks.SettingChanged += OnHostSettingChanged; PluginConfig.SpareDronesFromArenaVoidKill.SettingChanged += OnHostSettingChanged; PluginConfig.SprintSpeedMultiplier.SettingChanged += OnHostSettingChanged; NetworkManagerSystem.onStartClientGlobal += OnStartClient; object obj = <>O.<3>__OnNetworkUserStart; if (obj == null) { NetworkUserGenericDelegate val = OnNetworkUserStart; <>O.<3>__OnNetworkUserStart = val; obj = (object)val; } NetworkUser.onPostNetworkUserStart += (NetworkUserGenericDelegate)obj; Run.onRunStartGlobal += OnRunStart; } private static void OnSurvivorActionsChanged(object sender, EventArgs e) { if (NetworkServer.active) { Broadcast(); InteractionHooks.ApplySettingToExistingDrones(); } } private static void OnHostSettingChanged(object sender, EventArgs e) { if (NetworkServer.active) { Broadcast(); } } private static void OnStartClient(NetworkClient client) { ResetReceivedSettings(); } private static void OnNetworkUserStart(NetworkUser networkUser) { if (NetworkServer.active && !((NetworkBehaviour)networkUser).isLocalPlayer) { ((NetworkBehaviour)networkUser).connectionToClient.Send((short)17393, (MessageBase)(object)CreateMessage()); } } private static void OnRunStart(Run run) { if (NetworkServer.active) { Broadcast(); } } private static void Broadcast() { NetworkServer.SendToAll((short)17393, (MessageBase)(object)CreateMessage()); } private static SettingsMessage CreateMessage() { return new SettingsMessage { survivorActions = PluginConfig.DroneSurvivorActions.Value, combatGold = PluginConfig.DroneCombatGold.Value, barrelGold = PluginConfig.DroneBarrelGold.Value, shrineOfBloodGold = PluginConfig.DroneShrineOfBloodGold.Value, dronesCanChargeHoldoutZones = PluginConfig.DronesCanChargeHoldoutZones.Value, ignoreDronesForAllPlayerChecks = PluginConfig.IgnoreDronesForAllPlayerChecks.Value, spareDronesFromArenaVoidKill = PluginConfig.SpareDronesFromArenaVoidKill.Value, sprintSpeedMultiplier = PluginConfig.SprintSpeedMultiplier.Value }; } [NetworkMessageHandler(msgType = 17393, client = true)] private static void HandleSettings(NetworkMessage netMsg) { if (!NetworkServer.active) { SettingsMessage settingsMessage = netMsg.ReadMessage<SettingsMessage>(); receivedSurvivorActions = settingsMessage.survivorActions; receivedCombatGold = settingsMessage.combatGold; receivedBarrelGold = settingsMessage.barrelGold; receivedShrineOfBloodGold = settingsMessage.shrineOfBloodGold; receivedDronesCanChargeHoldoutZones = settingsMessage.dronesCanChargeHoldoutZones; receivedIgnoreDronesForAllPlayerChecks = settingsMessage.ignoreDronesForAllPlayerChecks; receivedSpareDronesFromArenaVoidKill = settingsMessage.spareDronesFromArenaVoidKill; receivedSprintSpeedMultiplier = (float)((ConfigEntryBase)PluginConfig.SprintSpeedMultiplier).Description.AcceptableValues.Clamp((object)settingsMessage.sprintSpeedMultiplier); InteractionHooks.ApplySettingToExistingDrones(); } } private static void ResetReceivedSettings() { receivedSurvivorActions = (bool)((ConfigEntryBase)PluginConfig.DroneSurvivorActions).DefaultValue; receivedCombatGold = (bool)((ConfigEntryBase)PluginConfig.DroneCombatGold).DefaultValue; receivedBarrelGold = (bool)((ConfigEntryBase)PluginConfig.DroneBarrelGold).DefaultValue; receivedShrineOfBloodGold = (bool)((ConfigEntryBase)PluginConfig.DroneShrineOfBloodGold).DefaultValue; receivedDronesCanChargeHoldoutZones = (bool)((ConfigEntryBase)PluginConfig.DronesCanChargeHoldoutZones).DefaultValue; receivedIgnoreDronesForAllPlayerChecks = (bool)((ConfigEntryBase)PluginConfig.IgnoreDronesForAllPlayerChecks).DefaultValue; receivedSpareDronesFromArenaVoidKill = (bool)((ConfigEntryBase)PluginConfig.SpareDronesFromArenaVoidKill).DefaultValue; receivedSprintSpeedMultiplier = (float)((ConfigEntryBase)PluginConfig.SprintSpeedMultiplier).DefaultValue; } } internal static class MessageIds { public const short DisconnectRequest = 17392; public const short HostSettingsUpdate = 17393; } internal static class PluginConfig { private const string HostSection = "Host"; private const string ObjectivesSection = "Objectives"; private const string AbilitiesSection = "Abilities"; private const string FlightSection = "Flight"; private const float DefaultSprintSpeedMultiplier = 2f; private const float MinSprintSpeedMultiplier = 1f; private const float MaxSprintSpeedMultiplier = 3f; private const float DefaultDisconnectHoldSeconds = 1f; private const float MinDisconnectHoldSeconds = 0f; private const float MaxDisconnectHoldSeconds = 5f; private const float DefaultTeleportCooldown = 30f; private const float MinTeleportCooldown = 1f; private const float MaxTeleportCooldown = 600f; public static ConfigEntry<bool> DroneSurvivorActions { get; private set; } public static ConfigEntry<bool> DroneCombatGold { get; private set; } public static ConfigEntry<bool> DroneBarrelGold { get; private set; } public static ConfigEntry<bool> DroneShrineOfBloodGold { get; private set; } public static ConfigEntry<bool> DronesCanChargeHoldoutZones { get; private set; } public static ConfigEntry<bool> IgnoreDronesForAllPlayerChecks { get; private set; } public static ConfigEntry<bool> SpareDronesFromArenaVoidKill { get; private set; } public static ConfigEntry<bool> DisconnectEnabled { get; private set; } public static ConfigEntry<float> DisconnectHoldSeconds { get; private set; } public static ConfigEntry<bool> TeleportEnabled { get; private set; } public static ConfigEntry<float> TeleportCooldown { get; private set; } public static ConfigEntry<float> SprintSpeedMultiplier { get; private set; } public static ConfigEntry<KeyboardShortcut> DescendKey { get; private set; } public static void Init(ConfigFile config) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) DroneSurvivorActions = config.Bind<bool>("Host", "DroneSurvivorActions", true, "(host) Drone players can open chests, use shrines, printers, scrappers and the teleporter, buy with their own gold, and pick up equipment. Off: they're locked out of those, as in the base game."); DroneCombatGold = config.Bind<bool>("Host", "DroneCombatGold", true, "(host) Drone players earn combat gold: kills, money packs, Brittle Crown, Roll of Pennies, ..., and gold other mods pay during a kill, hit or damage. Off: they get none, and their share of the shared combat gold goes to the survivors."); DroneBarrelGold = config.Bind<bool>("Host", "DroneBarrelGold", true, "(host) Drone players can open barrels and get their share of the gold. Off: they can't open barrels, and the survivors get all the gold of the barrels they open."); DroneShrineOfBloodGold = config.Bind<bool>("Host", "DroneShrineOfBloodGold", true, "(host) Drone players can use Shrine of Blood, which trades health for gold. Off: they can't."); DronesCanChargeHoldoutZones = config.Bind<bool>("Objectives", "DronesCanChargeHoldoutZones", true, "(host) Drone players inside a holdout zone (teleporter, pillars, Void Fields cells, ...) help charge it. Drones outside never slow it down."); IgnoreDronesForAllPlayerChecks = config.Bind<bool>("Objectives", "IgnoreDronesForAllPlayerChecks", true, "(host) Checks that wait for every player (the Mithrix arena entrance, the escape ship, ...) only wait for survivors. Drone players who are there anyway still count as there: they're safe when the arena seals and leave with the ship."); SpareDronesFromArenaVoidKill = config.Bind<bool>("Objectives", "SpareDronesFromArenaVoidKill", true, "(host) Drone players outside the Mithrix arena aren't killed when it seals (that would also use up a Dio's Best Friend). Drone players inside are never killed."); DisconnectEnabled = config.Bind<bool>("Abilities", "DisconnectEnabled", true, "(per player) Disconnect, your drone's Utility skill: hold it to leave the drone and go back to spectating."); DisconnectHoldSeconds = config.Bind<float>("Abilities", "DisconnectHoldSeconds", 1f, new ConfigDescription("(per player) How long to hold Disconnect, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); TeleportEnabled = config.Bind<bool>("Abilities", "TeleportEnabled", true, "(per player) Teleport to Player, your drone's Special skill (R): jump next to the nearest living player."); TeleportCooldown = config.Bind<float>("Abilities", "TeleportCooldown", 30f, new ConfigDescription("(per player) Base cooldown of Teleport to Player, in seconds. Cooldown items can shorten it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); SprintSpeedMultiplier = config.Bind<float>("Flight", "SprintSpeedMultiplier", 2f, new ConfigDescription("(host) How many times faster drone players fly while holding Sprint. At 1 this is off, and Sprint flies down as in the base game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), Array.Empty<object>())); DescendKey = config.Bind<KeyboardShortcut>("Flight", "DescendKey", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "(per player) Hold to fly your drone down (Jump flies up). It works whatever SprintSpeedMultiplier is. Modifier keys are ignored: the main key alone counts, so it also works while you hold movement keys."); } } internal static class RiskOfOptionsCompat { [CompilerGenerated] private static class <>O { public static IsDisabledDelegate <0>__IsClientOfAnotherHost; } public const string Guid = "com.rune580.riskofoptions"; private const string IconResource = "DroneImprovements.icon.png"; private const float DisconnectHoldStep = 0.1f; private const float TeleportCooldownStep = 1f; private const float SprintSpeedMultiplierStep = 0.1f; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Init() { ModSettingsManager.SetModDescription("Makes Remote Operation drones useful for dead players: survivor actions, flight controls, Disconnect and Teleport skills, and objectives that don't wait for drones. Settings marked (host) are decided by the host for everyone and are greyed out while you're a client; the others only affect your own drone."); ModSettingsManager.SetModIcon(EmbeddedSprites.Load("DroneImprovements.icon.png")); AddCheckBox(PluginConfig.DroneSurvivorActions, hostOnly: true); AddCheckBox(PluginConfig.DroneCombatGold, hostOnly: true); AddCheckBox(PluginConfig.DroneBarrelGold, hostOnly: true); AddCheckBox(PluginConfig.DroneShrineOfBloodGold, hostOnly: true); AddCheckBox(PluginConfig.DronesCanChargeHoldoutZones, hostOnly: true); AddCheckBox(PluginConfig.IgnoreDronesForAllPlayerChecks, hostOnly: true); AddCheckBox(PluginConfig.SpareDronesFromArenaVoidKill, hostOnly: true); AddCheckBox(PluginConfig.DisconnectEnabled, hostOnly: false); AddStepSlider(PluginConfig.DisconnectHoldSeconds, 0.1f, "{0:0.0}s", hostOnly: false); AddCheckBox(PluginConfig.TeleportEnabled, hostOnly: false); AddStepSlider(PluginConfig.TeleportCooldown, 1f, "{0:0}s", hostOnly: false); AddStepSlider(PluginConfig.SprintSpeedMultiplier, 0.1f, "{0:0.0}x", hostOnly: true); AddKeyBind(PluginConfig.DescendKey); } private static bool IsClientOfAnotherHost() { if (NetworkClient.active) { return !NetworkServer.active; } return false; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void AddCheckBox(ConfigEntry<bool> entry, bool hostOnly) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_001a: 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_0025: Expected O, but got Unknown CheckBoxConfig val = new CheckBoxConfig(); if (hostOnly) { object obj = <>O.<0>__IsClientOfAnotherHost; if (obj == null) { IsDisabledDelegate val2 = IsClientOfAnotherHost; <>O.<0>__IsClientOfAnotherHost = val2; obj = (object)val2; } ((BaseOptionConfig)val).checkIfDisabled = (IsDisabledDelegate)obj; } ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, val)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void AddStepSlider(ConfigEntry<float> entry, float step, string format, bool hostOnly) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003d: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0051: 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) //IL_005c: Expected O, but got Unknown AcceptableValueRange<float> val = (AcceptableValueRange<float>)(object)((ConfigEntryBase)entry).Description.AcceptableValues; StepSliderConfig val2 = new StepSliderConfig { min = val.MinValue, max = val.MaxValue, increment = step, FormatString = format }; if (hostOnly) { object obj = <>O.<0>__IsClientOfAnotherHost; if (obj == null) { IsDisabledDelegate val3 = IsClientOfAnotherHost; <>O.<0>__IsClientOfAnotherHost = val3; obj = (object)val3; } ((BaseOptionConfig)val2).checkIfDisabled = (IsDisabledDelegate)obj; } ModSettingsManager.AddOption((BaseOption)new StepSliderOption(entry, val2)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private static void AddKeyBind(ConfigEntry<KeyboardShortcut> entry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry)); } } } namespace DroneImprovements.Skills { internal sealed class DroneTeleportSkillDef : SkillDef { public override bool IsReady(GenericSkill skillSlot) { if (((SkillDef)this).IsReady(skillSlot) && PluginConfig.TeleportEnabled.Value && Object.op_Implicit((Object)(object)skillSlot.characterBody)) { return DroneTeleport.HasTarget(skillSlot.characterBody); } return false; } public override bool CanExecute(GenericSkill skillSlot) { if (!SkillKeyPress.IsClaimed(skillSlot)) { return ((SkillDef)this).CanExecute(skillSlot); } return false; } public override void OnExecute(GenericSkill skillSlot) { ((SkillDef)this).OnExecute(skillSlot); SkillKeyPress.Claim(skillSlot); } } internal sealed class DroneDisconnectSkillDef : SkillDef { public override bool IsReady(GenericSkill skillSlot) { if (((SkillDef)this).IsReady(skillSlot)) { return PluginConfig.DisconnectEnabled.Value; } return false; } public override bool CanExecute(GenericSkill skillSlot) { if (!SkillKeyPress.IsClaimed(skillSlot)) { return ((SkillDef)this).CanExecute(skillSlot); } return false; } public override void OnExecute(GenericSkill skillSlot) { ((SkillDef)this).OnExecute(skillSlot); SkillKeyPress.Claim(skillSlot); } } internal static class SkillKeyPress { public static bool IsClaimed(GenericSkill skillSlot) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected I4, but got Unknown CharacterBody characterBody = skillSlot.characterBody; InputBankTest val = (Object.op_Implicit((Object)(object)characterBody) ? characterBody.inputBank : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)characterBody.skillLocator)) { return false; } SkillSlot val2 = characterBody.skillLocator.FindSkillSlot(skillSlot); return (int)val2 switch { 0 => val.skill1.hasPressBeenClaimed, 1 => val.skill2.hasPressBeenClaimed, 2 => val.skill3.hasPressBeenClaimed, 3 => val.skill4.hasPressBeenClaimed, _ => false, }; } public static void Claim(GenericSkill skillSlot) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown CharacterBody characterBody = skillSlot.characterBody; InputBankTest val = (Object.op_Implicit((Object)(object)characterBody) ? characterBody.inputBank : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)characterBody.skillLocator)) { SkillSlot val2 = characterBody.skillLocator.FindSkillSlot(skillSlot); switch ((int)val2) { case 0: val.skill1.hasPressBeenClaimed = true; break; case 1: val.skill2.hasPressBeenClaimed = true; break; case 2: val.skill3.hasPressBeenClaimed = true; break; case 3: val.skill4.hasPressBeenClaimed = true; break; } } } } internal static class DroneSkills { private sealed class DroneContentPackProvider : IContentPackProvider { private readonly ContentPack contentPack = new ContentPack(); public string identifier => "revor.DroneImprovements"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.skillDefs.Add((SkillDef[])(object)new SkillDef[2] { TeleportSkill, DisconnectSkill }); contentPack.skillFamilies.Add((SkillFamily[])(object)new SkillFamily[2] { TeleportFamily, DisconnectFamily }); contentPack.entityStateTypes.Add(new Type[2] { typeof(DroneTeleportState), typeof(DroneDisconnectState) }); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } [CompilerGenerated] private static class <>O { public static EventHandler <0>__OnRechargeSettingChanged; public static CollectContentPackProvidersDelegate <1>__AddContentPackProvider; public static hook_SetBodyPrefabs <2>__BodyCatalog_SetBodyPrefabs; } public const string StateMachineName = "DroneImprovementsAbility"; private const string TeleportIconResource = "DroneImprovements.Assets.texDroneTeleportIcon.png"; private const string DisconnectIconResource = "DroneImprovements.Assets.texDroneDisconnectIcon.png"; private const float MinDisconnectRechargeInterval = 0.1f; public static DroneTeleportSkillDef TeleportSkill { get; private set; } public static DroneDisconnectSkillDef DisconnectSkill { get; private set; } public static SkillFamily TeleportFamily { get; private set; } public static SkillFamily DisconnectFamily { get; private set; } public static void Init() { //IL_00e9: 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_00f4: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown TeleportSkill = CreateSkillDef<DroneTeleportSkillDef>("DroneImprovementsTeleport", "Teleport to Player", "DroneImprovements.Assets.texDroneTeleportIcon.png", typeof(DroneTeleportState), (InterruptPriority)1); DisconnectSkill = CreateSkillDef<DroneDisconnectSkillDef>("DroneImprovementsDisconnect", "Disconnect", "DroneImprovements.Assets.texDroneDisconnectIcon.png", typeof(DroneDisconnectState), (InterruptPriority)0); ((SkillDef)DisconnectSkill).skillDescriptionToken = "<style=cIsUtility>Hold</style> to end remote operation and return to spectating."; ((SkillDef)DisconnectSkill).beginSkillCooldownOnSkillEnd = true; ApplyRechargeSettings(); PluginConfig.TeleportCooldown.SettingChanged += OnRechargeSettingChanged; PluginConfig.DisconnectHoldSeconds.SettingChanged += OnRechargeSettingChanged; TeleportFamily = CreateFamily("DroneImprovementsTeleportFamily", (SkillDef)(object)TeleportSkill); DisconnectFamily = CreateFamily("DroneImprovementsDisconnectFamily", (SkillDef)(object)DisconnectSkill); object obj = <>O.<1>__AddContentPackProvider; if (obj == null) { CollectContentPackProvidersDelegate val = AddContentPackProvider; <>O.<1>__AddContentPackProvider = val; obj = (object)val; } ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj; object obj2 = <>O.<2>__BodyCatalog_SetBodyPrefabs; if (obj2 == null) { hook_SetBodyPrefabs val2 = BodyCatalog_SetBodyPrefabs; <>O.<2>__BodyCatalog_SetBodyPrefabs = val2; obj2 = (object)val2; } BodyCatalog.SetBodyPrefabs += (hook_SetBodyPrefabs)obj2; } private static T CreateSkillDef<T>(string name, string nameToken, string iconResource, Type stateType, InterruptPriority interruptPriority) where T : SkillDef { //IL_0051: 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) //IL_0061: 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) T val = ScriptableObject.CreateInstance<T>(); ((Object)(object)val).name = name; ((SkillDef)val).skillName = name; ((SkillDef)val).skillNameToken = nameToken; ((SkillDef)val).icon = EmbeddedSprites.Load(iconResource); ((SkillDef)val).activationStateMachineName = "DroneImprovementsAbility"; ((SkillDef)val).activationState = new SerializableEntityStateType(stateType); ((SkillDef)val).interruptPriority = interruptPriority; ((SkillDef)val).baseMaxStock = 1; ((SkillDef)val).rechargeStock = 1; ((SkillDef)val).requiredStock = 1; ((SkillDef)val).stockToConsume = 1; ((SkillDef)val).fullRestockOnAssign = true; ((SkillDef)val).dontAllowPastMaxStocks = true; ((SkillDef)val).hideStockCount = true; ((SkillDef)val).isCombatSkill = false; ((SkillDef)val).cancelSprintingOnActivation = false; ((SkillDef)val).canceledFromSprinting = false; ((SkillDef)val).mustKeyPress = true; return val; } private static SkillFamily CreateFamily(string name, SkillDef skill) { //IL_0018: 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_003a: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>(); ((Object)val).name = name; Variant[] array = new Variant[1]; Variant val2 = new Variant { skillDef = skill }; ((Variant)(ref val2)).viewableNode = new Node(skill.skillName, false, (Node)null); array[0] = val2; val.variants = (Variant[])(object)array; return val; } private static void ApplyRechargeSettings() { float value = PluginConfig.TeleportCooldown.Value; ((SkillDef)TeleportSkill).baseRechargeInterval = value; ((SkillDef)TeleportSkill).skillDescriptionToken = "Teleport next to the nearest living player. " + $"<style=cIsUtility>{value:0.#}s base cooldown</style>."; ((SkillDef)DisconnectSkill).baseRechargeInterval = Mathf.Max(0.1f, PluginConfig.DisconnectHoldSeconds.Value); } private static void OnRechargeSettingChanged(object sender, EventArgs e) { ApplyRechargeSettings(); ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList; for (int i = 0; i < readOnlyInstancesList.Count; i++) { SkillLocator val = (Object.op_Implicit((Object)(object)readOnlyInstancesList[i]) ? readOnlyInstancesList[i].skillLocator : null); if (Object.op_Implicit((Object)(object)val)) { RefreshRechargeInterval(val.utility); RefreshRechargeInterval(val.special); } } } private static void RefreshRechargeInterval(GenericSkill skill) { if (Object.op_Implicit((Object)(object)skill) && ((Object)(object)skill.skillDef == (Object)(object)TeleportSkill || (Object)(object)skill.skillDef == (Object)(object)DisconnectSkill)) { skill.RecalculateValues(); } } private static void AddContentPackProvider(AddContentPackProviderDelegate addProvider) { addProvider.Invoke((IContentPackProvider)(object)new DroneContentPackProvider()); } private static void BodyCatalog_SetBodyPrefabs(orig_SetBodyPrefabs orig, GameObject[] newBodyPrefabs) { HashSet<GameObject> hashSet = new HashSet<GameObject>(); DroneDef[] droneDefs = ContentManager.droneDefs; foreach (DroneDef val in droneDefs) { if (Object.op_Implicit((Object)(object)val.remoteOpBody)) { hashSet.Add(val.remoteOpBody); } } foreach (GameObject val2 in newBodyPrefabs) { if (hashSet.Contains(val2)) { AddToBody(val2); } } orig.Invoke(newBodyPrefabs); } private static void AddToBody(GameObject prefab) { //IL_00b8: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)EntityStateMachine.FindByCustomName(prefab, "DroneImprovementsAbility"))) { return; } SkillLocator component = prefab.GetComponent<SkillLocator>(); if (!Object.op_Implicit((Object)(object)component)) { DroneImprovementsPlugin.Log.LogWarning((object)(((Object)prefab).name + " has no SkillLocator; no drone abilities added.")); return; } bool flag = !Object.op_Implicit((Object)(object)component.utility); bool flag2 = !Object.op_Implicit((Object)(object)component.special); if (!flag) { DroneImprovementsPlugin.Log.LogWarning((object)(((Object)prefab).name + " already has a Utility skill; no Disconnect.")); } if (!flag2) { DroneImprovementsPlugin.Log.LogWarning((object)(((Object)prefab).name + " already has a Special skill; no Teleport.")); } if (flag || flag2) { EntityStateMachine obj = prefab.AddComponent<EntityStateMachine>(); obj.customName = "DroneImprovementsAbility"; obj.initialStateType = new SerializableEntityStateType(typeof(Idle)); obj.mainStateType = new SerializableEntityStateType(typeof(Idle)); if (flag) { component.utility = AddSkill(prefab, DisconnectFamily, "DroneDisconnect"); } if (flag2) { component.special = AddSkill(prefab, TeleportFamily, "DroneTeleport"); } } } private static GenericSkill AddSkill(GameObject prefab, SkillFamily family, string slotName) { GenericSkill obj = prefab.AddComponent<GenericSkill>(); obj.skillName = slotName; obj.hideInCharacterSelect = true; obj._skillFamily = family; return obj; } } internal sealed class DroneTeleportState : BaseSkillState { private const string FailSound = "Play_UI_insufficient_funds"; public override void OnEnter() { ((BaseState)this).OnEnter(); if (((EntityState)this).isAuthority && !DroneTeleport.TryTeleport(((EntityState)this).characterBody)) { DroneImprovementsPlugin.Log.LogDebug((object)"Teleport cancelled: nobody to teleport to."); if (Object.op_Implicit((Object)(object)((BaseSkillState)this).activatorSkillSlot)) { ((BaseSkillState)this).activatorSkillSlot.AddOneStock(); } Util.PlaySound("Play_UI_insufficient_funds", ((Component)RoR2Application.instance).gameObject); } } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if (((EntityState)this).isAuthority) { ((EntityState)this).outer.SetNextStateToMain(); } } public override InterruptPriority GetMinimumInterruptPriority() { return (InterruptPriority)0; } } internal sealed class DroneDisconnectState : BaseSkillState { private const float HostResponseTimeout = 3f; private const float FullDisplayMargin = 0.01f; private float holdDuration; private bool requested; public override void OnEnter() { ((BaseState)this).OnEnter(); holdDuration = Mathf.Max(0f, PluginConfig.DisconnectHoldSeconds.Value); } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if (!((EntityState)this).isAuthority) { return; } if (!requested) { if (!IsDisconnectKeyHeld()) { ((EntityState)this).outer.SetNextStateToMain(); return; } ShowHoldProgress(); if (((EntityState)this).fixedAge >= holdDuration) { requested = true; DroneNetworking.RequestDisconnect(((EntityState)this).characterBody); } } else if (((EntityState)this).fixedAge >= holdDuration + 3f) { ((EntityState)this).outer.SetNextStateToMain(); } } private void ShowHoldProgress() { if (Object.op_Implicit((Object)(object)((BaseSkillState)this).activatorSkillSlot)) { float num = ((holdDuration > 0f) ? Mathf.Clamp01(((EntityState)this).fixedAge / holdDuration) : 1f); float num2 = ((BaseSkillState)this).activatorSkillSlot.CalculateFinalRechargeInterval() - 0.01f; ((BaseSkillState)this).activatorSkillSlot.rechargeStopwatch = num * num2; } } private bool IsDisconnectKeyHeld() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00ab: Expected I4, but got Unknown CharacterMaster val = (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) ? ((EntityState)this).characterBody.master : null); PlayerCharacterMasterController val2 = (Object.op_Implicit((Object)(object)val) ? val.playerCharacterMasterController : null); NetworkUser val3 = (Object.op_Implicit((Object)(object)val2) ? val2.networkUser : null); LocalUser val4 = (Object.op_Implicit((Object)(object)val3) ? val3.localUser : null); if (((val4 != null) ? val4.inputPlayer : null) == null) { return ((BaseSkillState)this).IsKeyDownAuthority(); } if (val4.isUIFocused) { return false; } SkillSlot val5 = (SkillSlot)((!Object.op_Implicit((Object)(object)((EntityState)this).skillLocator)) ? (-1) : ((int)((EntityState)this).skillLocator.FindSkillSlot(((BaseSkillState)this).activatorSkillSlot))); int num; switch ((int)val5) { case 0: num = 7; break; case 1: num = 8; break; case 2: num = 9; break; case 3: num = 10; break; default: return ((BaseSkillState)this).IsKeyDownAuthority(); } return val4.inputPlayer.GetButton(num); } public override void OnExit() { if (Object.op_Implicit((Object)(object)((BaseSkillState)this).activatorSkillSlot)) { ((BaseSkillState)this).activatorSkillSlot.stock = ((BaseSkillState)this).activatorSkillSlot.maxStock; ((BaseSkillState)this).activatorSkillSlot.rechargeStopwatch = 0f; } ((EntityState)this).OnExit(); } public override InterruptPriority GetMinimumInterruptPriority() { return (InterruptPriority)0; } } } namespace DroneImprovements.Hooks { internal static class AllPlayersCheckHooks { [CompilerGenerated] private static class <>O { public static hook_SetEncounteredBodies <0>__MultiBodyTrigger_SetEncounteredBodies; public static hook_FixedUpdate <1>__AllPlayersTrigger_FixedUpdate; public static hook_CountLivingPlayers <2>__EscapeSequenceExtractionZone_CountLivingPlayers; public static hook_GetPlayersInRadius <3>__EscapeSequenceExtractionZone_GetPlayersInRadius; public static hook_KillAllStragglers <4>__EscapeSequenceExtractionZone_KillAllStragglers; public static Predicate<CharacterBody> <5>__IsDronePlayer; } public static void Init() { //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>__MultiBodyTrigger_SetEncounteredBodies; if (obj == null) { hook_SetEncounteredBodies val = MultiBodyTrigger_SetEncounteredBodies; <>O.<0>__MultiBodyTrigger_SetEncounteredBodies = val; obj = (object)val; } MultiBodyTrigger.SetEncounteredBodies += (hook_SetEncounteredBodies)obj; object obj2 = <>O.<1>__AllPlayersTrigger_FixedUpdate; if (obj2 == null) { hook_FixedUpdate val2 = AllPlayersTrigger_FixedUpdate; <>O.<1>__AllPlayersTrigger_FixedUpdate = val2; obj2 = (object)val2; } AllPlayersTrigger.FixedUpdate += (hook_FixedUpdate)obj2; object obj3 = <>O.<2>__EscapeSequenceExtractionZone_CountLivingPlayers; if (obj3 == null) { hook_CountLivingPlayers val3 = EscapeSequenceExtractionZone_CountLivingPlayers; <>O.<2>__EscapeSequenceExtractionZone_CountLivingPlayers = val3; obj3 = (object)val3; } EscapeSequenceExtractionZone.CountLivingPlayers += (hook_CountLivingPlayers)obj3; object obj4 = <>O.<3>__EscapeSequenceExtractionZone_GetPlayersInRadius; if (obj4 == null) { hook_GetPlayersInRadius val4 = EscapeSequenceExtractionZone_GetPlayersInRadius; <>O.<3>__EscapeSequenceExtractionZone_GetPlayersInRadius = val4; obj4 = (object)val4; } EscapeSequenceExtractionZone.GetPlayersInRadius += (hook_GetPlayersInRadius)obj4; object obj5 = <>O.<4>__EscapeSequenceExtractionZone_KillAllStragglers; if (obj5 == null) { hook_KillAllStragglers val5 = EscapeSequenceExtractionZone_KillAllStragglers; <>O.<4>__EscapeSequenceExtractionZone_KillAllStragglers = val5; obj5 = (object)val5; } EscapeSequenceExtractionZone.KillAllStragglers += (hook_KillAllStragglers)obj5; } private static void MultiBodyTrigger_SetEncounteredBodies(orig_SetEncounteredBodies orig, MultiBodyTrigger self, List<CharacterBody> newEncounteredBodies, int candidateCount) { if (candidateCount > 0 && self.playerControlledOnly && HostSettings.IgnoreDronesForAllPlayerChecks) { int num = DroneUtil.CountSurvivorPlayers(); candidateCount = ((num > 0) ? (num + DroneUtil.CountDronePlayers(newEncounteredBodies)) : 0); } orig.Invoke(self, newEncounteredBodies, candidateCount); } private static void AllPlayersTrigger_FixedUpdate(orig_FixedUpdate orig, AllPlayersTrigger self) { if (!HostSettings.IgnoreDronesForAllPlayerChecks) { orig.Invoke(self); } else { if (!Object.op_Implicit((Object)(object)Run.instance)) { return; } int num = 0; List<CharacterBody> list = CollectionPool<CharacterBody, List<CharacterBody>>.RentCollection(); Queue<Collider> collisionQueueServer = self.collisionQueueServer; while (collisionQueueServer.Count > 0) { Collider val = collisionQueueServer.Dequeue(); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CharacterBody>() : null); if (DroneUtil.IsSurvivorPlayer(val2) && !list.Contains(val2)) { list.Add(val2); num++; } } CollectionPool<CharacterBody, List<CharacterBody>>.ReturnCollection(list); bool flag = num == DroneUtil.CountSurvivorPlayers() && num != 0; if (self.triggerActiveServer != flag) { self.triggerActiveServer = flag; UnityEvent obj = (flag ? self.onTriggerStart : self.onTriggerEnd); if (obj != null) { obj.Invoke(); } } } } private static int EscapeSequenceExtractionZone_CountLivingPlayers(orig_CountLivingPlayers orig, TeamIndex teamIndex) { //IL_0001: 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) int num = orig.Invoke(teamIndex); if (HostSettings.IgnoreDronesForAllPlayerChecks) { num -= DroneUtil.CountDronePlayers(teamIndex); } return num; } private static int EscapeSequenceExtractionZone_GetPlayersInRadius(orig_GetPlayersInRadius orig, EscapeSequenceExtractionZone self, Vector3 origin, float chargingRadiusSqr, TeamIndex teamIndex, List<CharacterBody> dest) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) int result = orig.Invoke(self, origin, chargingRadiusSqr, teamIndex, dest); if (HostSettings.IgnoreDronesForAllPlayerChecks) { dest.RemoveAll(DroneUtil.IsDronePlayer); } return result; } private static void EscapeSequenceExtractionZone_KillAllStragglers(orig_KillAllStragglers orig, EscapeSequenceExtractionZone self) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (HostSettings.IgnoreDronesForAllPlayerChecks) { List<CharacterBody> playersInRadius = self.playersInRadius; ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(self.teamIndex); for (int i = 0; i < teamMembers.Count; i++) { CharacterBody body = teamMembers[i].body; if (DroneUtil.IsDronePlayer(body) && self.IsBodyInRadius(body) && !playersInRadius.Contains(body)) { playersInRadius.Add(body); } } } orig.Invoke(self); } } internal static class ArenaVoidKillHooks { [CompilerGenerated] private static class <>O { public static hook_KillAllOutsideWithVoidDeath <0>__MultiBodyTrigger_KillAllOutsideWithVoidDeath; public static hook_TrueKill_GameObject_GameObject_DamageTypeCombo <1>__CharacterMaster_TrueKill_GameObject_GameObject_DamageTypeCombo; } private static bool isVoidKillRunning; public static void Init() { //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 object obj = <>O.<0>__MultiBodyTrigger_KillAllOutsideWithVoidDeath; if (obj == null) { hook_KillAllOutsideWithVoidDeath val = MultiBodyTrigger_KillAllOutsideWithVoidDeath; <>O.<0>__MultiBodyTrigger_KillAllOutsideWithVoidDeath = val; obj = (object)val; } MultiBodyTrigger.KillAllOutsideWithVoidDeath += (hook_KillAllOutsideWithVoidDeath)obj; object obj2 = <>O.<1>__CharacterMaster_TrueKill_GameObject_GameObject_DamageTypeCombo; if (obj2 == null) { hook_TrueKill_GameObject_GameObject_DamageTypeCombo val2 = CharacterMaster_TrueKill_GameObject_GameObject_DamageTypeCombo; <>O.<1>__CharacterMaster_TrueKill_GameObject_GameObject_DamageTypeCombo = val2; obj2 = (object)val2; } CharacterMaster.TrueKill_GameObject_GameObject_DamageTypeCombo += (hook_TrueKill_GameObject_GameObject_DamageTypeCombo)obj2; } private static void MultiBodyTrigger_KillAllOutsideWithVoidDeath(orig_KillAllOutsideWithVoidDeath orig, MultiBodyTrigger self) { isVoidKillRunning = true; try { orig.Invoke(self); } finally { isVoidKillRunning = false; } } private static void CharacterMaster_TrueKill_GameObject_GameObject_DamageTypeCombo(orig_TrueKill_GameObject_GameObject_DamageTypeCombo orig, CharacterMaster self, GameObject killerOverride, GameObject inflictorOverride, DamageTypeCombo damageTypeOverride) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!isVoidKillRunning || !HostSettings.SpareDronesFromArenaVoidKill || !DroneUtil.IsDronePlayer(self.GetBody())) { orig.Invoke(self, killerOverride, inflictorOverride, damageTypeOverride); } } } internal static class FlightHooks { [CompilerGenerated] private static class <>O { public static Manipulator <0>__PlayerFlyState_PerformInputs; public static Func<bool, PlayerFlyState, bool> <1>__IsDescending; public static Func<Vector3, PlayerFlyState, Vector3> <2>__ApplySprintSpeed; } private static bool SprintFliesFaster => HostSettings.SprintSpeedMultiplier > 1f; public static void Init() { //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>__PlayerFlyState_PerformInputs; if (obj == null) { Manipulator val = PlayerFlyState_PerformInputs; <>O.<0>__PlayerFlyState_PerformInputs = val; obj = (object)val; } PlayerFlyState.PerformInputs += (Manipulator)obj; } private static void PlayerFlyState_PerformInputs(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_00dd: 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) ILCursor val = new ILCursor(il); ILCursor val2 = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdflda(x, typeof(InputBankTest), "sprint"), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(ButtonState), "down") })) { DroneImprovementsPlugin.Log.LogError((object)("IL hook " + ((MemberReference)il.Method).Name + " failed: the sprint read that makes the drone fly down was not found.")); return; } if (!val2.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, typeof(RigidbodyMotor), "moveVector") })) { DroneImprovementsPlugin.Log.LogError((object)("IL hook " + ((MemberReference)il.Method).Name + " failed: the store into the RigidbodyMotor's moveVector was not found.")); return; } val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<bool, PlayerFlyState, bool>>((Func<bool, PlayerFlyState, bool>)IsDescending); val2.Emit(OpCodes.Ldarg_0); val2.EmitDelegate<Func<Vector3, PlayerFlyState, Vector3>>((Func<Vector3, PlayerFlyState, Vector3>)ApplySprintSpeed); } private static bool IsDescending(bool sprintDown, PlayerFlyState state) { CharacterBody characterBody = ((EntityState)state).characterBody; if (!DroneUtil.IsDronePlayer(characterBody)) { return sprintDown; } if (!IsDescendKeyHeld(characterBody)) { if (sprintDown) { return !SprintFliesFaster; } return false; } return true; } private static Vector3 ApplySprintSpeed(Vector3 moveVector, PlayerFlyState state) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (SprintFliesFaster && ((EntityState)state).inputBank.sprint.down && DroneUtil.IsDronePlayer(((EntityState)state).characterBody)) { return moveVector * HostSettings.SprintSpeedMultiplier; } return moveVector; } private static bool IsDescendKeyHeld(CharacterBody body) { //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_002d: Unknown result type (might be due to invalid IL or missing references) LocalUser val = default(LocalUser); Player val2 = default(Player); CameraRigController val3 = default(CameraRigController); bool flag = default(bool); if (PlayerCharacterMasterController.CanSendBodyInput(body.master.playerCharacterMasterController.networkUser, ref val, ref val2, ref val3, ref flag)) { KeyboardShortcut value = PluginConfig.DescendKey.Value; return Input.GetKey(((KeyboardShortcut)(ref value)).MainKey); } return false; } } internal static class GoldHooks { [CompilerGenerated] private static class <>O { public static hook_OnKilledServer <0>__DeathRewards_OnKilledServer; public static hook_OnTriggerStay <1>__MoneyPickup_OnTriggerStay; public static hook_OnHitEnemy <2>__GlobalEventManager_OnHitEnemy; public static hook_TakeDamage <3>__HealthComponent_TakeDamage; public static hook_GiveTeamMoney_TeamIndex_uint_bool <4>__TeamManager_GiveTeamMoney_TeamIndex_uint_bool; public static hook_AddOrb <5>__OrbManager_AddOrb; public static hook_OnArrival <6>__GoldOrb_OnArrival; public static hook_GiveMoney_uint_bool <7>__CharacterMaster_GiveMoney_uint_bool; public static hook_OnInteractionBegin <8>__BarrelInteraction_OnInteractionBegin; public static hook_GetInteractability <9>__BarrelInteraction_GetInteractability; public static hook_GetInteractability <10>__PurchaseInteraction_GetInteractability; } private static readonly ConditionalWeakTable<GoldOrb, object> combatOrbs = new ConditionalWeakTable<GoldOrb, object>(); private static readonly object marker = new object(); private static int combatContextDepth; private static int barrelContextDepth; private static bool InCombatContext => combatContextDepth > 0; private static bool InBarrelContext => barrelContextDepth > 0; private static bool ShouldExcludeDronesFromTeamPayout { get { if (HostSettings.CombatGold || !InCombatContext) { if (!HostSettings.BarrelGold) { return InBarrelContext; } return false; } return true; } } public static void Init() { //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 //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //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_011b: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown object obj = <>O.<0>__DeathRewards_OnKilledServer; if (obj == null) { hook_OnKilledServer val = DeathRewards_OnKilledServer; <>O.<0>__DeathRewards_OnKilledServer = val; obj = (object)val; } DeathRewards.OnKilledServer += (hook_OnKilledServer)obj; object obj2 = <>O.<1>__MoneyPickup_OnTriggerStay; if (obj2 == null) { hook_OnTriggerStay val2 = MoneyPickup_OnTriggerStay; <>O.<1>__MoneyPickup_OnTriggerStay = val2; obj2 = (object)val2; } MoneyPickup.OnTriggerStay += (hook_OnTriggerStay)obj2; object obj3 = <>O.<2>__GlobalEventManager_OnHitEnemy; if (obj3 == null) { hook_OnHitEnemy val3 = GlobalEventManager_OnHitEnemy; <>O.<2>__GlobalEventManager_OnHitEnemy = val3; obj3 = (object)val3; } GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj3; object obj4 = <>O.<3>__HealthComponent_TakeDamage; if (obj4 == null) { hook_TakeDamage val4 = HealthComponent_TakeDamage; <>O.<3>__HealthComponent_TakeDamage = val4; obj4 = (object)val4; } HealthComponent.TakeDamage += (hook_TakeDamage)obj4; object obj5 = <>O.<4>__TeamManager_GiveTeamMoney_TeamIndex_uint_bool; if (obj5 == null) { hook_GiveTeamMoney_TeamIndex_uint_bool val5 = TeamManager_GiveTeamMoney_TeamIndex_uint_bool; <>O.<4>__TeamManager_GiveTeamMoney_TeamIndex_uint_bool = val5; obj5 = (object)val5; } TeamManager.GiveTeamMoney_TeamIndex_uint_bool += (hook_GiveTeamMoney_TeamIndex_uint_bool)obj5; object obj6 = <>O.<5>__OrbManager_AddOrb; if (obj6 == null) { hook_AddOrb val6 = OrbManager_AddOrb; <>O.<5>__OrbManager_AddOrb = val6; obj6 = (object)val6; } OrbManager.AddOrb += (hook_AddOrb)obj6; object obj7 = <>O.<6>__GoldOrb_OnArrival; if (obj7 == null) { hook_OnArrival val7 = GoldOrb_OnArrival; <>O.<6>__GoldOrb_OnArrival = val7; obj7 = (object)val7; } GoldOrb.OnArrival += (hook_OnArrival)obj7; object obj8 = <>O.<7>__CharacterMaster_GiveMoney_uint_bool; if (obj8 == null) { hook_GiveMoney_uint_bool val8 = CharacterMaster_GiveMoney_uint_bool; <>O.<7>__CharacterMaster_GiveMoney_uint_bool = val8; obj8 = (object)val8; } CharacterMaster.GiveMoney_uint_bool += (hook_GiveMoney_uint_bool)obj8; object obj9 = <>O.<8>__BarrelInteraction_OnInteractionBegin; if (obj9 == null) { hook_OnInteractionBegin val9 = BarrelInteraction_OnInteractionBegin; <>O.<8>__BarrelInteraction_OnInteractionBegin = val9; obj9 = (object)val9; } BarrelInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj9; object obj10 = <>O.<9>__BarrelInteraction_GetInteractability; if (obj10 == null) { hook_GetInteractability val10 = BarrelInteraction_GetInteractability; <>O.<9>__BarrelInteraction_GetInteractability = val10; obj10 = (object)val10; } BarrelInteraction.GetInteractability += (hook_GetInteractability)obj10; object obj11 = <>O.<10>__PurchaseInteraction_GetInteractability; if (obj11 == null) { hook_GetInteractability val11 = PurchaseInteraction_GetInteractability; <>O.<10>__PurchaseInteraction_GetInteractability = val11; obj11 = (object)val11; } PurchaseInteraction.GetInteractability += (hook_GetInteractability)obj11; } private static void DeathRewards_OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport) { combatContextDepth++; try { orig.Invoke(self, damageReport); } finally { combatContextDepth--; } } private static void MoneyPickup_OnTriggerStay(orig_OnTriggerStay orig, MoneyPickup self, Collider other) { combatContextDepth++; try { orig.Invoke(self, other); } finally { combatContextDepth--; } } private static void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim) { combatContextDepth++; try { orig.Invoke(self, damageInfo, victim); } finally { combatContextDepth--; } } private static void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { combatContextDepth++; try { orig.Invoke(self, damageInfo); } finally { combatContextDepth--; } } private static void BarrelInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, BarrelInteraction self, Interactor activator) { barrelContextDepth++; try { orig.Invoke(self, activator); } finally { barrelContextDepth--; } } private static void TeamManager_GiveTeamMoney_TeamIndex_uint_bool(orig_GiveTeamMoney_TeamIndex_uint_bool orig, TeamManager self, TeamIndex teamIndex, uint money, bool bypassStatManager) { //IL_0010: 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) if (!NetworkServer.active || !ShouldExcludeDronesFromTeamPayout) { orig.Invoke(self, teamIndex, money, bypassStatManager); return; } int num = DroneUtil.CountSurvivorPlayers(); uint num2 = ((num != 0) ? ((uint)Mathf.CeilToInt((float)money / (float)num)) : money); ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex); for (int i = 0; i < teamMembers.Count; i++) { CharacterBody body = teamMembers[i].body; if (DroneUtil.IsSurvivorPlayer(body) && Object.op_Implicit((Object)(object)body.master)) { body.master.GiveMoney(num2, bypassStatManager); } } } private static void OrbManager_AddOrb(orig_AddOrb orig, OrbManager self, Orb orb) { GoldOrb val = (GoldOrb)(object)((orb is GoldOrb) ? orb : null); if (val != null && InCombatContext) { combatOrbs.GetValue(val, (GoldOrb _) => marker); } orig.Invoke(self, orb); } private static void GoldOrb_OnArrival(orig_OnArrival orig, GoldOrb self) { if (!HostSettings.CombatGold && combatOrbs.TryGetValue(self, out var _)) { HurtBox target = ((Orb)self).target; if (DroneUtil.IsDronePlayer((Object.op_Implicit((Object)(object)target) && Object.op_Implicit((Object)(object)target.healthComponent)) ? target.healthComponent.body : null)) { return; } } orig.Invoke(self); } private static void CharacterMaster_GiveMoney_uint_bool(orig_GiveMoney_uint_bool orig, CharacterMaster self, uint amount, bool bypassStatManager) { if (HostSettings.CombatGold || !InCombatContext || !DroneUtil.IsDronePlayer(self.GetBody())) { orig.Invoke(self, amount, bypassStatManager); } } private static Interactability BarrelInteraction_GetInteractability(orig_GetInteractability orig, BarrelInteraction self, Interactor activator) { //IL_0003: 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_0009: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); if ((int)val != 0 && !HostSettings.BarrelGold && DroneUtil.IsDronePlayer(((Component)activator).GetComponent<CharacterBody>())) { val = (Interactability)0; } return val; } private static Interactability PurchaseInteraction_GetInteractability(orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { //IL_0003: 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_0009: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); if ((int)val != 0 && !HostSettings.ShrineOfBloodGold && DroneUtil.IsDronePlayer(((Component)activator).GetComponent<CharacterBody>()) && Object.op_Implicit((Object)(object)((Component)self).GetComponent<ShrineBloodBehavior>())) { val = (Interactability)0; } return val; } } internal static class HoldoutZoneHooks { [CompilerGenerated] private static class <>O { public static hook_DoUpdate <0>__HoldoutZoneController_DoUpdate; public static hook_CountLivingPlayers <1>__HoldoutZoneController_CountLivingPlayers; public static hook_CountPlayersInRadius <2>__HoldoutZoneController_CountPlayersInRadius; } private static HoldoutZoneController currentZone; public static void Init() { //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>__HoldoutZoneController_DoUpdate; if (obj == null) { hook_DoUpdate val = HoldoutZoneController_DoUpdate; <>O.<0>__HoldoutZoneController_DoUpdate = val; obj = (object)val; } HoldoutZoneController.DoUpdate += (hook_DoUpdate)obj; object obj2 = <>O.<1>__HoldoutZoneController_CountLivingPlayers; if (obj2 == null) { hook_CountLivingPlayers val2 = HoldoutZoneController_CountLivingPlayers; <>O.<1>__HoldoutZoneController_CountLivingPlayers = val2; obj2 = (object)val2; } HoldoutZoneController.CountLivingPlayers += (hook_CountLivingPlayers)obj2; object obj3 = <>O.<2>__HoldoutZoneController_CountPlayersInRadius; if (obj3 == null) { hook_CountPlayersInRadius val3 = HoldoutZoneController_CountPlayersInRadius; <>O.<2>__HoldoutZoneController_CountPlayersInRadius = val3; obj3 = (object)val3; } HoldoutZoneController.CountPlayersInRadius += (hook_CountPlayersInRadius)obj3; } private static void HoldoutZoneController_DoUpdate(orig_DoUpdate orig, HoldoutZoneController self, float deltaTime) { currentZone = self; try { orig.Invoke(self, deltaTime); } finally { currentZone = null; } } private static int HoldoutZoneController_CountLivingPlayers(orig_CountLivingPlayers orig, TeamIndex teamIndex) { //IL_0001: 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) return orig.Invoke(teamIndex) + CountDronesInside(teamIndex); } private static int HoldoutZoneController_CountPlayersInRadius(orig_CountPlayersInRadius orig, HoldoutZoneController holdoutZoneController, Vector3 origin, float chargingRadiusSqr, TeamIndex teamIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) int num = orig.Invoke(holdoutZoneController, origin, chargingRadiusSqr, teamIndex); if ((Object)(object)holdoutZoneController == (Object)(object)currentZone) { num += CountDronesInside(teamIndex); } return num; } private static int CountDronesInside(TeamIndex teamIndex) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) HoldoutZoneController val = currentZone; if (!Object.op_Implicit((Object)(object)val) || !HostSettings.DronesCanChargeHoldoutZones) { return 0; } int num = 0; ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex); for (int i = 0; i < teamMembers.Count; i++) { CharacterBody body = teamMembers[i].body; if (DroneUtil.IsDronePlayer(body) && val.IsBodyInChargingRadius(body)) { num++; } } return num; } } internal static class InteractionHooks { [CompilerGenerated] private static class <>O { public static hook_Start <0>__CharacterBody_Start; public static hook_BodyHasPickupPermission <1>__GenericPickupController_BodyHasPickupPermission; } public static void Init() { //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 object obj = <>O.<0>__CharacterBody_Start; if (obj == null) { hook_Start val = CharacterBody_Start; <>O.<0>__CharacterBody_Start = val; obj = (object)val; } CharacterBody.Start += (hook_Start)obj; object obj2 = <>O.<1>__GenericPickupController_BodyHasPickupPermission; if (obj2 == null) { hook_BodyHasPickupPermission val2 = GenericPickupController_BodyHasPickupPermission; <>O.<1>__GenericPickupController_BodyHasPickupPermission = val2; obj2 = (object)val2; } GenericPickupController.BodyHasPickupPermission += (hook_BodyHasPickupPermission)obj2; } public static void ApplySettingToExistingDrones() { bool isRemoteOp = !HostSettings.SurvivorActions; ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList; Interactor val2 = default(Interactor); for (int i = 0; i < readOnlyInstancesList.Count; i++) { CharacterBody val = readOnlyInstancesList[i]; if (val.isRemoteOp && ((Component)val).TryGetComponent<Interactor>(ref val2)) { val2.isRemoteOp = isRemoteOp; } } } private static void CharacterBody_Start(orig_Start orig, CharacterBody self) { orig.Invoke(self); Interactor val = default(Interactor); if (self.isRemoteOp && HostSettings.SurvivorActions && ((Component)self).TryGetComponent<Interactor>(ref val)) { val.isRemoteOp = false; } } private static bool GenericPickupController_BodyHasPickupPermission(orig_BodyHasPickupPermission orig, CharacterBody body, UniquePickup pickupState) { //IL_0002: 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) bool flag = orig.Invoke(body, pickupState); if (!flag && DroneUtil.IsDronePlayer(body) && Object.op_Implicit((Object)(object)body.inventory) && HostSettings.SurvivorActions) { flag = !IsObjectiveItem(pickupState); } return flag; } private static bool IsObjectiveItem(UniquePickup pickup) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0016: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { return false; } ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (Object.op_Implicit((Object)(object)itemDef)) { if (!itemDef.ContainsTag((ItemTag)26)) { return itemDef.ContainsTag((ItemTag)32); } return true; } return false; } } }