using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OpDroneTrans")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0cf7af91529935736781c7624be5737ddd0e3703")] [assembly: AssemblyProduct("OpDroneTrans")] [assembly: AssemblyTitle("OpDroneTrans")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OpDroneTrans { [BepInPlugin("com.operatordronetransparency", "Operator Drone Transparency", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class OpDroneTransPlugin : BaseUnityPlugin { public const string PluginGUID = "com.operatordronetransparency"; public const string PluginName = "Operator Drone Transparency"; public const string PluginVersion = "1.0.2"; private static ConfigEntry opacityConfig; private static ConfigEntry showGlowConfig; private static ConfigEntry enableLogging; private static ManualLogSource Log; private static readonly HashSet trackedDrones = new HashSet(); private static CharacterModel currentQueuedDrone = null; private static Highlight currentDroneHighlight = null; private static readonly string[] DroneBodyNames = new string[20] { "DTHealingDroneBody", "DTHaulerDroneBody", "DTGunnerDroneBody", "RechargeDroneBody", "BombardmentDroneBody", "CleanupDroneBody", "EmergencyDroneBody", "EquipmentDroneBody", "CopycatDroneBody", "Drone1Body", "Drone2Body", "FlameDroneBody", "JailerDroneBody", "JunkDroneBody", "MissileDroneBody", "MegaDroneBody", "HaulerDroneBody", "BackupDroneBody", "DroneBomberBody", "DroneCommanderBody" }; public void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; opacityConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Drone Opacity", 20f, new ConfigDescription("Opacity of the Operator's companion drone model (0 = invisible, 100 = fully opaque)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); showGlowConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Show Drone Glow", false, "Show the highlight glow overlay on the companion drone."); enableLogging = ((BaseUnityPlugin)this).Config.Bind("Debug", "Enable Body Name Logging", false, "Log all CharacterModel body names to help identify the correct drone names."); InitRiskOfOptions(); CharacterModel.Start += new hook_Start(CharacterModel_Start); CharacterModel.UpdateMaterials += new hook_UpdateMaterials(CharacterModel_UpdateMaterials); CharacterModel.OnDestroy += new hook_OnDestroy(CharacterModel_OnDestroy); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Operator Drone Transparency v1.0.2 loaded."); } public void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown CharacterModel.Start -= new hook_Start(CharacterModel_Start); CharacterModel.UpdateMaterials -= new hook_UpdateMaterials(CharacterModel_UpdateMaterials); CharacterModel.OnDestroy -= new hook_OnDestroy(CharacterModel_OnDestroy); trackedDrones.Clear(); currentQueuedDrone = null; currentDroneHighlight = null; } private void CharacterModel_Start(orig_Start orig, CharacterModel self) { orig.Invoke(self); if (enableLogging.Value) { string text = (Object.op_Implicit((Object)(object)self.body) ? ((Object)self.body).name : "null"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[OpDroneTrans] CharacterModel body name: " + text)); } if (IsOperatorDrone(self)) { trackedDrones.Add(self); if (enableLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[OpDroneTrans] Tracking drone: " + ((Object)self.body).name)); } } } private void CharacterModel_OnDestroy(orig_OnDestroy orig, CharacterModel self) { if (trackedDrones.Remove(self) && (Object)(object)currentQueuedDrone == (Object)(object)self) { currentQueuedDrone = null; currentDroneHighlight = null; } orig.Invoke(self); } private void CharacterModel_UpdateMaterials(orig_UpdateMaterials orig, CharacterModel self) { if (trackedDrones.Contains(self)) { if ((self.invisibilityCount > 0 || self.fade < 1f) && (Object)(object)currentQueuedDrone != (Object)(object)self) { if ((Object)(object)currentQueuedDrone != (Object)null) { currentQueuedDrone.invisibilityCount = 0; currentQueuedDrone.fade = 1f; } currentQueuedDrone = self; currentDroneHighlight = ((Component)self).GetComponent(); } if ((Object)(object)self == (Object)(object)currentQueuedDrone) { float num = opacityConfig.Value / 100f; if (enableLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[OpDroneTrans] Queued drone: {((Object)self.body).name} fade={self.fade} invisCount={self.invisibilityCount} -> targetFade={num}"); } if (num <= 0.001f) { self.invisibilityCount = 1; orig.Invoke(self); } else { self.invisibilityCount = 0; self.fade = num; orig.Invoke(self); } if ((Object)(object)currentDroneHighlight == (Object)null) { currentDroneHighlight = ((Component)self).GetComponent(); } if ((Object)(object)currentDroneHighlight != (Object)null) { if (showGlowConfig.Value && num > 0.001f) { currentDroneHighlight.isOn = true; } else { currentDroneHighlight.isOn = false; } } return; } } orig.Invoke(self); } private static bool IsOperatorDrone(CharacterModel model) { if ((Object)(object)model == (Object)null || (Object)(object)model.body == (Object)null) { return false; } string name = ((Object)model.body).name; bool flag = false; string[] droneBodyNames = DroneBodyNames; foreach (string value in droneBodyNames) { if (name.Contains(value)) { flag = true; break; } } if (!flag && name.StartsWith("DT") && name.Contains("Drone") && !name.Contains("DroneTechBody")) { flag = true; } if (!flag) { return false; } if (!IsOwnedByLocalPlayer(model.body)) { return false; } return true; } private static bool IsOwnedByLocalPlayer(CharacterBody body) { if ((Object)(object)body == (Object)null || (Object)(object)body.master == (Object)null) { return false; } MinionOwnership minionOwnership = body.master.minionOwnership; if ((Object)(object)minionOwnership == (Object)null || (Object)(object)minionOwnership.ownerMaster == (Object)null) { return false; } CharacterMaster ownerMaster = minionOwnership.ownerMaster; LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser == null || (Object)(object)firstLocalUser.cachedMasterController == (Object)null) { return false; } if ((Object)(object)ownerMaster != (Object)(object)firstLocalUser.cachedMasterController.master) { return false; } CharacterBody body2 = ownerMaster.GetBody(); string text = (((Object)(object)body2 != (Object)null) ? ((Object)body2).name : "null"); bool flag = (Object)(object)body2 != (Object)null && text.Contains("DroneTech"); if (enableLogging.Value) { Log.LogInfo((object)$"[OpDroneTrans] Ownership check — drone: {((Object)body).name}, ownerBody: {text}, isDroneTech: {flag}"); } return flag; } private void InitRiskOfOptions() { try { RiskOfOptionsHelper.Init(opacityConfig, showGlowConfig); } catch (Exception) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"RiskOfOptions not installed — using config file only."); } } } internal static class RiskOfOptionsHelper { internal static void Init(ConfigEntry opacityConfig, ConfigEntry showGlowConfig) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StepSliderOption(opacityConfig, new StepSliderConfig { min = 0f, max = 100f, increment = 1f, FormatString = "{0:0}%" })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(showGlowConfig)); ModSettingsManager.SetModDescription("Adjust the transparency and glow of the Operator's companion drone."); } } }