using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using SineusModding.Api;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("EndlessBounty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+07f4bd8ea1b913522ec39a1d432449c2d237baad")]
[assembly: AssemblyProduct("EndlessBounty")]
[assembly: AssemblyTitle("EndlessBounty")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace EndlessBounty
{
internal sealed class BountyHud
{
private const int WindowId = 722043;
private const int ToastWindowId = 722044;
private const float DefaultWidth = 260f;
private const float BottomMargin = 90f;
private readonly BountySettings _settings;
private readonly BountyTracker _tracker;
private Rect _rect = new Rect(12f, 0f, 260f, 10f);
private GUIStyle _windowStyle;
private GUIStyle _textStyle;
private bool _stylesReady;
private Texture2D _panelTexture;
private Font _uiFont;
private float _toggleToastUntil;
private bool _positionInitialized;
public BountyHud(BountySettings settings, BountyTracker tracker)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
_settings = settings;
_tracker = tracker;
}
private void EnsurePositionInitialized()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (!_positionInitialized)
{
float num = ((_settings.HudY.Value < 0f) ? ((float)Screen.height - 90f) : _settings.HudY.Value);
_rect = new Rect(_settings.HudX.Value, num, 260f, 10f);
_positionInitialized = true;
}
}
public void NotifyToggled()
{
_toggleToastUntil = Time.unscaledTime + 2.5f;
}
public void Draw()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Expected O, but got Unknown
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
if (Time.unscaledTime < _toggleToastUntil)
{
EnsureStyles();
DrawToggleToast();
}
if (_settings.Enabled.Value && _settings.ShowHud.Value && MatchObjective.IsPostBossPhase)
{
EnsureStyles();
EnsurePositionInitialized();
_rect = ClampToScreen(_rect);
string obj = ((_settings.MinutesPerChest.Value > 0f) ? ("\n <color=#9FB4BA>Chest:</color> <color=#FFFFFF>" + FormatSeconds(_tracker.TimeUntilNextChest) + "</color>") : string.Empty);
string text = ((_settings.MinutesPerCustomDrop.Value > 0f) ? ("\n <color=#9FB4BA>Item:</color> <color=#FFFFFF>" + FormatSeconds(_tracker.TimeUntilNextCustomDrop) + "</color>") : string.Empty);
string text2 = ((_settings.MinutesPerBuildingUpgrade.Value > 0f) ? ("\n <color=#9FB4BA>Upgrade:</color> <color=#FFFFFF>" + FormatSeconds(_tracker.TimeUntilNextBuildingUpgrade) + "</color>") : string.Empty);
string text3 = obj + text + text2;
string text4 = (MatchObjective.IsFinalBossSiege ? ("<color=#9FB4BA>Siege ends in:</color> <color=#FF8A65>-" + FormatSeconds(MatchObjective.FinalBossSiegeSecondsRemaining) + "</color>") : ("<color=#9FB4BA>Final wave time:</color> <color=#F0D060>" + FormatSeconds(_tracker.TimeInFinalWave) + "</color>"));
string text5 = "<color=#E6C478><b>Endless Bounty</b></color>\n" + text4 + " " + $"<color=#9FB4BA>Kills:</color> <color=#FFFFFF>{_tracker.SessionKills}</color>" + (string.IsNullOrEmpty(text3) ? string.Empty : ("\n<color=#9FB4BA>Next:</color>" + text3));
_rect = GUILayout.Window(722043, _rect, (WindowFunction)delegate(int id)
{
DrawWindowContents(id, text5);
}, string.Empty, _windowStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(((Rect)(ref _rect)).width) });
PersistPanelPosition();
}
}
private void DrawWindowContents(int windowId, string text)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
GUILayout.Label(text, _textStyle, Array.Empty<GUILayoutOption>());
GUI.DragWindow(new Rect(0f, 0f, 10000f, 10000f));
}
private void PersistPanelPosition()
{
if (!Mathf.Approximately(((Rect)(ref _rect)).x, _settings.HudX.Value))
{
_settings.HudX.Value = ((Rect)(ref _rect)).x;
}
if (!Mathf.Approximately(((Rect)(ref _rect)).y, _settings.HudY.Value))
{
_settings.HudY.Value = ((Rect)(ref _rect)).y;
}
}
private static string FormatSeconds(float seconds)
{
int num = Mathf.Max(0, Mathf.RoundToInt(seconds));
int num2 = num / 60;
int num3 = num % 60;
return $"{num2}:{num3:00}";
}
private void DrawToggleToast()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
string text = (_settings.Enabled.Value ? "<color=#7CE07C>ENABLED</color>" : "<color=#FF6B57>DISABLED</color>");
string text2 = "<color=#E6C478><b>Endless Bounty</b></color> " + text;
Rect val = default(Rect);
((Rect)(ref val))..ctor(((float)Screen.width - 220f) / 2f, 60f, 220f, 10f);
GUILayout.Window(722044, val, (WindowFunction)delegate
{
GUILayout.Label(text2, _textStyle, Array.Empty<GUILayoutOption>());
}, string.Empty, _windowStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(220f) });
}
private static Rect ClampToScreen(Rect rect)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Clamp(((Rect)(ref rect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref rect)).width));
float num2 = Mathf.Clamp(((Rect)(ref rect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref rect)).height));
return new Rect(num, num2, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height);
}
private void EnsureStyles()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: 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_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
//IL_0195: Expected O, but got Unknown
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: 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_01c0: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Expected O, but got Unknown
if (!_stylesReady || !((Object)(object)_panelTexture != (Object)null) || !((Object)(object)_uiFont != (Object)null))
{
_uiFont = UiFont.CreateSafe(new string[3] { "Segoe UI", "Segoe UI Semibold", "Arial" }, 13);
Color fill = Color32.op_Implicit(new Color32((byte)10, (byte)26, (byte)34, (byte)235));
Color border = Color32.op_Implicit(new Color32((byte)198, (byte)158, (byte)74, byte.MaxValue));
Color textColor = Color32.op_Implicit(new Color32((byte)224, (byte)230, (byte)232, byte.MaxValue));
_panelTexture = MakeBorderedTexture(fill, border);
GUIStyle val = new GUIStyle(GUI.skin.window)
{
font = _uiFont,
border = new RectOffset(2, 2, 2, 2),
overflow = new RectOffset(0, 0, 0, 0),
margin = new RectOffset(0, 0, 0, 0)
};
val.normal.background = _panelTexture;
val.onNormal.background = _panelTexture;
val.hover.background = _panelTexture;
val.onHover.background = _panelTexture;
val.active.background = _panelTexture;
val.onActive.background = _panelTexture;
val.focused.background = _panelTexture;
val.onFocused.background = _panelTexture;
val.padding = new RectOffset(10, 10, 8, 8);
_windowStyle = val;
GUIStyle val2 = new GUIStyle(GUI.skin.label)
{
font = _uiFont,
fontSize = 13,
richText = true,
wordWrap = true
};
val2.normal.textColor = textColor;
_textStyle = val2;
_stylesReady = true;
}
}
private static Texture2D MakeBorderedTexture(Color fill, Color border)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_001b: Expected O, but got Unknown
//IL_0045: 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)
Texture2D val = new Texture2D(12, 12, (TextureFormat)4, false)
{
filterMode = (FilterMode)0,
hideFlags = (HideFlags)61
};
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 12; j++)
{
bool flag = j < 2 || i < 2 || j >= 10 || i >= 10;
val.SetPixel(j, i, flag ? border : fill);
}
}
val.Apply();
return val;
}
}
internal sealed class BountySettings
{
public readonly ConfigEntry<bool> Enabled;
public readonly ConfigEntry<KeyCode> ToggleKey;
public readonly ConfigEntry<float> MinutesPerChest;
public readonly ConfigEntry<float> MinutesPerCustomDrop;
public readonly ConfigEntry<float> MinutesPerBuildingUpgrade;
public readonly ConfigEntry<bool> ShowHud;
public readonly ConfigEntry<float> HudX;
public readonly ConfigEntry<float> HudY;
public BountySettings(ConfigFile config)
{
Enabled = config.Bind<bool>("General", "Enabled", true, "Master switch: grant occasional bonus chests/items for surviving the endless post-boss final wave.");
ToggleKey = config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)289, "Key to toggle EndlessBounty on/off in-match.");
MinutesPerChest = config.Bind<float>("Rewards", "MinutesPerChest", 2f, "A free bonus chest spawns after this many minutes survived in the final wave (timer only runs while the final wave is active). 0 disables this.");
MinutesPerCustomDrop = config.Bind<float>("Rewards", "MinutesPerCustomDrop", 1.5f, "A random item from the game's own elite drop table (e.g. the Magnet pickup) spawns after this many minutes survived in the final wave. 0 disables this.");
MinutesPerBuildingUpgrade = config.Bind<float>("Rewards", "MinutesPerBuildingUpgrade", 4f, "A free building-upgrade pickup spawns after this many minutes survived in the final wave. 0 disables this.");
ShowHud = config.Bind<bool>("Display", "ShowHud", true, "Show a small HUD readout of time survived and time until the next reward.");
HudX = config.Bind<float>("Display", "HudX", 12f, "X position (pixels from left) of the HUD panel. Drag the panel's title bar in-game to change, or edit here.");
HudY = config.Bind<float>("Display", "HudY", -1f, "Y position (pixels from top) of the HUD panel. -1 means \"anchor to the bottom of the screen\" (recomputed as the screen resolution changes); once dragged in-game it becomes a fixed pixel value.");
}
}
internal sealed class BountyTracker
{
private readonly BountySettings _settings;
private float _timeUntilNextChest;
private float _timeUntilNextCustomDrop;
private float _timeUntilNextBuildingUpgrade;
private int _lastSeenStage = -1;
private const float SpawnOffsetMinRadius = 10f;
private const float SpawnOffsetMaxRadius = 20f;
public int SessionKills { get; private set; }
public float TimeInFinalWave { get; private set; }
public float LastKillTime { get; private set; } = -999f;
public Vector3 LastKillPosition { get; private set; }
public float TimeUntilNextChest => _timeUntilNextChest;
public float TimeUntilNextCustomDrop => _timeUntilNextCustomDrop;
public float TimeUntilNextBuildingUpgrade => _timeUntilNextBuildingUpgrade;
public BountyTracker(BountySettings settings)
{
_settings = settings;
ResetTimers();
BountyMobs.EnsureSubscribed();
BountyMobs.BountyUnitKilled += OnBountyUnitKilled;
}
private void ResetTimers()
{
_timeUntilNextChest = Mathf.Max(0f, _settings.MinutesPerChest.Value) * 60f;
_timeUntilNextCustomDrop = Mathf.Max(0f, _settings.MinutesPerCustomDrop.Value) * 60f;
_timeUntilNextBuildingUpgrade = Mathf.Max(0f, _settings.MinutesPerBuildingUpgrade.Value) * 60f;
}
public void Update()
{
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
if (!MatchObjective.IsInMatch)
{
if (TimeInFinalWave != 0f || SessionKills != 0 || LastKillTime != -999f)
{
ResetSession();
}
_lastSeenStage = -1;
return;
}
int currentStage = MatchObjective.CurrentStage;
if (_lastSeenStage != -1 && currentStage != _lastSeenStage)
{
ResetSession();
}
_lastSeenStage = currentStage;
if (!_settings.Enabled.Value || (BountyMobs.TrackedAliveCount <= 0 && !(Time.time - LastKillTime < 5f) && !MatchObjective.IsFinalBossSiege))
{
return;
}
if (MatchObjective.IsEndlessNight)
{
TimeInFinalWave += Time.deltaTime;
}
if (_settings.MinutesPerChest.Value > 0f)
{
_timeUntilNextChest -= Time.deltaTime;
if (_timeUntilNextChest <= 0f)
{
_timeUntilNextChest = _settings.MinutesPerChest.Value * 60f;
BountyRewards.SpawnFreeChestAt(GetRewardSpawnPosition());
}
}
if (_settings.MinutesPerCustomDrop.Value > 0f)
{
_timeUntilNextCustomDrop -= Time.deltaTime;
if (_timeUntilNextCustomDrop <= 0f)
{
_timeUntilNextCustomDrop = _settings.MinutesPerCustomDrop.Value * 60f;
BountyRewards.SpawnRandomCustomDropAt(GetRewardSpawnPosition());
}
}
if (_settings.MinutesPerBuildingUpgrade.Value > 0f)
{
_timeUntilNextBuildingUpgrade -= Time.deltaTime;
if (_timeUntilNextBuildingUpgrade <= 0f)
{
_timeUntilNextBuildingUpgrade = _settings.MinutesPerBuildingUpgrade.Value * 60f;
BountyRewards.SpawnBuildingUpgradeAt(GetRewardSpawnPosition());
}
}
}
private Vector3 GetRewardSpawnPosition()
{
//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_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_003c: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = default(Vector3);
if (!BountyRewards.TryGetAnyBaseCenterPosition(ref val))
{
return LastKillPosition;
}
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized;
float num = Random.Range(10f, 20f);
return val + new Vector3(normalized.x * num, 0f, normalized.y * num);
}
private void OnBountyUnitKilled(BountyKillInfo kill)
{
//IL_001f: 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)
if (_settings.Enabled.Value)
{
LastKillTime = Time.time;
LastKillPosition = kill.Position;
SessionKills++;
}
}
private void ResetSession()
{
//IL_0020: 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)
TimeInFinalWave = 0f;
SessionKills = 0;
LastKillTime = -999f;
LastKillPosition = default(Vector3);
ResetTimers();
}
}
[BepInPlugin("com.community.sineusarena.endlessbounty", "Endless Bounty", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "com.community.sineusarena.endlessbounty";
public const string PluginName = "Endless Bounty";
public const string PluginVersion = "1.2.0";
private const string GithubOwner = "maanu113";
private const string GithubRepo = "EndlessBounty";
private BountySettings _settings;
private BountyTracker _tracker;
private BountyHud _hud;
private UpdateNotice _updateNotice;
private void Awake()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
_settings = new BountySettings(((BaseUnityPlugin)this).Config);
_tracker = new BountyTracker(_settings);
_hud = new BountyHud(_settings, _tracker);
_updateNotice = new UpdateNotice("Endless Bounty");
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded. Occasional bonus chests/items during the endless final wave. Press {2} to toggle.", "Endless Bounty", "1.2.0", _settings.ToggleKey.Value));
UpdateChecker.CheckAsync((MonoBehaviour)(object)this, "maanu113", "EndlessBounty", "1.2.0", (Action<UpdateCheckResult>)delegate(UpdateCheckResult result)
{
//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_0007: Invalid comparison between Unknown and I4
//IL_000f: 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)
if ((int)result.Status == 3)
{
_updateNotice.Show(result.LatestVersion, result.ReleaseUrl);
}
});
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(_settings.ToggleKey.Value))
{
_settings.Enabled.Value = !_settings.Enabled.Value;
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Endless Bounty {0} (toggled with {1}).", _settings.Enabled.Value ? "ENABLED" : "DISABLED", _settings.ToggleKey.Value));
_hud.NotifyToggled();
}
_tracker.Update();
}
private void OnGUI()
{
_hud.Draw();
_updateNotice.Draw();
}
}
}