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 LethalBattle v1.1.3
Lethal_Battle.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; 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 GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Lethal_Battle.NewFolder; using Lethal_Battle.codes; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Steamworks; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; 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("Lethal_Battle")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d81fa5de88a666c380649ba5fc9e89331f317499")] [assembly: AssemblyProduct("Lethal_Battle")] [assembly: AssemblyTitle("Lethal_Battle")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace Lethal_Battle { internal class Config { public ConfigEntry<int> SingItemBattleRarity { get; private set; } public ConfigEntry<bool> IsVolumeInBattle { get; private set; } public Config(ConfigFile configFile) { configFile.SaveOnConfigSet = false; SingItemBattleRarity = configFile.Bind<int>("Spawn Rates", "SingleItemBattleRarity", 10, "percentage of chances to have a battle with a single item (higher = more common)."); IsVolumeInBattle = configFile.Bind<bool>("Is the battle volume is in the battle.", "IsVolumeInBattle", true, "true equal the battle has a volume making a reddish tone to the screen"); configFile.Save(); configFile.SaveOnConfigSet = true; } } [HarmonyPatch(typeof(HUDManager))] internal class DebugCommandsManager { } [HarmonyPatch(typeof(RoundManager))] internal class PatchRoundManager { private static bool winSequenceStarted; [HarmonyPostfix] [HarmonyPatch("FinishGeneratingNewLevelClientRpc")] public static void Changes() { if (Plugin.hasBattleStarted || StartOfRound.Instance.livingPlayers < 2 || TimeOfDay.Instance.daysUntilDeadline != 0 || TimeOfDay.Instance.currentLevel.planetHasTime || TimeOfDay.Instance.currentLevel.spawnEnemiesAndScrap) { return; } ManualLogSource? log = Plugin.log; if (log != null) { log.LogInfo((object)"In a company for the last phase!"); } int num = 5 * (StartOfRound.Instance.allPlayerObjects.Length - 1); int num2 = Object.FindObjectsOfType<GrabbableObject>().Where(delegate(GrabbableObject o) { int result; if (o.itemProperties.isScrap && o.itemProperties.minValue > 0) { StunGrenadeItem val = (StunGrenadeItem)(object)((o is StunGrenadeItem) ? o : null); if (val == null || !val.hasExploded || !val.DestroyGrenade) { result = ((o.isInShipRoom && o.isInElevator) ? 1 : 0); goto IL_0049; } } result = 0; goto IL_0049; IL_0049: return (byte)result != 0; }).ToList() .Sum((GrabbableObject s) => s.scrapValue); winSequenceStarted = false; if (num2 + num + TimeOfDay.Instance.quotaFulfilled >= TimeOfDay.Instance.profitQuota) { ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogInfo((object)(num2 + num + TimeOfDay.Instance.quotaFulfilled >= TimeOfDay.Instance.profitQuota)); } return; } ManualLogSource? log3 = Plugin.log; if (log3 != null) { log3.LogInfo((object)"Battle because ur too poor, the company want blood !"); } ((MonoBehaviour)RoundManager.Instance).StartCoroutine(ItemSpawn.SpawnItems()); Plugin.hasBattleStarted = true; } [HarmonyPrefix] [HarmonyPatch("Update")] public static void ChangesUI_death() { if (Plugin.hasBattleStarted) { StartMatchLever val = Object.FindObjectOfType<StartMatchLever>(); val.triggerScript.interactable = false; if ((Object)(object)ManageUI.UI_players_alive_and_kills != (Object)null && !Plugin.hasMessageWonShowed) { ManageUI.UpdateUI(); } if (StartOfRound.Instance.livingPlayers == 1 && !winSequenceStarted) { winSequenceStarted = true; ((MonoBehaviour)RoundManager.Instance).StartCoroutine(ManageUI.WinScreenCoroutine(val)); } } } } [HarmonyPatch(typeof(StartOfRound))] internal class PatchStartOfRound { [HarmonyPrefix] [HarmonyPatch("EndOfGame")] public static void ChangesDeleteUI() { if (Plugin.hasBattleStarted && (Object)(object)ManageUI.UI_players_alive_and_kills != (Object)null && Plugin.hasMessageWonShowed) { ItemSpawn.DisableBattleVolume(); ClosestPlayerAndPath.StopClosestOpponentPath(); ManageUI.UIDelete(); Plugin.hasMessageWonShowed = false; Plugin.hasBattleStarted = false; } } } [BepInPlugin("POUY.LETHAL_BATTLE", "Lethal Battle", "1.1.1")] public class Plugin : BaseUnityPlugin { private const string GUID = "POUY.LETHAL_BATTLE"; private const string NAME = "Lethal Battle"; private const string VERSION = "1.1.1"; public static ManualLogSource? log; public readonly Harmony harmony = new Harmony("POUY.LETHAL_BATTLE"); public static bool verifying; public GameObject? UI_Lethal_Battle; public int numberOfPlayers; public static bool hasBattleStarted; public static bool hasMessageWonShowed; public GameObject? FootprintPrefab; public GameObject? VolumeLightBattle; public AudioClip? SoundSonar; public static Plugin Instance { get; private set; } internal static Config LethalBattleConfig { get; private set; } public void Awake() { Instance = this; log = ((BaseUnityPlugin)this).Logger; LethalBattleConfig = new Config(((BaseUnityPlugin)this).Config); LoadUI(); log.LogMessage((object)"Lethal Battle Loaded !"); ClosestPlayerAndPath.Initialize(); harmony.PatchAll(); } public void LoadUI() { try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lethal_battle"); AssetBundle val = AssetBundle.LoadFromFile(text); string text2 = "Assets/LethalModding/LethalBattle/UIBattle.prefab"; UI_Lethal_Battle = val.LoadAsset<GameObject>(text2); ManualLogSource? obj = log; if (obj != null) { obj.LogInfo((object)"UI loaded successfully"); } LoadFootprints(val); } catch (Exception ex) { ManualLogSource? obj2 = log; if (obj2 != null) { obj2.LogError((object)"UI ERROR"); } ManualLogSource? obj3 = log; if (obj3 != null) { obj3.LogError((object)ex); } } } public void LoadFootprints(AssetBundle bundle) { FootprintPrefab = bundle.LoadAsset<GameObject>("Assets/LethalModding/LethalBattle/FootPrintPrefab.prefab"); SoundSonar = bundle.LoadAsset<AudioClip>("Assets/LethalModding/LethalBattle/sonar.ogg"); VolumeLightBattle = bundle.LoadAsset<GameObject>("Assets/LethalModding/LethalBattle/VolumeBattle.prefab"); if ((Object)(object)VolumeLightBattle == (Object)null) { ManualLogSource? obj = log; if (obj != null) { obj.LogError((object)"VolumeLightBattle failed to load"); } } string[] allAssetNames = bundle.GetAllAssetNames(); foreach (string text in allAssetNames) { ManualLogSource? obj2 = log; if (obj2 != null) { obj2.LogInfo((object)("BUNDLE ASSET: " + text)); } } } } } namespace Lethal_Battle.NewFolder { internal class ManageJson { public class ItemWeight { public string? name { get; set; } public float value { get; set; } } public Item item; public float weight; public static bool battleJsonLoaded = false; public static List<ItemWeight>? _reader { get; set; } public static List<ItemWeight>? battleWithOneItem { get; set; } public static Dictionary<string, float> WeightsByName { get; set; } = new Dictionary<string, float>(); public ManageJson(Item item, float weight) { this.item = item; this.weight = weight; } public static void LoadWeightsFromJson(string jsonPath) { try { if (!File.Exists(jsonPath)) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogError((object)("JSON not found : " + jsonPath)); } return; } string text = File.ReadAllText(jsonPath); _reader = JsonConvert.DeserializeObject<List<ItemWeight>>(text); if (_reader == null || _reader.Count == 0) { ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogError((object)"JSON not valid"); } } else { WeightsByName = _reader.ToDictionary((ItemWeight x) => x.name.Trim().ToUpper(), (ItemWeight x) => x.value); } } catch (Exception ex) { ManualLogSource? log3 = Plugin.log; if (log3 != null) { log3.LogError((object)(ex?.ToString() ?? "")); } } } public static void LoadBattleWithOneItemJson(string jsonPath) { try { if (!File.Exists(jsonPath)) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogError((object)("Battle JSON not found : " + jsonPath)); } return; } string text = File.ReadAllText(jsonPath); battleWithOneItem = JsonConvert.DeserializeObject<List<ItemWeight>>(text); if (battleWithOneItem == null || battleWithOneItem.Count == 0) { ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogError((object)"Battle JSON invalid or empty"); } battleWithOneItem = new List<ItemWeight>(); } else { battleJsonLoaded = true; ManualLogSource? log3 = Plugin.log; if (log3 != null) { log3.LogInfo((object)$"Loaded {battleWithOneItem.Count} battle items"); } } } catch (Exception ex) { ManualLogSource? log4 = Plugin.log; if (log4 != null) { log4.LogError((object)(ex?.ToString() ?? "")); } battleWithOneItem = new List<ItemWeight>(); } } public static float GetWeight(string itemName) { string key = itemName.Trim().ToUpper(); float value; return WeightsByName.TryGetValue(key, out value) ? value : 0f; } public static List<ManageJson> GetBattleItemsWeighted(List<Item> allItems) { string jsonPath = Path.Combine(Paths.PluginPath, "MikuT4T-LethalBattle/items.json"); string jsonPath2 = Path.Combine(Paths.PluginPath, "MikuT4T-LethalBattle/itemsForBattleWithOneItem.json"); LoadWeightsFromJson(jsonPath); if (!battleJsonLoaded) { LoadBattleWithOneItemJson(jsonPath2); } Random random = new Random(); int num = random.Next(0, 100); bool flag = num < Plugin.LethalBattleConfig.SingItemBattleRarity.Value; List<ManageJson> list = new List<ManageJson>(); if (!flag) { foreach (Item allItem in allItems) { float num2 = GetWeight(allItem.itemName); list.Add(new ManageJson(allItem, num2)); } return list; } if (battleWithOneItem == null || battleWithOneItem.Count == 0) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogError((object)"No battle items loaded"); } return list; } List<ItemWeight> list2 = battleWithOneItem.Where((ItemWeight jsonItem) => !string.IsNullOrWhiteSpace(jsonItem.name) && allItems.Any((Item gameItem) => gameItem.itemName.Trim().ToUpper() == jsonItem.name.Trim().ToUpper())).ToList(); if (list2.Count == 0) { ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogError((object)"No valid battle items found in game"); } return list; } float num3 = list2.Sum((ItemWeight i) => i.value); if (num3 <= 0f) { ManualLogSource? log3 = Plugin.log; if (log3 != null) { log3.LogError((object)"Battle total weight is zero"); } return list; } float num4 = (float)(random.NextDouble() * (double)num3); float num5 = 0f; ItemWeight chosen = new ItemWeight(); foreach (ItemWeight item in list2) { num5 += item.value; if (num4 <= num5) { chosen = item; break; } } if (chosen == null) { chosen = list2.Last(); } Item val = ((IEnumerable<Item>)allItems).FirstOrDefault((Func<Item, bool>)((Item it) => it.itemName.Trim().ToUpper() == chosen.name?.Trim().ToUpper())); if ((Object)(object)val == (Object)null) { ManualLogSource? log4 = Plugin.log; if (log4 != null) { log4.LogError((object)("Item not found in game : " + chosen.name)); } return list; } HUDManager.Instance.BeginDisplayAd(val.itemName, " Only battle !"); ManualLogSource? log5 = Plugin.log; if (log5 != null) { log5.LogInfo((object)("battle with " + chosen.name)); } list.Add(new ManageJson(val, chosen.value)); return list; } } internal class ManageUI { public static GameObject? UI_players_alive_and_kills; private static GameObject? ScreenWinBattle; private static GameObject? ScreenBattle; public static void UISpawn() { if ((Object)(object)Plugin.Instance.UI_Lethal_Battle != (Object)null) { Plugin.Instance.numberOfPlayers = StartOfRound.Instance.livingPlayers; UI_players_alive_and_kills = Object.Instantiate<GameObject>(Plugin.Instance.UI_Lethal_Battle); Graphic[] componentsInChildren = UI_players_alive_and_kills.GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { val.raycastTarget = false; } GraphicRaycaster component = UI_players_alive_and_kills.GetComponent<GraphicRaycaster>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } Transform obj = UI_players_alive_and_kills.transform.Find("ScreenWinBattle"); ScreenWinBattle = ((obj != null) ? ((Component)obj).gameObject : null); GameObject? screenWinBattle = ScreenWinBattle; if (screenWinBattle != null) { screenWinBattle.SetActive(false); } Transform obj2 = UI_players_alive_and_kills.transform.Find("Panel"); ScreenBattle = ((obj2 != null) ? ((Component)obj2).gameObject : null); GameObject? screenBattle = ScreenBattle; if (screenBattle != null) { screenBattle.SetActive(true); } } } public static void ShowWinScreen() { GameObject? screenBattle = ScreenBattle; if (screenBattle != null) { screenBattle.SetActive(false); } if ((Object)(object)ScreenWinBattle != (Object)null) { ScreenWinBattle.SetActive(true); } } public static void UpdateUI() { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UI_players_alive_and_kills != (Object)null)) { return; } Transform obj = UI_players_alive_and_kills.transform.Find("Panel/NumberOfPlayerKilled"); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null); if ((Object)(object)val != (Object)null) { val.text = (Plugin.Instance.numberOfPlayers - StartOfRound.Instance.livingPlayers).ToString() ?? ""; } Transform obj2 = UI_players_alive_and_kills.transform.Find("Panel/NumberOfPlayers"); TMP_Text val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null); if ((Object)(object)val2 != (Object)null) { val2.text = "/ " + (Plugin.Instance.numberOfPlayers - 1); } PlayerControllerB closestOpponentToLocalPlayer = ClosestPlayerAndPath.GetClosestOpponentToLocalPlayer(); Transform obj3 = UI_players_alive_and_kills.transform.Find("Panel/playerName"); TMP_Text val3 = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null); Transform obj4 = UI_players_alive_and_kills.transform.Find("Panel/PlayerDistance"); TMP_Text val4 = ((obj4 != null) ? ((Component)obj4).GetComponent<TMP_Text>() : null); Transform obj5 = UI_players_alive_and_kills.transform.Find("Panel/PFPPlayer"); RawImage val5 = ((obj5 != null) ? ((Component)obj5).GetComponent<RawImage>() : null); bool flag = !GameNetworkManager.Instance.disableSteam; if ((Object)(object)closestOpponentToLocalPlayer != (Object)null) { float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)closestOpponentToLocalPlayer).transform.position); if ((Object)(object)val3 != (Object)null) { val3.text = closestOpponentToLocalPlayer.playerUsername; } if ((Object)(object)val4 != (Object)null) { val4.text = $"- {Mathf.RoundToInt(num)} m"; } if ((Object)(object)val5 != (Object)null) { if (flag) { ((Component)val5).gameObject.SetActive(true); HUDManager.FillImageWithSteamProfile(val5, SteamId.op_Implicit(closestOpponentToLocalPlayer.playerSteamId), true); } else { ((Component)val5).gameObject.SetActive(false); } } } else { if ((Object)(object)val3 != (Object)null) { val3.text = "No player"; } if ((Object)(object)val4 != (Object)null) { val4.text = "-"; } if ((Object)(object)val5 != (Object)null) { ((Component)val5).gameObject.SetActive(false); } } } public static IEnumerator WinScreenCoroutine(StartMatchLever shipLever) { PlayerControllerB winner = null; GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects; foreach (GameObject playerObject in allPlayerObjects) { PlayerControllerB player = playerObject.GetComponent<PlayerControllerB>(); if ((Object)(object)player != (Object)null && !player.isPlayerDead) { winner = player; break; } } if ((Object)(object)winner != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)winner) { ShowWinScreen(); } yield return (object)new WaitForSeconds(0.5f); ItemSpawn.MakeShipLeave(shipLever); Plugin.hasMessageWonShowed = true; } public static void UIDelete() { if ((Object)(object)UI_players_alive_and_kills != (Object)null) { Object.Destroy((Object)(object)UI_players_alive_and_kills); } } } } namespace Lethal_Battle.codes { internal static class ClosestPlayerAndPath { private class CoroutineRunner : MonoBehaviour { } private static bool generatingPath = false; private static float nextPathTime = 0f; private static Queue<Vector3> footprintQueue = new Queue<Vector3>(); private static Coroutine? closestOpponentPathCoroutine; private static Coroutine? footprintCoroutine; private static GameObject? buddy; private static CoroutineRunner? coroutineBuddy; public static void Initialize() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)buddy != (Object)null)) { buddy = new GameObject("Buddy"); Object.DontDestroyOnLoad((Object)(object)buddy); coroutineBuddy = buddy.AddComponent<CoroutineRunner>(); } } private static IEnumerator ClosestOpponentPathLoop() { while (Plugin.hasBattleStarted) { PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayer == (Object)null || !((NetworkBehaviour)localPlayer).IsSpawned || !localPlayer.isPlayerControlled || localPlayer.isPlayerDead) { StopFootprintCoroutine(); yield return (object)new WaitForSeconds(1f); continue; } PlayerControllerB opponent = GetClosestOpponentToLocalPlayer(); if ((Object)(object)opponent == (Object)null) { StopFootprintCoroutine(); yield return (object)new WaitForSeconds(0.5f); continue; } if (!generatingPath && Time.time >= nextPathTime) { nextPathTime = Time.time + 1.5f; Queue<Vector3> path = PathSystem.GeneratePathPoints(((Component)localPlayer).transform.position, ((Component)opponent).transform.position, 1.5f); if (path.Count > 0) { footprintQueue = path; if (footprintCoroutine == null) { footprintCoroutine = ((MonoBehaviour)coroutineBuddy).StartCoroutine(SpawnFootprints()); } } } yield return (object)new WaitForSeconds(0.1f); } closestOpponentPathCoroutine = null; StopFootprintCoroutine(); } public static PlayerControllerB? GetClosestOpponentToLocalPlayer() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController != (Object)null) { PlayerControllerB result = null; float num = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)localPlayerController && val.isPlayerControlled && ((NetworkBehaviour)val).IsSpawned && !val.isPlayerDead) { float num2 = Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } return result; } return null; } public static void StartClosestOpponentPath() { if (Plugin.hasBattleStarted) { Initialize(); if ((Object)(object)coroutineBuddy != (Object)null && closestOpponentPathCoroutine == null) { nextPathTime = 0f; closestOpponentPathCoroutine = ((MonoBehaviour)coroutineBuddy).StartCoroutine(ClosestOpponentPathLoop()); return; } ManualLogSource? log = Plugin.log; if (log != null) { log.LogError((object)"PATH Coroutine runner is null :c, can't start path search"); } } else { ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogError((object)"Can't start closest opponent path because battle didn't start :c"); } } } public static void StopClosestOpponentPath() { if ((Object)(object)coroutineBuddy != (Object)null) { if (closestOpponentPathCoroutine != null) { ((MonoBehaviour)coroutineBuddy).StopCoroutine(closestOpponentPathCoroutine); closestOpponentPathCoroutine = null; } if (footprintCoroutine != null) { ((MonoBehaviour)coroutineBuddy).StopCoroutine(footprintCoroutine); footprintCoroutine = null; } } footprintQueue.Clear(); generatingPath = false; nextPathTime = 0f; } private static void StopFootprintCoroutine() { if ((Object)(object)coroutineBuddy != (Object)null && footprintCoroutine != null) { ((MonoBehaviour)coroutineBuddy).StopCoroutine(footprintCoroutine); } footprintCoroutine = null; footprintQueue.Clear(); generatingPath = false; } private static IEnumerator SpawnFootprints() { generatingPath = true; Vector3? previous = null; bool leftFoot = true; while (footprintQueue.Count > 0) { Vector3 current = footprintQueue.Dequeue(); Vector3 val; Vector3 direction; if (previous.HasValue) { val = current - previous.Value; direction = ((Vector3)(ref val)).normalized; } else if (footprintQueue.Count > 0) { val = footprintQueue.Peek() - current; direction = ((Vector3)(ref val)).normalized; } else { PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController; direction = ((Component)localPlayer).transform.forward; } val = Vector3.Cross(Vector3.up, direction); Vector3 perp = ((Vector3)(ref val)).normalized; Vector3 offset = perp * (leftFoot ? (-0.2f) : 0.2f); offset *= Random.Range(0.9f, 1.1f); Vector3 footprintPosition = current + offset; if ((Object)(object)Plugin.Instance.FootprintPrefab != (Object)null) { PathSystem.SpawnFootprint(Plugin.Instance.FootprintPrefab, footprintPosition, direction, 2f); } previous = current; leftFoot = !leftFoot; yield return (object)new WaitForSeconds(0.1f); } generatingPath = false; footprintCoroutine = null; } } internal class ItemSpawn { private static GameObject? battleVolumeInstance; public static IEnumerator SpawnItems() { yield return (object)new WaitForSeconds(10f); ManageUI.UISpawn(); ItemsSpawner(); EnableBattleVolume(); } public static List<ManageJson> GetFilteredWeightedItems() { List<Item> list = new List<Item>(); foreach (ShopItem shopItem in Items.shopItems) { if (shopItem != null) { list.Add(shopItem.item); } } foreach (PlainItem plainItem in Items.plainItems) { if (plainItem != null) { list.Add(plainItem.item); } } foreach (ScrapItem scrapItem in Items.scrapItems) { if (scrapItem != null) { list.Add(scrapItem.item); } } foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { if ((Object)(object)items != (Object)null) { list.Add(items); } } List<ManageJson> list2 = new List<ManageJson>(); return ManageJson.GetBattleItemsWeighted(list); } public static Item GetRandomItem(List<ManageJson> weightedItems) { float num = weightedItems.Sum((ManageJson wi) => wi.weight); float num2 = Random.Range(0f, num); float num3 = 0f; foreach (ManageJson weightedItem in weightedItems) { num3 += weightedItem.weight; if (num2 <= num3) { return weightedItem.item; } } return weightedItems[0].item; } public static void SpawnScrap(Item scrap, Vector3 position) { //IL_0007: 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_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) GameObject val = Object.Instantiate<GameObject>(scrap.spawnPrefab, position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer); GrabbableObject component = val.GetComponent<GrabbableObject>(); ((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation); component.fallTime = 0f; component.scrapValue = 0; ((NetworkBehaviour)component).NetworkObject.Spawn(false); } public static void ItemsSpawner() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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) HUDManager.Instance.DisplayTip("The company demand blood", " Only one can live... may the game start", true, false, "LC_Tip1"); if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogInfo((object)"getting all items... c:"); } List<ManageJson> filteredWeightedItems = GetFilteredWeightedItems(); int num = 100; if (TimeOfDay.Instance.currentLevel.PlanetName.ToUpper() == "98 GALETRY") { num = 200; } for (int i = 0; i < num; i++) { Item randomItem = GetRandomItem(filteredWeightedItems); Vector3 position = PositionManager(); if ((Object)(object)randomItem != (Object)null && (Object)(object)randomItem.spawnPrefab != (Object)null) { SpawnScrap(randomItem, position); } } ManualLogSource? log2 = Plugin.log; if (log2 != null) { log2.LogInfo((object)"items spawned successfully !!! UwU"); } } Plugin.hasBattleStarted = true; ClosestPlayerAndPath.StartClosestOpponentPath(); } public static List<Vector3> GalatryNodesList() { //IL_0017: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0140: 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_0176: 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_01ac: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); list.Add(new Vector3(-74f, 21f, -16f)); list.Add(new Vector3(-129f, 1f, -15f)); list.Add(new Vector3(-194f, 1f, -27f)); list.Add(new Vector3(-70f, 1f, 17f)); list.Add(new Vector3(-70f, 1f, 17f)); list.Add(new Vector3(-70f, 1f, 17f)); list.Add(new Vector3(-70f, 1f, 17f)); list.Add(new Vector3(-70f, 1f, 17f)); list.Add(new Vector3(-36f, 1f, -14f)); list.Add(new Vector3(-2f, -2f, 20f)); list.Add(new Vector3(-2f, 1f, 47f)); list.Add(new Vector3(-2f, -1f, -1f)); list.Add(new Vector3(56f, -1f, 13f)); list.Add(new Vector3(-27f, 1f, 11f)); list.Add(new Vector3(23f, 1f, -26f)); list.Add(new Vector3(-8f, -2f, -27f)); list.Add(new Vector3(-104f, 11f, -16f)); list.Add(new Vector3(-51f, 20f, -13f)); list.Add(new Vector3(-31f, 11f, -2f)); list.Add(new Vector3(-31f, 11f, -26f)); list.Add(new Vector3(46f, -1f, -8f)); list.Add(new Vector3(-66f, 1f, -44f)); return list; } public static List<Vector3> GordionNodesList() { //IL_0017: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0140: 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) List<Vector3> list = new List<Vector3>(); list.Add(new Vector3(-19f, -2f, -23f)); list.Add(new Vector3(-21f, -2f, -13f)); list.Add(new Vector3(-5f, -2f, 0f)); list.Add(new Vector3(-13f, -2f, -17f)); list.Add(new Vector3(5f, -2f, 37f)); list.Add(new Vector3(-4f, -2f, -35f)); list.Add(new Vector3(5f, -2f, -57f)); list.Add(new Vector3(-20f, -2f, -65f)); list.Add(new Vector3(6f, -18f, -44f)); list.Add(new Vector3(19f, -27f, -18f)); list.Add(new Vector3(9f, -19f, -7f)); list.Add(new Vector3(19f, -26f, -35f)); list.Add(new Vector3(-26f, -2f, -31f)); return list; } public static Vector3 PositionManager() { //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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) Vector3 val; if (TimeOfDay.Instance.currentLevel.PlanetName.ToUpper() == "71 GORDION") { List<Vector3> list = GordionNodesList(); val = list[Random.Range(0, list.Count)]; } else if (TimeOfDay.Instance.currentLevel.PlanetName.ToUpper() != "98 GALETRY") { val = RoundManager.Instance.outsideAINodes[Random.Range(0, RoundManager.Instance.outsideAINodes.Length)].transform.position; } else { List<Vector3> list2 = GalatryNodesList(); val = list2[Random.Range(0, list2.Count)]; } return RoundManager.Instance.GetRandomNavMeshPositionInRadius(val, 30f, default(NavMeshHit)); } public static async void MakeShipLeave(StartMatchLever shipLever) { if ((Object)(object)shipLever != (Object)null) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogInfo((object)"End of Battle, ship is living ! GG :>"); } shipLever.triggerScript.animationString = "SA_PushLeverBack"; shipLever.leverHasBeenPulled = false; shipLever.triggerScript.interactable = false; shipLever.leverAnimatorObject.SetBool("pullLever", false); StartOfRound.Instance.ShipLeaveAutomatically(false); } } public static List<PlayerControllerB> GetPlayers() { List<PlayerControllerB> list = StartOfRound.Instance.allPlayerScripts.ToList(); List<PlayerControllerB> list2 = new List<PlayerControllerB>(list); foreach (PlayerControllerB item in list) { if (!((NetworkBehaviour)item).IsSpawned || !item.isPlayerControlled) { list2.Remove(item); } } return list2; } public static void EnableBattleVolume() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)battleVolumeInstance != (Object)null || !((Object)(object)Plugin.Instance.VolumeLightBattle != (Object)null) || !Plugin.LethalBattleConfig.IsVolumeInBattle.Value) { return; } StartMatchLever val = Object.FindObjectOfType<StartMatchLever>(); if ((Object)(object)val == (Object)null) { ManualLogSource? log = Plugin.log; if (log != null) { log.LogError((object)"shipLever not found!"); } } else { battleVolumeInstance = Object.Instantiate<GameObject>(Plugin.Instance.VolumeLightBattle, ((Component)val).transform); battleVolumeInstance.transform.localPosition = Vector3.zero; battleVolumeInstance.transform.localRotation = Quaternion.identity; } } public static void DisableBattleVolume() { if (!((Object)(object)battleVolumeInstance == (Object)null) && Plugin.LethalBattleConfig.IsVolumeInBattle.Value) { Object.Destroy((Object)(object)battleVolumeInstance); battleVolumeInstance = null; } } } internal class ManageChat { public static void SendChatMessage(string message) { } public static void ConfirmRestart() { Plugin.verifying = true; SendChatMessage("Are you sure? Type CONFIRM or DENY."); } public static void AcceptRestart(StartOfRound manager) { SendChatMessage("Battle confirmed."); Plugin.verifying = false; } public static void DeclineRestart() { SendChatMessage("Battle aborted."); Plugin.verifying = false; } } internal static class PathSystem { public static Queue<Vector3> GeneratePathPoints(Vector3 start, Vector3 end, float spacing) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_006e: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //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_010e: 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_010a: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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) Queue<Vector3> queue = new Queue<Vector3>(); NavMeshPath val = new NavMeshPath(); if (!NavMesh.CalculatePath(start, end, -1, val)) { return queue; } if ((int)val.status > 0) { return queue; } Vector3[] corners = val.corners; if (corners.Length < 2) { return queue; } bool flag = true; float num = 0.18f; for (int i = 0; i < corners.Length - 1; i++) { Vector3 val2 = corners[i]; Vector3 val3 = corners[i + 1]; Vector3 val4 = val3 - val2; Vector3 normalized = ((Vector3)(ref val4)).normalized; val4 = Vector3.Cross(Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; float num2 = Vector3.Distance(val2, val3); if (!(num2 <= 0.01f)) { float num8; for (float num3 = 0f; num3 < num2; num3 += num8) { float num4 = num3 / num2; Vector3 val5 = Vector3.Lerp(val2, val3, num4); float num5 = Random.Range(-0.04f, 0.04f); float num6 = num + num5; Vector3 val6 = (flag ? (-normalized2) : normalized2) * num6; float num7 = Random.Range(-0.05f, 0.05f); val5 += normalized * num7; queue.Enqueue(val5 + val6); flag = !flag; num8 = spacing + Random.Range(-0.12f, 0.12f); } } } return queue; } public static void SpawnFootprint(GameObject footprintPrefab, Vector3 position, Vector3 direction, float lifetime) { //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_0022: 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_002c: 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) float num = Random.Range(-12f, 12f); Quaternion val = Quaternion.LookRotation(direction) * Quaternion.Euler(0f, num, 0f); GameObject val2 = Object.Instantiate<GameObject>(footprintPrefab, position, val); Rigidbody component = val2.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; } Object.Destroy((Object)(object)val2, lifetime); } } public class ScrapIndicator : MonoBehaviour { private GrabbableObject? grabbable; private GameObject? circleObject; private bool circleCreated; private void Awake() { grabbable = ((Component)this).GetComponent<GrabbableObject>(); } private void Start() { UpdateIndicator(); } private void Update() { if (!((Object)(object)grabbable == (Object)null)) { UpdateIndicator(); } } private void UpdateIndicator() { bool flag = (Object)(object)grabbable != (Object)null && !grabbable.isHeld; if (flag && !circleCreated) { CreateYellowCircle(); } else if (!flag && circleCreated) { DestroyYellowCircle(); } } private void CreateYellowCircle() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_00ca: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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) if (!((Object)(object)circleObject != (Object)null)) { circleObject = new GameObject("ScrapIndicator"); circleObject.transform.SetParent(((Component)this).transform); circleObject.transform.localPosition = new Vector3(0f, -0.1f, 0f); circleObject.transform.localRotation = Quaternion.identity; LineRenderer val = circleObject.AddComponent<LineRenderer>(); val.useWorldSpace = false; val.loop = true; val.positionCount = 64; val.startWidth = 0.04f; val.endWidth = 0.04f; ((Renderer)val).material = new Material(Shader.Find("Sprites/Default")); val.startColor = Color.yellow; val.endColor = Color.yellow; float num = 0.6f; for (int i = 0; i < 64; i++) { float num2 = (float)i * MathF.PI * 2f / 64f; val.SetPosition(i, new Vector3(Mathf.Cos(num2) * num, 0f, Mathf.Sin(num2) * num)); } circleCreated = true; } } private void DestroyYellowCircle() { if ((Object)(object)circleObject != (Object)null) { Object.Destroy((Object)(object)circleObject); circleObject = null; } circleCreated = false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }