using 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 ComputerysModdingUtilities; using FishNet; using FishNet.Managing.Timing; using HarmonyLib; using HeathenEngineering.SteamworksIntegration.API; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; 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: StraftatMod(false)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("STRAFTATBattleRoyale")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0eb28693b76ff4a86be57997942055739277293c")] [assembly: AssemblyProduct("com.elneko.battleroyale")] [assembly: AssemblyTitle("STRAFTATBattleRoyale")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace STRAFTATBattleRoyale { public static class BattleRoyaleZone { private static int _ticksUntilZone; private static bool _active; private static float _radius; private static Vector3 _center; private static GameObject _cylinder; private static PlayerHealth[] _players = Array.Empty(); private static ulong _hideHudTick; public static void Reset() { //IL_0028: 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) _radius = Plugin.ZoneInitialRadius.Value; _ticksUntilZone = Plugin.SecondsUntilZone.Value * 60; _active = false; _center = Vector3.zero; if (Object.op_Implicit((Object)(object)_cylinder)) { Object.Destroy((Object)(object)_cylinder); } CountdownHUD.Hide(); TimeManager timeManager = InstanceFinder.TimeManager; timeManager.OnTick -= TickCountdown; timeManager.OnTick -= TickZone; timeManager.OnTick += TickCountdown; timeManager.OnTick += TickZone; } private static void TickCountdown() { if (_ticksUntilZone > 0) { _ticksUntilZone--; if (_ticksUntilZone <= 600 && _ticksUntilZone % 60 == 0) { int num = _ticksUntilZone / 60; CountdownHUD.Show(num); Plugin.Log.LogInfo((object)$"[BattleRoyale] Zona en {num}s..."); } } else if (!_active) { _active = true; CountdownHUD.Show(0); if (Object.op_Implicit((Object)(object)_cylinder)) { Object.Destroy((Object)(object)_cylinder); } Spawn(); } } private static void TickZone() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_007c: 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) if (!_active) { return; } TimeManager timeManager = InstanceFinder.TimeManager; if (timeManager.Tick % 60 == 0 && InstanceFinder.IsServer) { PlayerHealth[] players = _players; foreach (PlayerHealth val in players) { if (Object.op_Implicit((Object)(object)val)) { Vector3 position = ((Component)val).transform.position; float num = Vector3.Distance(new Vector3(position.x, 0f, position.z), new Vector3(_center.x, 0f, _center.z)); if (num > _radius) { val.RemoveHealth(Plugin.ZoneDamagePerSecond.Value / 25f); } } } } if (Object.op_Implicit((Object)(object)_cylinder)) { if (_radius > Plugin.ZoneFinalRadius.Value) { _radius -= Plugin.ZoneShrinkRate.Value / 60f; } _cylinder.transform.localScale = new Vector3(_radius * 2f, 200f, _radius * 2f); } } private static void Spawn() { //IL_0059: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0040: 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_004a: Unknown result type (might be due to invalid IL or missing references) _players = Object.FindObjectsOfType(); PlayerHealth[] players = _players; foreach (PlayerHealth val in players) { if ((Object)(object)val != (Object)null && !val.isKilled) { _center += ((Component)val).transform.position; } } _center /= (float)Mathf.Max(1, _players.Length); _cylinder = GameObject.CreatePrimitive((PrimitiveType)2); _cylinder.GetComponent().enabled = false; _cylinder.transform.position = new Vector3(_center.x, 0f, _center.z); _cylinder.transform.localScale = new Vector3(_radius * 2f, 200f, _radius * 2f); Material material = ((Renderer)_cylinder.GetComponent()).material; material.shader = Shader.Find("UI/Default"); material.SetColor("_Color", new Color(0f, 1f, 0.08f, Plugin.ZoneAlpha.Value)); material.SetInt("_Cull", 0); Plugin.Log.LogInfo((object)$"[BattleRoyale] Zona activa. Centro: {_center} Radio: {_radius}"); InstanceFinder.TimeManager.OnTick += HideHUDAfterDelay; _hideHudTick = InstanceFinder.TimeManager.Tick + 120; } private static void HideHUDAfterDelay() { if (InstanceFinder.TimeManager.Tick >= _hideHudTick) { CountdownHUD.Hide(); InstanceFinder.TimeManager.OnTick -= HideHUDAfterDelay; } } } public static class CountdownHUD { private static GameObject _canvasGo; private static TextMeshProUGUI _text; public static void Show(int seconds) { //IL_0097: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) EnsureCreated(); _canvasGo.SetActive(true); if (seconds > 0) { ((TMP_Text)_text).text = seconds.ToString(); ((Graphic)_text).color = Color.Lerp(Color.yellow, Color.red, 1f - (float)seconds / 10f); ((TMP_Text)_text).fontSize = Mathf.Lerp(60f, 120f, 1f - (float)seconds / 10f); } else { ((TMP_Text)_text).text = "¡ZONA ACTIVA!"; ((Graphic)_text).color = Color.red; ((TMP_Text)_text).fontSize = 80f; } } public static void Hide() { if (Object.op_Implicit((Object)(object)_canvasGo)) { _canvasGo.SetActive(false); } } private static void EnsureCreated() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) if (!Object.op_Implicit((Object)(object)_canvasGo)) { _canvasGo = new GameObject("BR_CountdownHUD"); Object.DontDestroyOnLoad((Object)(object)_canvasGo); Canvas val = _canvasGo.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 100; _canvasGo.AddComponent(); _canvasGo.AddComponent(); GameObject val2 = new GameObject("CountdownText"); val2.transform.SetParent(_canvasGo.transform, false); _text = val2.AddComponent(); ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((TMP_Text)_text).fontSize = 80f; ((Graphic)_text).color = Color.yellow; ((TMP_Text)_text).fontStyle = (FontStyles)1; RectTransform component = val2.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.6f); component.anchorMax = new Vector2(0.5f, 0.6f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(400f, 150f); component.anchoredPosition = Vector2.zero; } } } [BepInPlugin("STRAFTATBattleRoyale", "com.elneko.battleroyale", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static BeforeSpawnAction <0>__Reset; public static UnityAction <1>__OnSceneLoaded; } private static readonly HashSet _menuScenes = new HashSet { "MainMenu", "Menu", "main_menu", "Loading" }; public static ManualLogSource Log { get; private set; } = null; public static ConfigEntry ZoneInitialRadius { get; private set; } = null; public static ConfigEntry ZoneFinalRadius { get; private set; } = null; public static ConfigEntry ZoneShrinkRate { get; private set; } = null; public static ConfigEntry ZoneDamagePerSecond { get; private set; } = null; public static ConfigEntry SecondsUntilZone { get; private set; } = null; public static ConfigEntry ZoneAlpha { get; private set; } = null; public static ConfigEntry ZoneColor { get; private set; } = null; private void Awake() { //IL_0048: 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_003d: Expected O, but got Unknown ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); object obj = <>O.<0>__Reset; if (obj == null) { BeforeSpawnAction val = BattleRoyaleZone.Reset; <>O.<0>__Reset = val; obj = (object)val; } PauseManager.OnBeforeSpawn += (BeforeSpawnAction)obj; new Harmony("STRAFTATBattleRoyale").PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"================================================"); Log.LogInfo((object)" com.elneko.battleroyale v1.0.0"); Log.LogInfo((object)$" Hora : {DateTime.Now:dd/MM/yyyy HH:mm:ss}"); Log.LogInfo((object)"================================================"); ((MonoBehaviour)this).StartCoroutine(LogSteamName()); } private static IEnumerator LogSteamName() { for (float w = 0f; w < 10f; w += 0.5f) { try { string name = Client.PersonaName; if (!string.IsNullOrEmpty(name)) { Log.LogInfo((object)(" Jugador : " + name)); break; } } catch { } yield return (object)new WaitForSeconds(0.5f); } } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (!_menuScenes.Contains(((Scene)(ref scene)).name)) { Log.LogInfo((object)$"[Sesión] Modo: '{((Scene)(ref scene)).name}' — {DateTime.Now:HH:mm:ss}"); } } private void BindConfig() { ZoneColor = ((BaseUnityPlugin)this).Config.Bind("Zona", "Color", "110, 53, 45", "R, G, B"); ZoneInitialRadius = ((BaseUnityPlugin)this).Config.Bind("Zona", "RadioInicial", 37.5f, "Radio inicial."); ZoneFinalRadius = ((BaseUnityPlugin)this).Config.Bind("Zona", "RadioFinal", 10f, "Radio minimo."); ZoneShrinkRate = ((BaseUnityPlugin)this).Config.Bind("Zona", "VelocidadCierre", 1f, "Unidades por segundo."); SecondsUntilZone = ((BaseUnityPlugin)this).Config.Bind("Zona", "SegundosInicio", 25, "Segundos hasta que aparece la zona."); ZoneDamagePerSecond = ((BaseUnityPlugin)this).Config.Bind("Zona", "DanoPorSegundo", 10f, "Dano por segundo fuera de la zona."); ZoneAlpha = ((BaseUnityPlugin)this).Config.Bind("Zona", "Transparencia", 0.5f, "0.0 = invisible, 1.0 = solido."); } } [HarmonyPatch(typeof(PauseManager), "InvokeBeforeSpawn")] internal static class Patch_InvokeBeforeSpawn { [HarmonyPostfix] private static void Postfix() { Plugin.Log.LogInfo((object)"[BR] InvokeBeforeSpawn detectado → Reset()"); BattleRoyaleZone.Reset(); } } public static class PluginInfo { public const string PLUGIN_GUID = "STRAFTATBattleRoyale"; public const string PLUGIN_NAME = "com.elneko.battleroyale"; public const string PLUGIN_VERSION = "1.0.0"; } }