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 Player Bounties v1.0.0
Bounty.dll
Decompiled 7 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Bounty")] [assembly: AssemblyTitle("Bounty")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Empress.REPO.BountyHunt { [BepInPlugin("empress.repo.bountyhunt", "Empress Bounty Hunt", "1.4.2")] public class BountyPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <LevelWatcher>d__23 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BountyPlugin <>4__this; private bool <playersReady>5__1; private bool <mainState>5__2; private BountyManager <mgr>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LevelWatcher>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <mgr>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; if (!EnableMode.Value || !SemiFunc.IsMultiplayer() || !PhotonNetwork.InRoom || SemiFunc.MenuLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null) { break; } <playersReady>5__1 = GameDirector.instance.PlayerList != null && GameDirector.instance.PlayerList.Count > 0; <mainState>5__2 = (int)GameDirector.instance.currentState == 2; if (!<playersReady>5__1 || !<mainState>5__2) { break; } <>4__this.CreateManagersIfMissing(); <mgr>5__3 = BountyManager.Instance; if (!((Object)(object)<mgr>5__3 == (Object)null)) { <mgr>5__3.EnsureHudBoundForAllPlayers(); if (!<mgr>5__3.HasAssignedThisLevel) { <mgr>5__3.TryAssignRandomBountyThisLevel(); } <mgr>5__3 = null; } break; } <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ConfigEntry<bool> EnableMode; internal static ConfigEntry<float> ChancePerLevel; internal static ConfigEntry<int> MinDollars; internal static ConfigEntry<int> MaxDollars; internal static ConfigEntry<float> DurationSeconds; internal static ConfigEntry<bool> OnlyOneBountyPerLevel; private const string AsciiBanner = "\r\n ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ \r\n▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌\r\n▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌▐░▌░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░▌ ▐░▌\r\n▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌\r\n▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌\r\n▐░░░░░░░░░░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌\r\n▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ \r\n▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ \r\n▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▐░▌ ▐░▌ ▐░▌ \r\n▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░░▌ ▐░▌ ▐░▌ \r\n ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ▀ ▀ "; internal static BountyPlugin Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony Harmony { get; private set; } private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)this); Harmony = new Harmony("empress.repo.bountyhunt"); Harmony.PatchAll(); EnableMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Bounty", "Enable", true, "Enable Bounty Hunt."); ChancePerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Bounty", "ChancePerLevel", 0.45f, "Probability a level spawns a bounty (0..1)."); MinDollars = ((BaseUnityPlugin)this).Config.Bind<int>("Bounty", "MinDollars", 1, "Minimum bounty dollars displayed."); MaxDollars = ((BaseUnityPlugin)this).Config.Bind<int>("Bounty", "MaxDollars", 100000, "Maximum bounty dollars displayed."); DurationSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Bounty", "DurationSeconds", 60f, "Bounty timer seconds."); OnlyOneBountyPerLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Bounty", "OnlyOneBountyPerLevel", true, "At most one bounty per level."); SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(LevelWatcher()); Logger.LogMessage((object)"\r\n ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ \r\n▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░▌ ▐░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌\r\n▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌▐░▌░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ ▐░▌ ▐░▌\r\n▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌\r\n▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄█░▌\r\n▐░░░░░░░░░░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░░░░░░░░░░░▌\r\n▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▀▀▀▀█░█▀▀▀▀ \r\n▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ \r\n▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▐░▌ ▐░▌ ▐░▌ \r\n▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░░▌ ▐░▌ ▐░▌ \r\n ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ▀ ▀ "); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; try { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (EnableMode.Value) { CreateManagersIfMissing(); BountyManager.Instance?.OnNewLevelSceneLoaded(); } } private void CreateManagersIfMissing() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if ((Object)(object)BountyManager.Instance == (Object)null) { GameObject val = new GameObject("Empress_BountyManager"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<BountyManager>(); } if ((Object)(object)BountyEventManager.Instance == (Object)null) { GameObject val2 = new GameObject("Empress_BountyEventManager"); ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); val2.AddComponent<BountyEventManager>(); } } [IteratorStateMachine(typeof(<LevelWatcher>d__23))] private IEnumerator LevelWatcher() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LevelWatcher>d__23(0) { <>4__this = this }; } } internal static class BountyEvt { internal const byte EVT_CODE = 66; internal const string TAG = "BNT1"; internal const byte SET_BOUNTY = 1; private static readonly SendOptions Reliable; private static readonly RaiseEventOptions ToAllCached; internal static void SendAllCached(byte innerId, params object[] args) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) object[] array = Build(innerId, args); PhotonNetwork.RaiseEvent((byte)66, (object)array, ToAllCached, Reliable); } private static object[] Build(byte innerId, object[] args) { object[] array = new object[2 + ((args != null) ? args.Length : 0)]; array[0] = "BNT1"; array[1] = innerId; if (args != null && args.Length != 0) { Array.Copy(args, 0, array, 2, args.Length); } return array; } static BountyEvt() { //IL_0002: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown SendOptions reliable = default(SendOptions); ((SendOptions)(ref reliable)).Reliability = true; Reliable = reliable; ToAllCached = new RaiseEventOptions { Receivers = (ReceiverGroup)1, CachingOption = (EventCaching)4 }; } } public class BountyEventManager : MonoBehaviourPunCallbacks, IOnEventCallback { public static BountyEventManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void OnEnable() { if (PhotonNetwork.NetworkingClient != null) { PhotonNetwork.AddCallbackTarget((object)this); } } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } public void OnEvent(EventData photonEvent) { try { if (photonEvent.Code != 66 || !(photonEvent.CustomData is object[] array) || array.Length < 2 || !(array[0] is string text) || text != "BNT1") { return; } BountyManager instance = BountyManager.Instance; if (!((Object)(object)instance == (Object)null)) { byte b = (byte)array[1]; byte b2 = b; if (b2 == 1 && array.Length >= 6) { int actor = Convert.ToInt32(array[2]); int dollars = Convert.ToInt32(array[3]); double startTime = Convert.ToDouble(array[4]); float duration = Convert.ToSingle(array[5]); instance.ApplyBounty(actor, dollars, startTime, duration); } } } catch (Exception ex) { BountyPlugin.Logger.LogWarning((object)("[Bounty] OnEvent guarded: " + ex.Message)); } } } public class BountyManager : MonoBehaviourPunCallbacks { private readonly HashSet<int> reviveLockedActors = new HashSet<int>(); public static BountyManager Instance { get; private set; } public int TargetActor { get; private set; } = -1; public int BountyDollars { get; private set; } = 0; public double StartTime { get; private set; } = 0.0; public float Duration { get; private set; } = 0f; public bool HasAssignedThisLevel { get; private set; } = false; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } public override void OnJoinedRoom() { ResetForNewLevel(clearHudOnly: true); } public override void OnLeftRoom() { ResetForNewLevel(clearHudOnly: true); } public void OnNewLevelSceneLoaded() { ResetForNewLevel(clearHudOnly: false); } private void ResetForNewLevel(bool clearHudOnly) { if (!clearHudOnly) { TargetActor = -1; BountyDollars = 0; StartTime = 0.0; Duration = 0f; reviveLockedActors.Clear(); HasAssignedThisLevel = false; } PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); foreach (PlayerAvatar val in array) { ((Component)val).GetComponent<BountyHud>()?.SetActive(on: false); } } public bool IsBountyActive() { if (TargetActor <= 0 || Duration <= 0f) { return false; } return PhotonNetwork.Time < StartTime + (double)Duration; } public float GetSecondsRemaining() { if (!IsBountyActive()) { return 0f; } return Mathf.Max(0f, (float)(StartTime + (double)Duration - PhotonNetwork.Time)); } public bool IsReviveLocked(int actor) { return reviveLockedActors.Contains(actor); } public void LockReviveForLevel(int actor) { if (actor > 0) { reviveLockedActors.Add(actor); } } public void EnsureHudBoundForAllPlayers() { try { List<PlayerAvatar> list = GameDirector.instance?.PlayerList; if (list == null) { return; } int num = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : (-1)); foreach (PlayerAvatar item in list) { if (!((Object)(object)item == (Object)null)) { BountyHud bountyHud = ((Component)item).GetComponent<BountyHud>(); if ((Object)(object)bountyHud == (Object)null) { bountyHud = ((Component)item).gameObject.AddComponent<BountyHud>(); bountyHud.Bind(item); } PhotonView photonView = item.photonView; int num2 = (((Object)(object)photonView != (Object)null && photonView.Owner != null) ? photonView.Owner.ActorNumber : (-1)); bool active = num2 == TargetActor && IsBountyActive() && num2 != num; bountyHud.SetActive(active); } } } catch (Exception ex) { BountyPlugin.Logger.LogWarning((object)("[Bounty] EnsureHudBoundForAllPlayers: " + ex.Message)); } } public void TryAssignRandomBountyThisLevel() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 if (HasAssignedThisLevel || (PhotonNetwork.IsConnected && (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient)) || SemiFunc.MenuLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2) { return; } List<PlayerAvatar> playerList = GameDirector.instance.PlayerList; if (playerList == null || playerList.Count == 0) { return; } Random random = new Random(); if (random.NextDouble() > (double)Mathf.Clamp01(BountyPlugin.ChancePerLevel.Value)) { HasAssignedThisLevel = true; return; } PlayerAvatar val = playerList[random.Next(playerList.Count)]; int? obj; if (val == null) { obj = null; } else { PhotonView photonView = val.photonView; if (photonView == null) { obj = null; } else { Player owner = photonView.Owner; obj = ((owner != null) ? new int?(owner.ActorNumber) : null); } } int? num = obj; int valueOrDefault = num.GetValueOrDefault(-1); if (valueOrDefault <= 0) { HasAssignedThisLevel = true; return; } int num2 = Mathf.Max(1, BountyPlugin.MinDollars.Value); int num3 = Mathf.Max(num2, BountyPlugin.MaxDollars.Value); int num4 = random.Next(num2, num3 + 1); float num5 = Mathf.Max(1f, BountyPlugin.DurationSeconds.Value); object[] args = new object[4] { valueOrDefault, num4, PhotonNetwork.Time, num5 }; if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom) { BountyEvt.SendAllCached(1, args); } else { ApplyBounty(valueOrDefault, num4, PhotonNetwork.Time, num5); } HasAssignedThisLevel = true; } public void ApplyBounty(int actor, int dollars, double startTime, float duration) { TargetActor = actor; BountyDollars = dollars; StartTime = startTime; Duration = duration; EnsureHudBoundForAllPlayers(); } public void OnBountyTargetDied(int actor, bool wasInsideExtraction) { if (actor <= 0) { return; } if (wasInsideExtraction && IsBountyActive() && actor == TargetActor) { LockReviveForLevel(actor); if (!PhotonNetwork.IsConnected || PhotonNetwork.IsMasterClient) { int num = Mathf.Max(1, Mathf.RoundToInt((float)BountyDollars / 1000f)); int num2 = SemiFunc.StatGetRunCurrency(); int num3 = Mathf.Max(0, num2 + num); SemiFunc.StatSetRunCurrency(num3); } } PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); foreach (PlayerAvatar val in array) { ((Component)val).GetComponent<BountyHud>()?.SetActive(on: false); } TargetActor = -1; BountyDollars = 0; StartTime = 0.0; Duration = 0f; } internal static bool IsInExtraction(PlayerAvatar p) { try { List<RoomVolume> list = (p?.RoomVolumeCheck)?.CurrentRooms; if (list == null) { return false; } for (int i = 0; i < list.Count; i++) { RoomVolume val = list[i]; if ((Object)(object)val != (Object)null && val.Extraction) { return true; } } } catch { } return false; } } public class BountyHud : MonoBehaviour { private PlayerAvatar _player; private WorldSpaceUIPlayerName _nameplate; private TextMeshProUGUI _nameplateText; private GameObject _root; private WorldSpaceUIChild _wui; private TextMeshProUGUI _text; private bool _shown; private const float WorldYOffset = 0.2f; private static FieldInfo _fiWorldPos; private static FieldInfo _fiNameText; public void Bind(PlayerAvatar p) { _player = p; TryFindNameplate(); TrySetupUI(); UpdateImmediateText(); } public void SetActive(bool on) { if (_shown != on) { _shown = on; if ((Object)(object)_root != (Object)null) { _root.SetActive(on); } } } private void TryFindNameplate() { if ((Object)(object)_player != (Object)null) { try { FieldInfo field = typeof(PlayerAvatar).GetField("worldSpaceUIPlayerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { ref WorldSpaceUIPlayerName nameplate = ref _nameplate; object? value = field.GetValue(_player); nameplate = (WorldSpaceUIPlayerName)((value is WorldSpaceUIPlayerName) ? value : null); } } catch { } } if ((Object)(object)_nameplate == (Object)null) { WorldSpaceUIPlayerName[] array = Object.FindObjectsOfType<WorldSpaceUIPlayerName>(); WorldSpaceUIPlayerName[] array2 = array; foreach (WorldSpaceUIPlayerName val in array2) { try { if ((Object)(object)val != (Object)null && (Object)(object)val.playerAvatar == (Object)(object)_player) { _nameplate = val; break; } } catch { } } } if (_fiWorldPos == null) { _fiWorldPos = typeof(WorldSpaceUIChild).GetField("worldPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } _nameplateText = null; if (!((Object)(object)_nameplate != (Object)null)) { return; } try { if (_fiNameText == null) { _fiNameText = typeof(WorldSpaceUIPlayerName).GetField("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_fiNameText != null) { ref TextMeshProUGUI nameplateText = ref _nameplateText; object? value2 = _fiNameText.GetValue(_nameplate); nameplateText = (TextMeshProUGUI)((value2 is TextMeshProUGUI) ? value2 : null); } if ((Object)(object)_nameplateText == (Object)null) { _nameplateText = ((Component)_nameplate).GetComponentInChildren<TextMeshProUGUI>(true); } } catch { } } private void LateUpdate() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if (!_shown) { return; } if ((Object)(object)_nameplate == (Object)null || _fiWorldPos == null) { TryFindNameplate(); if ((Object)(object)_nameplate == (Object)null || _fiWorldPos == null) { return; } } if ((Object)(object)_wui == (Object)null) { return; } Vector3 val = (Vector3)_fiWorldPos.GetValue(_nameplate); Vector3 worldPosition = val + new Vector3(0f, 0.2f, 0f); _wui.worldPosition = worldPosition; BountyManager instance = BountyManager.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)_text != (Object)null) { float secondsRemaining = instance.GetSecondsRemaining(); TimeSpan timeSpan = TimeSpan.FromSeconds(secondsRemaining); string text = $"{timeSpan.Minutes:0}:{timeSpan.Seconds:00}"; string text2 = $"${instance.BountyDollars:N0}"; ((TMP_Text)_text).text = "<color=#FF5555><b>BOUNTY</b></color> " + text2 + " <size=80%><color=#FFFF66>(" + text + ")</color></size>"; if ((Object)(object)_nameplateText == (Object)null) { TryFindNameplate(); } if ((Object)(object)_nameplateText != (Object)null) { ((TMP_Text)_text).fontSize = Mathf.Min(18f, ((TMP_Text)_nameplateText).fontSize); } else { ((TMP_Text)_text).fontSize = 18f; } } if ((Object)(object)BountyManager.Instance != (Object)null && !BountyManager.Instance.IsBountyActive()) { SetActive(on: false); } } private void UpdateImmediateText() { BountyManager instance = BountyManager.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)_text != (Object)null) { string text = $"${instance.BountyDollars:N0}"; ((TMP_Text)_text).text = "<color=#FF5555><b>BOUNTY</b></color> " + text + " <size=80%><color=#FFFF66>(1:00)</color></size>"; } } private void TrySetupUI() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00f4: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root != (Object)null) { return; } try { WorldSpaceUIParent instance = WorldSpaceUIParent.instance; if ((Object)(object)instance == (Object)null) { BountyPlugin.Logger.LogWarning((object)"[Bounty] WorldSpaceUIParent missing; bounty tag hidden."); return; } _root = new GameObject("Empress_BountyHud"); _root.transform.SetParent(((Component)instance).transform, false); _root.transform.SetAsLastSibling(); RectTransform val = _root.AddComponent<RectTransform>(); val.sizeDelta = new Vector2(320f, 32f); _wui = _root.AddComponent<WorldSpaceUIChild>(); _wui.positionOffset = Vector3.zero; GameObject val2 = new GameObject("Text"); val2.transform.SetParent(_root.transform, false); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(0f, 0f); val3.anchorMax = new Vector2(1f, 1f); val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; _text = val2.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((TMP_Text)_text).enableAutoSizing = false; ((TMP_Text)_text).fontStyle = (FontStyles)1; ((Graphic)_text).raycastTarget = false; ((TMP_Text)_text).outlineColor = Color32.op_Implicit(new Color(0f, 0f, 0f, 0.8f)); ((TMP_Text)_text).outlineWidth = 0.26f; ((TMP_Text)_text).fontSize = 18f; _root.SetActive(false); _shown = false; } catch (Exception ex) { BountyPlugin.Logger.LogWarning((object)("[Bounty] HUD setup failed: " + ex.Message)); } } } [HarmonyPatch] internal static class BountyPatches { [HarmonyPostfix] [HarmonyPatch(typeof(WorldSpaceUIParent), "PlayerName")] private static void WorldSpaceUIParent_PlayerName_Postfix(PlayerAvatar _player) { try { if (!((Object)(object)_player == (Object)null)) { BountyHud bountyHud = ((Component)_player).GetComponent<BountyHud>(); if ((Object)(object)bountyHud == (Object)null) { bountyHud = ((Component)_player).gameObject.AddComponent<BountyHud>(); bountyHud.Bind(_player); } BountyManager instance = BountyManager.Instance; if ((Object)(object)instance != (Object)null) { PhotonView photonView = _player.photonView; int num = (((Object)(object)photonView != (Object)null && photonView.Owner != null) ? photonView.Owner.ActorNumber : (-1)); int num2 = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : (-1)); bool active = num == instance.TargetActor && instance.IsBountyActive() && num != num2; bountyHud.SetActive(active); } } } catch (Exception ex) { BountyPlugin.Logger.LogWarning((object)("[Bounty] Nameplate postfix failed: " + ex.Message)); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerAvatar), "Revive")] private static bool PlayerAvatar_Revive_Prefix(PlayerAvatar __instance) { try { BountyManager instance = BountyManager.Instance; if ((Object)(object)instance == (Object)null) { return true; } PhotonView val = __instance?.photonView; int num = (((Object)(object)val != (Object)null && val.Owner != null) ? val.Owner.ActorNumber : (-1)); if (num > 0 && instance.IsReviveLocked(num)) { return false; } } catch { } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathDone")] private static void PlayerAvatar_PlayerDeathDone_Postfix(PlayerAvatar __instance) { try { BountyManager instance = BountyManager.Instance; if (!((Object)(object)instance == (Object)null)) { PhotonView val = __instance?.photonView; int num = (((Object)(object)val != (Object)null && val.Owner != null) ? val.Owner.ActorNumber : (-1)); if (num > 0 && instance.TargetActor == num) { bool wasInsideExtraction = BountyManager.IsInExtraction(__instance); instance.OnBountyTargetDied(num, wasInsideExtraction); } } } catch (Exception ex) { BountyPlugin.Logger.LogWarning((object)("[Bounty] Death handling failed: " + ex.Message)); } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerDeathHead), "Revive")] private static bool PlayerDeathHead_Revive_Prefix(PlayerDeathHead __instance) { try { BountyManager instance = BountyManager.Instance; if ((Object)(object)instance == (Object)null) { return true; } PhotonView val = (__instance?.playerAvatar)?.photonView; int num = (((Object)(object)val != (Object)null && val.Owner != null) ? val.Owner.ActorNumber : (-1)); if (num > 0 && instance.IsReviveLocked(num)) { return false; } } catch { } return true; } } }