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 LethalRPG v0.10.0
LethalRPG.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalRPG.Patches; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Cucumis")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 Cucumis")] [assembly: AssemblyFileVersion("0.10.0.0")] [assembly: AssemblyInformationalVersion("0.10.0+9a70785")] [assembly: AssemblyProduct("LethalRPG")] [assembly: AssemblyTitle("LethalRPG")] [assembly: InternalsVisibleTo("PatchCheck")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.10.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 LethalRPG { public enum Balancing { Standard, Generous, Strict } public static class BalancingPresets { private sealed class Rule { public UpgradeType Type; public string Key; public float Generous; public float Strict; public bool Add; } public const int LevelLimit = 20; private const double GenerousLevels = 3.0; private const double StrictLevels = 0.6; private const float CrouchSpeedGap = 0.5f; private static readonly Dictionary<UpgradeType, int> GenerousCeiling = new Dictionary<UpgradeType, int> { { UpgradeType.Agility, 10 }, { UpgradeType.Jump, 6 }, { UpgradeType.LongReach, 8 }, { UpgradeType.Climber, 7 }, { UpgradeType.Vitality, 8 }, { UpgradeType.Medic, 8 }, { UpgradeType.Recovery, 8 }, { UpgradeType.Strength, 7 }, { UpgradeType.Brawler, 8 }, { UpgradeType.Inventory, 8 } }; private static readonly Dictionary<UpgradeType, float> GenerousEffect = new Dictionary<UpgradeType, float> { { UpgradeType.Brawler, 0.5f } }; private static readonly Rule[] Rules = new Rule[24] { Scale(UpgradeType.Lockpicker, "Seconds", 0.5f, 1.5f), Scale(UpgradeType.FieldHacker, "Seconds", 0.5f, 1.5f), Scale(UpgradeType.Medic, "RegenDelaySeconds", 0.5f, 1.5f), Scale(UpgradeType.ConcussiveBlows, "StunTime", 1.5f, 0.75f), Scale(UpgradeType.ConcussiveBlows, "CooldownSeconds", 0.5f, 1.5f), Scale(UpgradeType.CoilBreaker, "Seconds", 0.5f, 1.5f), Scale(UpgradeType.CoilBreaker, "Duration", 1.5f, 0.75f), Scale(UpgradeType.CoilBreaker, "CooldownSeconds", 0.5f, 1.5f), Scale(UpgradeType.BlastShield, "Damage", 0.5f, 1.3333334f), Scale(UpgradeType.RallyingPresence, "Range", 1.5f, 0.75f), Scale(UpgradeType.TrainedEyes, "VisibilityMultiplier", 1.4f, 0.8f), Scale(UpgradeType.GunkProof, "VisorClearSpeed", 1.5f, 0.75f), Scale(UpgradeType.GunkProof, "SlipReduction", 1.4f, 0.6f), Scale(UpgradeType.PestControl, "KillSpeed", 1.5f, 0.75f), Scale(UpgradeType.PestControl, "TankSaving", 1.4f, 0.6f), Scale(UpgradeType.PestControl, "HealSpeed", 1.5f, 0.75f), Scale(UpgradeType.GentleCollector, "QuietChance", 1.4f, 0.6f), Scale(UpgradeType.SoftLanding, "FallDamage", 0.8f, 1.1333333f), new Rule { Type = UpgradeType.GhostStep, Key = "NoiseLeft", Generous = 0f, Strict = 0.3f, Add = true }, Scale(UpgradeType.Overcharge, "HeatSpeed", 0.6f, 1.4f), Scale(UpgradeType.Overcharge, "PullGrowth", 0.6f, 1.4f), Scale(UpgradeType.Mechanic, "DamageTaken", 0.6f, 1.4f), Scale(UpgradeType.Mechanic, "RepairSpeed", 1.5f, 0.75f), new Rule { Type = UpgradeType.SecondWind, Key = "ChargesPerDay", Generous = 1f, Strict = 0f, Add = true } }; private static Rule Scale(UpgradeType type, string key, float generous, float strict) { return new Rule { Type = type, Key = key, Generous = generous, Strict = strict }; } public static void Apply(RpgSettings settings) { if (settings.Balancing == Balancing.Standard) { return; } Dictionary<UpgradeType, float> dictionary = new Dictionary<UpgradeType, float>(); UpgradeDef[] all = Upgrades.All; foreach (UpgradeDef upgradeDef in all) { if (!upgradeDef.Unique) { float num = ScaleLevels(settings, upgradeDef.Type); if (num < 1f) { dictionary[upgradeDef.Type] = num; } } } all = Upgrades.All; foreach (UpgradeDef upgradeDef2 in all) { if (upgradeDef2.Unique) { UpgradeSettings upgradeSettings = settings.For(upgradeDef2.Type); upgradeSettings.RequiredLevel = SameEffect(dictionary, upgradeDef2.Requires, upgradeSettings.RequiredLevel); if (upgradeDef2.IsUltimate) { upgradeSettings.RequiredLevel2 = SameEffect(dictionary, upgradeDef2.Requires2, upgradeSettings.RequiredLevel2); } } } Rule[] rules = Rules; foreach (Rule rule in rules) { ApplyRule(settings, rule); } } private static float ScaleLevels(RpgSettings settings, UpgradeType type) { UpgradeSettings upgradeSettings = settings.For(type); int maxLevel = upgradeSettings.MaxLevel; if (settings.Balancing == Balancing.Strict) { upgradeSettings.MaxLevel = Math.Max(1, (int)Math.Round((double)maxLevel * 0.6, MidpointRounding.AwayFromZero)); return 1f; } float effectPerLevel = upgradeSettings.EffectPerLevel; if (GenerousEffect.TryGetValue(type, out var value)) { UpgradeDef upgradeDef = Upgrades.Get(type); upgradeSettings.EffectPerLevel = Math.Max(upgradeDef.EffectMin, Math.Min(upgradeDef.EffectMax, effectPerLevel * value)); } float num = ((effectPerLevel > 0f) ? (upgradeSettings.EffectPerLevel / effectPerLevel) : 1f); int num2 = Math.Min((int)Math.Round((double)maxLevel * 3.0), UsefulLevels(settings, type)); if (GenerousCeiling.TryGetValue(type, out var value2)) { num2 = Math.Min(num2, EffectCeiling(settings, type, value2)); } if ((num < 1f) ? (TopEffect(settings, type, upgradeSettings.EffectPerLevel, num2) < TopEffect(settings, type, effectPerLevel, maxLevel) - 0.0001f) : (num2 <= maxLevel)) { upgradeSettings.EffectPerLevel = effectPerLevel; return 1f; } upgradeSettings.CostMultiplier = ((maxLevel <= 1) ? 1f : ((float)Math.Pow(upgradeSettings.CostMultiplier, ((double)maxLevel - 1.0) / ((double)num2 - 1.0)))); upgradeSettings.MaxLevel = num2; return num; } private static float TopEffect(RpgSettings settings, UpgradeType type, float step, int levels) { float num = step * settings.EffectFactorOf(type); if (type != UpgradeType.Brawler) { return num * (float)levels; } return RpgSettings.BrawlerBonus(step, num, levels); } private static int EffectCeiling(RpgSettings settings, UpgradeType type, int ceiling) { float num = settings.EffectFactorOf(type); if (!(num > 1f)) { return ceiling; } return Math.Max(1, (int)Math.Floor((float)ceiling / num + 0.0001f)); } private static int SameEffect(Dictionary<UpgradeType, float> weaker, UpgradeType type, int level) { if (level <= 0 || !weaker.TryGetValue(type, out var value)) { return level; } return Math.Min(20, (int)Math.Ceiling((float)level / value - 0.0001f)); } public static int UsefulLevels(RpgSettings settings, UpgradeType type) { float num = settings.EffectPerLevel(type); int num2 = 20; if (num <= 0f) { return num2; } if (settings.For(type).Params.TryGetValue("MaxReduction", out var value)) { num2 = Math.Min(num2, LevelsFor(value / num)); } if (type == UpgradeType.Inventory) { num2 = Math.Min(num2, LevelsFor(16f / Math.Max(1f, (float)Math.Round(num)))); } if (type == UpgradeType.CrouchWalk) { num2 = Math.Min(num2, LevelsFor(0.5f / num)); } return Math.Max(1, num2); } private static int LevelsFor(float levels) { return (int)Math.Ceiling(levels - 0.001f); } private static void ApplyRule(RpgSettings settings, Rule rule) { UpgradeSettings upgradeSettings = settings.For(rule.Type); SkillParam skillParam = Array.Find(Upgrades.Get(rule.Type).Params, (SkillParam p) => p.Key == rule.Key); if (skillParam != null && upgradeSettings.Params != null && upgradeSettings.Params.TryGetValue(rule.Key, out var value)) { float num = ((settings.Balancing == Balancing.Generous) ? rule.Generous : rule.Strict); value = (rule.Add ? (value + num) : (value * num)); if (skillParam.IsInt) { value = (float)Math.Round(value, MidpointRounding.AwayFromZero); } upgradeSettings.Params[rule.Key] = Math.Max(skillParam.Min, Math.Min(skillParam.Max, value)); } } public static string Describe(Balancing balancing) { return balancing switch { Balancing.Generous => "Balancing: Generous (up to 3x the levels with slower rising prices, faster lockpicking and hacking, stronger skills).", Balancing.Strict => "Balancing: Strict (40% fewer levels, slower lockpicking and hacking, weaker skills).", _ => null, }; } } public static class Builds { private static UpgradeDef Leveled(string id) { return Upgrades.All.FirstOrDefault((UpgradeDef u) => u.Id == id && !u.Unique); } public static List<string> CurrentBuild(PlayerProgress progress) { List<string> list = new List<string>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (string item in progress.BuildOrder ?? new List<string>()) { UpgradeDef upgradeDef = Leveled(item); if (upgradeDef != null) { dictionary.TryGetValue(item, out var value); if (value < progress.GetLevel(upgradeDef.Type)) { list.Add(item); dictionary[item] = value + 1; } } } foreach (UpgradeDef item2 in Upgrades.All.Where((UpgradeDef u) => !u.Unique)) { dictionary.TryGetValue(item2.Id, out var value2); for (int num = value2; num < progress.GetLevel(item2.Type); num++) { list.Add(item2.Id); } } return list; } public static List<UpgradeType> MissingSteps(PlayerProgress progress, IList<string> build, RpgSettings settings = null) { List<UpgradeType> list = new List<UpgradeType>(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (string item in build ?? new List<string>()) { UpgradeDef upgradeDef = Leveled(item); if (upgradeDef != null) { dictionary.TryGetValue(item, out var value); value = (dictionary[item] = value + 1); if ((settings == null || (settings.IsEnabled(upgradeDef.Type) && value <= settings.For(upgradeDef.Type).MaxLevel)) && progress.GetLevel(upgradeDef.Type) < value) { list.Add(upgradeDef.Type); } } } return list; } public static long CostOf(RpgSettings settings, PlayerProgress progress, IEnumerable<UpgradeType> steps, int crew = 1) { Dictionary<UpgradeType, int> dictionary = new Dictionary<UpgradeType, int>(); long num = 0L; foreach (UpgradeType step in steps) { if (!dictionary.TryGetValue(step, out var value)) { value = progress.GetLevel(step); } num += settings.PriceFor(step, value, crew); dictionary[step] = value + 1; } return num; } public static string Totals(IEnumerable<string> build, RpgSettings settings = null) { return string.Join(", ", from d in build.Select(Leveled) where d != null group d by d.Type into g select $"{g.First().DisplayName} {g.Count()}{CapNote(settings, g.Key, g.Count())}"); } private static string CapNote(RpgSettings settings, UpgradeType type, int levels) { if (settings == null || !settings.IsEnabled(type)) { return ""; } int maxLevel = settings.For(type).MaxLevel; if (levels <= maxLevel) { return ""; } return $" (capped at {maxLevel})"; } public static string Increments(IEnumerable<UpgradeType> steps) { return string.Join(", ", from t in steps group t by t into g select $"{Upgrades.Get(g.Key).DisplayName} +{g.Count()}"); } } internal static class CoilBreaker { public const float Range = 4f; public const float HostSlack = 3f; private const float PendingSeconds = 5f; private const float AnswerSeconds = 5f; private static readonly FieldRef<SpringManAI, bool> SetOnCooldown = AccessTools.FieldRefAccess<SpringManAI, bool>("setOnCooldown"); private static readonly Dictionary<string, float> readyAt = new Dictionary<string, float>(); private static readonly Dictionary<int, (float Duration, float Since)> pending = new Dictionary<int, (float, float)>(); private static float localReadyAt; private static float awaitingUntil; internal static Func<PlayerControllerB, SpringManAI, float> Distance = (PlayerControllerB player, SpringManAI coil) => Vector3.Distance(((Component)player).transform.position, ((Component)coil).transform.position); internal static Action<SpringManAI> PowerDown = delegate(SpringManAI coil) { coil.SetCoilheadOnCooldownClientRpc(true); }; public static float RechargeLeft => Mathf.Max(0f, localReadyAt - Time.realtimeSinceStartup); public static bool AwaitingAnswer => Time.realtimeSinceStartup < awaitingUntil; public static void ResetSession() { readyAt.Clear(); pending.Clear(); localReadyAt = 0f; awaitingUntil = 0f; } public static bool IsPoweredDown(SpringManAI coil) { return SetOnCooldown.Invoke(coil); } public static void Request(SpringManAI coil) { awaitingUntil = Time.realtimeSinceStartup + 5f; RpgNetwork.RequestCoilBreaker(((NetworkBehaviour)coil).NetworkObjectId); } public static string Decide(PlayerControllerB player, ulong? coilId) { float realtimeSinceStartup = Time.realtimeSinceStartup; DropStale(realtimeSinceStartup); string text = RpgState.KeyOf(player); float value; float num = ((text != null && readyAt.TryGetValue(text, out value)) ? Mathf.Max(0f, value - realtimeSinceStartup) : 0f); SpringManAI coil; string text2 = Refusal(player, text, coilId, num, out coil); if (text2 != null) { Plugin.Log.LogInfo((object)("Coil Breaker: " + RpgState.LogName(player) + " was refused: " + text2)); return Answer(granted: false, num, text2); } float num2 = RpgState.Param(UpgradeType.CoilBreaker, "Duration"); float num3 = RpgState.Param(UpgradeType.CoilBreaker, "CooldownSeconds"); pending[((Object)coil).GetInstanceID()] = (num2, realtimeSinceStartup); PowerDown(coil); readyAt[text] = realtimeSinceStartup + num3; Plugin.Log.LogInfo((object)("Coil Breaker: " + RpgState.LogName(player) + " shut down a coil head for " + Seconds(num2))); return Answer(granted: true, num3, "Coil head shut down for " + Seconds(num2) + "."); } private static string Refusal(PlayerControllerB player, string key, ulong? coilId, float left, out SpringManAI coil) { coil = null; if ((Object)(object)player == (Object)null || key == null) { return "Your employee record is not ready yet."; } if (Guard.CoilBreakerHost.Disabled) { return "Coil Breaker is switched off on the host after errors."; } if (!RpgState.Has(player, UpgradeType.CoilBreaker)) { return "You do not have Coil Breaker."; } if (player.isPlayerDead) { return "Dead employees cannot shut down coil heads."; } coil = Find(coilId); if ((Object)(object)coil == (Object)null || !((NetworkBehaviour)coil).IsSpawned || ((EnemyAI)coil).isEnemyDead) { return "That coil head is gone."; } if (IsPoweredDown(coil) || pending.ContainsKey(((Object)coil).GetInstanceID())) { return "That coil head is already powered down."; } if (Distance(player, coil) > 7f) { return "You are too far away from the coil head."; } if (left > 0f) { return "Coil Breaker is recharging (" + Clock(left) + ")."; } return null; } private static SpringManAI Find(ulong? networkObjectId) { RoundManager instance = RoundManager.Instance; if (!networkObjectId.HasValue || (Object)(object)instance == (Object)null || instance.SpawnedEnemies == null) { return null; } foreach (EnemyAI spawnedEnemy in instance.SpawnedEnemies) { SpringManAI val = (SpringManAI)(object)((spawnedEnemy is SpringManAI) ? spawnedEnemy : null); if (val != null && (Object)(object)val != (Object)null && ((NetworkBehaviour)val).NetworkObjectId == networkObjectId) { return val; } } return null; } private static void DropStale(float now) { foreach (int item in (from entry in pending where now - entry.Value.Since > 5f select entry.Key).ToList()) { pending.Remove(item); } } public static void TellRecharge(PlayerControllerB player) { string text = RpgState.KeyOf(player); PlayerControllerB localPlayer = RpgState.LocalPlayer; if (text != null && !((Object)(object)player == (Object)(object)localPlayer) && readyAt.TryGetValue(text, out var value)) { float num = value - Time.realtimeSinceStartup; if (num > 0f) { RpgNetwork.SendCoilBreakerAnswer(player, Answer(granted: false, num, "")); } } } public static void ApplyDuration(SpringManAI coil) { int instanceID = ((Object)coil).GetInstanceID(); if (pending.TryGetValue(instanceID, out (float, float) value) && IsPoweredDown(coil)) { pending.Remove(instanceID); if (Time.realtimeSinceStartup - value.Item2 <= 5f) { (coil.onCooldownPhase, _) = value; } } } internal static string Answer(bool granted, float secondsLeft, string text) { return $"{(granted ? 1 : 0)}|{Mathf.CeilToInt(secondsLeft).ToString(CultureInfo.InvariantCulture)}|{text}"; } public static void Receive(string answer) { string[] array = (answer ?? "").Split(new char[1] { '|' }, 3); if (array.Length >= 3 && int.TryParse(array[1], NumberStyles.None, CultureInfo.InvariantCulture, out var result)) { awaitingUntil = 0f; localReadyAt = Time.realtimeSinceStartup + (float)result; if (array[0] != "1" && array[2].Length > 0) { RpgNotices.ShowNow("Coil Breaker", array[2]); } } } public static string Clock(float seconds) { int num = Mathf.CeilToInt(seconds); return string.Format("{0}:{1}", num / 60, (num % 60).ToString("00", CultureInfo.InvariantCulture)); } private static string Seconds(float seconds) { return seconds.ToString("0.#", CultureInfo.InvariantCulture) + " s"; } } internal static class Compat { internal static readonly Dictionary<string, string> InventoryMods = new Dictionary<string, string> { { "FlipMods.ReservedItemSlotCore", "ReservedItemSlotCore" }, { "FlipMods.HotbarPlus", "HotbarPlus" }, { "com.potatoepet.AdvancedCompany", "AdvancedCompany" }, { "Stoneman.LethalProgression", "LethalProgression" }, { "TisRyno.LethalProgression", "LethalProgression" } }; internal const string LethalThingsGuid = "evaisa.lethalthings"; internal const string LethalThings = "LethalThings"; internal const string UtilityBeltClass = "PouchyBelt"; internal const int UtilityBeltSlots = 3; internal const string LateGameUpgradesGuid = "com.malco.lethalcompany.moreshipupgrades"; internal const string LateGameUpgrades = "LateGameUpgrades"; private static readonly Dictionary<string, string> OverlappingMods = new Dictionary<string, string> { { "com.malco.lethalcompany.moreshipupgrades", "LateGameUpgrades" }, { "Stoneman.LethalProgression", "LethalProgression" }, { "TisRyno.LethalProgression", "LethalProgression" }, { "ShaosilGaming.GeneralImprovements", "GeneralImprovements" } }; internal static readonly Dictionary<UpgradeType, string> LguOverlaps = new Dictionary<UpgradeType, string> { { UpgradeType.Stamina, "Bigger Lungs" }, { UpgradeType.Agility, "Running Shoes" }, { UpgradeType.Jump, "Strong Legs" }, { UpgradeType.Strength, "Back Muscles" }, { UpgradeType.Vitality, "Stimpack" }, { UpgradeType.CrouchWalk, "Carbon Kneejoints" }, { UpgradeType.Lungs, "Oxygen Canisters" }, { UpgradeType.Handyman, "Quick Hands" }, { UpgradeType.Brawler, "Protein Powder" }, { UpgradeType.LongReach, "Mechanical Arms" }, { UpgradeType.Analyst, "Better Scanner" }, { UpgradeType.Climber, "Climbing Gloves" }, { UpgradeType.Electrician, "Lithium Batteries" }, { UpgradeType.Marksman, "Sleight of Hand" } }; internal static Func<UpgradeType, string> TakenOverBy = LguTakenOverBy; internal static bool checkedInventory; internal static string inventoryConflict; internal static bool? hasLethalThings; internal static bool? hasLateGameUpgrades; internal static Func<ConfigFile> LateGameUpgradesConfig = () => PluginConfig("com.malco.lethalcompany.moreshipupgrades"); internal const string MoreCompanyGuid = "me.swipez.melonloader.morecompany"; internal static bool? hasMoreCompany; internal const string LethalConfigGuid = "ainavt.lc.lethalconfig"; internal const string InputUtilsGuid = "com.rune580.LethalCompanyInputUtils"; internal const string LethalConfigAssembly = "LethalConfig"; internal const string InputUtilsAssembly = "LethalCompanyInputUtils"; private static Dictionary<UpgradeType, bool> lguOn; private static bool logged; public static string InventoryConflict { get { if (!checkedInventory) { checkedInventory = true; try { inventoryConflict = (from m in InventoryMods where Chainloader.PluginInfos.ContainsKey(m.Key) select m.Value).FirstOrDefault() ?? (Chainloader.PluginInfos.Keys.Any((string guid) => guid.Contains("ReservedItem")) ? "ReservedItemSlotCore" : null); } catch (TypeInitializationException) { inventoryConflict = null; } } return inventoryConflict; } } public static bool HasLethalThings { get { if (!hasLethalThings.HasValue) { try { hasLethalThings = Chainloader.PluginInfos.ContainsKey("evaisa.lethalthings"); } catch (TypeInitializationException) { hasLethalThings = false; } } return hasLethalThings.Value; } } public static bool HasLateGameUpgrades { get { if (!hasLateGameUpgrades.HasValue) { try { hasLateGameUpgrades = Chainloader.PluginInfos.ContainsKey("com.malco.lethalcompany.moreshipupgrades"); } catch (TypeInitializationException) { hasLateGameUpgrades = false; } } return hasLateGameUpgrades.Value; } } public static bool HasMoreCompany { get { if (!hasMoreCompany.HasValue) { try { hasMoreCompany = Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"); } catch (TypeInitializationException) { hasMoreCompany = false; } } return hasMoreCompany.Value; } } public static bool InventoryUpgradeAllowed => InventoryConflict == null; public static bool InventoryApplies { get { if (InventoryUpgradeAllowed) { return RpgState.Settings.InventoryBlockedBy == null; } return false; } } public static bool CarriesUtilityBelt(PlayerControllerB player) { return UtilityBelts(player) > 0; } internal static int UtilityBelts(PlayerControllerB player) { int num = (IsUtilityBelt(player.ItemOnlySlot) ? 1 : 0); if (player.ItemSlots != null) { GrabbableObject[] itemSlots = player.ItemSlots; for (int i = 0; i < itemSlots.Length; i++) { if (IsUtilityBelt(itemSlots[i])) { num++; } } } return num; } internal static bool IsUtilityBelt(GrabbableObject item) { if ((Object)(object)item != (Object)null) { return ((object)item).GetType().Name == "PouchyBelt"; } return false; } internal static string Counterpart(UpgradeType type, string mod) { if (!(mod == "LateGameUpgrades") || !LguOverlaps.TryGetValue(type, out var value)) { return null; } return value; } internal static ConfigDefinition LguSwitch(string upgrade) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown return new ConfigDefinition(upgrade, "Enable " + upgrade + " Upgrade"); } private static string LguTakenOverBy(UpgradeType type) { if (!LguOverlaps.ContainsKey(type) || !HasLateGameUpgrades || !LguSwitches()[type]) { return null; } return "LateGameUpgrades"; } private static ConfigFile PluginConfig(string guid) { if (!Chainloader.PluginInfos.TryGetValue(guid, out var value) || value == null) { return null; } BaseUnityPlugin instance = value.Instance; if (!((Object)(object)instance != (Object)null)) { return null; } return instance.Config; } internal static Dictionary<UpgradeType, bool> LguSwitches() { if (lguOn != null) { return lguOn; } Dictionary<UpgradeType, bool> dictionary = new Dictionary<UpgradeType, bool>(); List<UpgradeType> list = new List<UpgradeType>(); List<UpgradeType> list2 = new List<UpgradeType>(); string unreadable = null; ConfigFile val = null; try { val = LateGameUpgradesConfig(); if (val == null) { unreadable = "its config could not be read"; } } catch (Exception ex) { unreadable = "its config could not be read (" + ex.GetType().Name + ": " + ex.Message + ")"; } foreach (UpgradeType item in LguOverlaps.Keys.OrderBy((UpgradeType type) => type)) { bool value = true; ConfigDefinition val2 = LguSwitch(LguOverlaps[item]); if (val != null) { if (!val.ContainsKey(val2)) { list.Add(item); } else if (val[val2].BoxedValue is bool flag) { value = flag; } else { list2.Add(item); } } dictionary[item] = value; } lguOn = dictionary; LogLguSwitches(dictionary, unreadable, list, list2); return dictionary; } private static string LguEntry(UpgradeType type) { ConfigDefinition val = LguSwitch(LguOverlaps[type]); return val.Section + "/" + val.Key; } private static void LogLguSwitches(Dictionary<UpgradeType, bool> on, string unreadable, List<UpgradeType> missing, List<UpgradeType> odd) { if (unreadable != null) { Plugin.Log.LogWarning((object)("LateGameUpgrades: " + unreadable + ", so its upgrades count as on (its default): OverlapPolicy PreferOtherMod leaves " + Names(on.Keys.OrderBy((UpgradeType type) => type)) + " to LateGameUpgrades.")); } if (missing.Count > 0) { Plugin.Log.LogWarning((object)("LateGameUpgrades: its config has no entry " + string.Join(", ", missing.Select(LguEntry)) + ", so " + ((missing.Count == 1) ? "it counts" : "they count") + " as on (its default): OverlapPolicy PreferOtherMod leaves " + Names(missing) + " to LateGameUpgrades. Another LateGameUpgrades version may have renamed " + ((missing.Count == 1) ? "it" : "them") + ".")); } if (odd.Count > 0) { Plugin.Log.LogWarning((object)("LateGameUpgrades: its entry " + string.Join(", ", odd.Select(LguEntry)) + " is no true/false value, so " + ((odd.Count == 1) ? "it counts" : "they count") + " as on (its default): OverlapPolicy PreferOtherMod leaves " + Names(odd) + " to LateGameUpgrades.")); } Plugin.Log.LogInfo((object)("LateGameUpgrades' config (OverlapPolicy PreferOtherMod): " + (on.ContainsValue(value: true) ? ("on there, so left to it: " + Pairs(value: true)) : "none of the same upgrades on there") + (on.ContainsValue(value: false) ? ("; off there, so LethalRPG keeps: " + Pairs(value: false)) : "") + ".")); static string Names(IEnumerable<UpgradeType> types) { return string.Join(", ", types.Select((UpgradeType type) => Upgrades.Get(type).DisplayName)); } string Pairs(bool value) { return string.Join(", ", from pair in @on where pair.Value == value orderby pair.Key select Upgrades.Get(pair.Key).DisplayName + " (" + LguOverlaps[pair.Key] + ")"); } } public static string HostInventoryBlocker() { return InventoryConflict; } public static List<string> Detected() { List<string> list = new List<string>(); try { list.AddRange(from m in InventoryMods.Concat(OverlappingMods) where Chainloader.PluginInfos.ContainsKey(m.Key) select m.Value); } catch (TypeInitializationException) { } if (InventoryConflict != null) { list.Add(InventoryConflict); } if (HasLethalThings) { list.Add("LethalThings"); } return list.Distinct().ToList(); } public static List<string> Plugins() { try { return (from info in Chainloader.PluginInfos.Values where info != null && info.Metadata != null select $"{info.Metadata.GUID} {info.Metadata.Version} ({info.Metadata.Name})").OrderBy<string, string>((string text) => text, StringComparer.OrdinalIgnoreCase).ToList(); } catch (TypeInitializationException) { return new List<string>(); } } public static List<UpgradeType> LimitedSkills() { return (from skill in Plugin.DegradedSkills.Keys.Select(((UpgradeType Skill, string Where) key) => key.Skill).Distinct() orderby skill select skill).ToList(); } public static bool IsLimited(UpgradeType skill) { return Plugin.DegradedSkills.Keys.Any(((UpgradeType Skill, string Where) key) => key.Skill == skill); } private static string SkillNames(IEnumerable<UpgradeType> skills, int max) { List<string> list = skills.Select((UpgradeType skill) => Upgrades.Get(skill).DisplayName).ToList(); if (list.Count > max) { return string.Format("{0} and {1} more", string.Join(", ", list.Take(max)), list.Count - max); } return string.Join(", ", list); } private static string FailedPatchesLine() { return $"WARNING: {Plugin.FailedPatches.Count} patch group(s) failed to load (conflict with another mod?): " + string.Join(", ", Plugin.FailedPatches); } public static List<string> Report() { List<string> list = new List<string>(); List<UpgradeType> list2 = LimitedSkills(); if (list2.Count > 0) { list.Add("WARNING: These skills may not work with your mods: " + SkillNames(list2, int.MaxValue) + "."); } if (Plugin.FailedPatches.Count > 0) { list.Add(FailedPatchesLine()); } if (list2.Count > 0) { List<string> list3 = Detected(); if (list3.Count > 0) { list.Add("Mods LethalRPG detected on this PC: " + string.Join(", ", list3) + "."); } list.Add("rpg report names the other mods that change the code these skills need."); } return list; } public static string Notice() { int count = Plugin.FailedPatches.Count; List<UpgradeType> list = LimitedSkills(); if (list.Count == 0) { if (count != 0) { return $"{count} patch group(s) failed to load, some skills will not work. " + "Probably a conflict with another mod; see the BepInEx log."; } return null; } return ((count > 0) ? $"{count} patch group(s) failed to load. " : "") + SkillNames(list, 3) + " may not work with your mods. See rpg info."; } public static string OverlapLine(RpgSettings settings) { if (settings.OverlapPolicy != OverlapPolicy.PreferOtherMod) { return null; } List<IGrouping<string, UpgradeType>> list = (from u in Upgrades.All select u.Type into type where settings.LeftTo(type) != null group type by settings.LeftTo(type)).ToList(); if (list.Count == 0) { return "OverlapPolicy PreferOtherMod: no other mod here has the same upgrades on, so LethalRPG leaves none to another mod."; } return string.Join(" ", list.Select((IGrouping<string, UpgradeType> mod) => "Left to " + mod.Key + ", which has the same upgrades (OverlapPolicy PreferOtherMod): " + SkillNames(mod, int.MaxValue) + ".")) + " Levels bought in them are kept but do nothing, and skills need no level in them."; } public static List<string> OtherOwners(string where) { Assembly own = typeof(Plugin).Assembly; return (from patch in (from info in (from method in Harmony.GetAllPatchedMethods() where IlTools.Where(method) == @where select method).Select((Func<MethodBase, Patches>)Harmony.GetPatchInfo) where info != null select info).SelectMany((Patches info) => info.Prefixes.Concat(info.Postfixes).Concat(info.Transpilers).Concat(info.Finalizers) .Concat(info.ILManipulators)) where patch.PatchMethod?.DeclaringType?.Assembly != own select patch.owner).Distinct().OrderBy<string, string>((string owner) => owner, StringComparer.Ordinal).ToList(); } public static void ResetSession() { lguOn = null; } public static void LogSummary() { if (HasLethalThings) { LogUtilityBelt(); } if (logged) { return; } logged = true; if (InventoryConflict != null) { Plugin.Log.LogWarning((object)(InventoryConflict + " manages inventory slots itself: the Inventory upgrade is disabled.")); } try { foreach (KeyValuePair<string, string> item in OverlappingMods.Where((KeyValuePair<string, string> m) => Chainloader.PluginInfos.ContainsKey(m.Key))) { Plugin.Log.LogInfo((object)((item.Value == "LateGameUpgrades") ? (item.Value + " detected: similar upgrades from both mods stack, unless the host's OverlapPolicy is PreferOtherMod.") : (item.Value + " detected: similar upgrades from both mods stack."))); } } catch (TypeInitializationException) { } } private static void LogUtilityBelt() { Plugin.Log.LogInfo((object)"LethalThings: its Utility Belt adds 3 slots on top of the Inventory upgrade's; taking it off removes the last 3 slots and drops what is in them."); } } public enum GainKind { Xp, Budget, Note, TeamBudget } internal static class DayReport { internal sealed class Draft { public string Xp; public string XpSources; public int Budget; public int TeamBudget; public readonly List<string> Notes = new List<string>(); public string Saves; public string SavesShort; public string CanBuy; public string Hint; public string HintShort; public bool Newcomer; public string Fit() { bool merged = false; bool savesShort = false; bool notesShort = false; bool canBuy = true; bool hintShort = false; bool hint = true; Action[] obj = new Action[7] { delegate { merged = true; }, delegate { canBuy = !Newcomer; }, delegate { hintShort = true; }, delegate { savesShort = true; }, delegate { notesShort = true; }, delegate { canBuy = false; }, delegate { hint = false; } }; string text = Compose(merged, savesShort, notesShort, canBuy, hintShort, hint); Action[] array = obj; foreach (Action action in array) { if (Rows(text) <= 3) { return text; } action(); text = Compose(merged, savesShort, notesShort, canBuy, hintShort, hint); } return Cut(text); } private string Compose(bool merged, bool savesShort, bool notesShort, bool canBuy, bool hintShort, bool hint) { List<string> list = new List<string>(); if (merged) { string text = ((Rows(Gains("upgrade budget")) > 1) ? Gains("budget") : Gains("upgrade budget")); if (text.Length > 0) { list.Add(text); } } else { if (XpSources != null) { list.Add(XpSources); } list.AddRange(Money("upgrade budget")); } IEnumerable<string> collection; if (!notesShort) { IEnumerable<string> notes = Notes; collection = notes; } else { collection = Notes.Select(ShortNote).Distinct(); } list.AddRange(collection); if (Saves != null) { list.Add(savesShort ? SavesShort : Saves); } if (canBuy && CanBuy != null) { list.Add(CanBuy); } if (hint && Hint != null) { list.Add(hintShort ? HintShort : Hint); } return string.Join("\n", list); string Gains(string label) { return string.Join(", ", new string[1] { Xp }.Where((string x) => x != null).Concat(Money(label))); } List<string> Money(string label) { List<string> list2 = new List<string>(); if (Budget > 0) { list2.Add($"+${Budget} {label}"); } if (TeamBudget > 0) { list2.Add($"+${TeamBudget} team budget"); } return list2; } } internal static string ShortNote(string note) { if (note.StartsWith("Team Rebuilt:", StringComparison.Ordinal)) { return "Team build rebuilt"; } if (note.StartsWith("Rebuilt:", StringComparison.Ordinal)) { return "Saved build rebuilt"; } return Cut(note, 1); } internal static string Cut(string text, int rows = 3) { List<string> list = Wrap(text); if (list.Count <= rows) { return text; } List<string> list2 = list.Take(rows).ToList(); string text2 = list2[rows - 1]; list2[rows - 1] = ((text2.Length > 28) ? text2.Substring(0, 28) : text2).TrimEnd(' ', ',', ';', ':') + "..."; return string.Join("\n", list2); } } private static readonly XpSource[] Order = new XpSource[5] { XpSource.Rank, XpSource.Scrap, XpSource.Kill, XpSource.Survival, XpSource.Quota }; private static readonly Dictionary<XpSource, int> xp = new Dictionary<XpSource, int>(); private static readonly List<string> notes = new List<string>(); private static int budget; private static int teamBudget; private static readonly List<(UpgradeType Skill, CauseOfDeath Cause)> saves = new List<(UpgradeType, CauseOfDeath)>(); internal const int TipColumns = 31; internal const int TipRows = 3; public static void Reset() { xp.Clear(); notes.Clear(); budget = 0; teamBudget = 0; saves.Clear(); } public static void AddSave(UpgradeType skill, CauseOfDeath cause) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) saves.Add((skill, cause)); } public static void Add(GainKind kind, int amount, XpSource source, string text) { switch (kind) { case GainKind.Xp: if (source != XpSource.Debug) { xp.TryGetValue(source, out var value); xp[source] = value + amount; if (source == XpSource.Kill) { StatusHud.Flash($"+{amount} XP" + ((text != null) ? (" (" + text + ")") : "")); } } break; case GainKind.Budget: budget += amount; break; case GainKind.TeamBudget: teamBudget += amount; break; case GainKind.Note: if (!string.IsNullOrEmpty(text)) { notes.Add(text); } break; } } public static void OnShipReady() { if (xp.Count != 0 || budget != 0 || teamBudget != 0 || notes.Count != 0 || saves.Count != 0) { if (!Plugin.Cfg.ShowDayReport.Value || (Object)(object)StatApplier.Instance == (Object)null) { Reset(); } else { StatApplier.Instance.ShowDelayed("Day report", TakeText, 5f); } } } internal static string TakeText() { Draft draft = new Draft(); int num = xp.Values.Sum(); if (num > 0) { IEnumerable<string> values = from s in Order.Where(xp.ContainsKey) select $"{Label(s)} {xp[s]}"; draft.Xp = $"+{num} XP"; draft.XpSources = string.Format("+{0} XP ({1})", num, string.Join(", ", values)); } draft.Budget = budget; draft.TeamBudget = teamBudget; draft.Notes.AddRange(notes); if (saves.Count > 0) { draft.Saves = SavesText(withCauses: true); draft.SavesShort = SavesText(withCauses: false); } PlayerControllerB localPlayer = RpgState.LocalPlayer; draft.CanBuy = CanBuyLine(localPlayer); if (draft.CanBuy != null || budget > 0 || teamBudget > 0) { string text = FirstPurchaseCommand(localPlayer); if (text != null) { draft.Newcomer = true; draft.Hint = ((budget > 0) ? "Spend it on the ship: " : "The crew can spend it: ") + text; draft.HintShort = "Spend it: " + text; } else { draft.Hint = (draft.HintShort = Reports.SpendHint()); } } Reset(); return draft.Fit(); } private static string CanBuyLine(PlayerControllerB local) { List<string> list = Reports.Affordable(local, 2, keepSkill: true); if (list.Count == 0) { return null; } List<string> list2 = Reports.Affordable(local, 2, keepSkill: true, withPrice: false); string[] array = new string[3] { "Can buy: " + string.Join(", ", list), "Can buy: " + string.Join(", ", list2), "Can buy: " + list[0] }; foreach (string text in array) { if (Rows(text) == 1) { return text; } } return "Can buy: " + list2[0]; } internal static int Rows(string text, int columns = 31) { return Wrap(text, columns).Count; } internal static List<string> Wrap(string text, int columns = 31) { List<string> list = new List<string>(); if (string.IsNullOrEmpty(text)) { return list; } string[] array = text.Split('\n'); foreach (string obj in array) { string text2 = ""; string[] array2 = obj.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text3 in array2) { if (text2.Length > 0 && text2.Length + 1 + text3.Length <= columns) { text2 = text2 + " " + text3; continue; } if (text2.Length > 0) { list.Add(text2); } string text4 = text3; while (text4.Length > columns) { list.Add(text4.Substring(0, columns)); text4 = text4.Substring(columns); } text2 = text4; } list.Add(text2); } return list; } private static string FirstPurchaseCommand(PlayerControllerB local) { PlayerProgress playerProgress = RpgState.ProgressOf(local); if ((budget <= 0 && teamBudget <= 0) || !Reports.IsNewcomer(playerProgress)) { return null; } RpgSettings settings = RpgState.Settings; PlayerProgress playerProgress2 = settings.Wallet(playerProgress); if (settings.Currency == CurrencyMode.GroupCredits || Builds.MissingSteps(playerProgress2, playerProgress2.LastBuild, settings).Count > 0) { return null; } UpgradeDef upgradeDef = Reports.AffordableDefs(local).FirstOrDefault((UpgradeDef def) => !settings.PaysWithXp(def.Type)); if (upgradeDef == null) { return null; } string text = Reports.MenuKeyName(); string text2 = "rpg buy " + upgradeDef.Id; if (text == null) { return text2; } return "[" + text + "] or " + text2; } private static string SavesText(bool withCauses) { IEnumerable<string> values = saves.Select(((UpgradeType Skill, CauseOfDeath Cause) s) => s.Skill).Distinct().Select(delegate(UpgradeType skill) { List<string> list = (from s in saves where s.Skill == skill select Reports.CauseText(s.Cause)).ToList(); string text = ((list.Count > 1) ? $" {list.Count}x" : ""); return Upgrades.Get(skill).DisplayName + text + (withCauses ? (" (" + string.Join(", ", list.Distinct()) + ")") : ""); }); return "Saved today: " + string.Join(", ", values); } private static string Label(XpSource source) { return source switch { XpSource.Rank => "rank", XpSource.Scrap => "scrap", XpSource.Kill => "kills", XpSource.Survival => "survived", XpSource.Quota => "quota", _ => source.ToString().ToLowerInvariant(), }; } } internal static class SessionLog { public const int TestedGameVersion = 81; public const int MinGameVersion = 80; public const int MaxLines = 200; private const int MaxLineLength = 4000; private const float NoticeDelay = 15f; internal static readonly List<string> lines = new List<string>(); private static readonly object linesLock = new object(); internal static bool warnedGameVersion; internal static bool loggedGameVersion; public static void Attach(ManualLogSource log) { log.LogEvent -= OnLog; log.LogEvent += OnLog; } private static void OnLog(object sender, LogEventArgs e) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) string text = e.Data?.ToString() ?? ""; if (text.Length > 4000) { text = text.Substring(0, 4000) + " [...]"; } string item = string.Format("{0} [{1}] {2}", DateTime.Now.ToString("HH:mm:ss", CultureInfo.InvariantCulture), e.Level, text); lock (linesLock) { lines.Add(item); if (lines.Count > 200) { lines.RemoveRange(0, lines.Count - 200); } } } public static List<string> Lines() { lock (linesLock) { return new List<string>(lines); } } public static void OnSessionStart() { try { Plugin.Log.LogInfo((object)StartLine()); if (!RpgState.IsServer) { return; } foreach (string item in PresetLines()) { Plugin.Log.LogInfo((object)item); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Could not write the session's first log line: {arg}"); } } public static string StartLine() { bool isServer = RpgState.IsServer; int num = RpgState.ConnectedPlayers().Count(); string text = (isServer ? ("rules " + Reports.RulesSummary(RpgState.Settings)) : "rules from the host with its first sync"); string text2 = SlotsText(); return string.Format("LethalRPG {0} {1}, {2}, {3} player{4}, ", "0.10.0+9a70785", isServer ? "host" : "client", Network(), num, (num == 1) ? "" : "s") + ((text2 != null) ? (text2 + ", ") : "") + $"protocol {4}, {text}, game {GameVersionText()}, detected: {ListText(Compat.Detected())}, " + "failed: " + ListText(Plugin.FailedPatches); } public static List<string> PresetLines() { RulesPreset rulesPreset = RulesPresets.Matching(RpgState.Settings); RulesPreset value = Plugin.Cfg.RulesPreset.Value; List<string> list = new List<string> { $"Rules preset: {rulesPreset}" + ((value != rulesPreset) ? $" (RulesPreset = {value}, named from the values)" : "") }; List<string> list2 = Plugin.Cfg.PresetOverrides(); if (list2.Count > 0) { list.Add(string.Format("RulesPreset {0} decides {1}; their own values in the cfg are kept for Custom.", value, string.Join(", ", list2))); } return list; } public static string SlotsText() { int num = RpgState.SlotCount(); bool hasMoreCompany = Compat.HasMoreCompany; if (num != 0 && (num != 4 || hasMoreCompany)) { return $"slots {num}" + (hasMoreCompany ? " (MoreCompany)" : ""); } return null; } private static string ListText(List<string> items) { if (items.Count <= 0) { return "none"; } return string.Join(", ", items); } public static string Network() { if (!((Object)(object)GameNetworkManager.Instance == (Object)null)) { if (!GameNetworkManager.Instance.disableSteam) { return "Steam"; } return "LAN"; } return "unknown network"; } public static string BepInExVersion() { return typeof(Paths).Assembly.GetName().Version.ToString(); } public static int GameVersion() { if (!((Object)(object)GameNetworkManager.Instance != (Object)null)) { return 0; } return GameNetworkManager.Instance.gameVersionNum; } private static bool Plausible(int version) { if (version > 0) { return version < 1000; } return false; } public static string GameVersionText() { int num = GameVersion(); if (num > 0) { if (!Plausible(num)) { return $"v{num} (changed by a mod?)"; } return $"v{num}"; } return "unknown"; } public static string GameVersionNote() { int num = GameVersion(); if (!Plausible(num)) { return null; } if (num < 80) { return $"LethalRPG needs Lethal Company v{80} or newer, this game is v{num}: some skills may not work."; } if (num <= 81) { return null; } return $"This game is v{num}, LethalRPG was tested on v{81}. If something does not work, 'rpg report' writes a bug report."; } public static void CheckGameVersion() { try { ReportGameVersion(); } catch (Exception arg) { Plugin.Log.LogError((object)$"Could not check the game version: {arg}"); } } private static void ReportGameVersion() { string text = GameVersionNote(); if (text == null) { return; } if (!loggedGameVersion) { loggedGameVersion = true; Plugin.Log.LogWarning((object)text); } if (warnedGameVersion) { return; } if ((Object)(object)StatApplier.Instance != (Object)null) { StatApplier.Instance.ShowDelayed("LethalRPG", GameVersionNotice, 15f); return; } string text2 = GameVersionNotice(); if (text2 != null) { RpgNotices.ShowNow("LethalRPG", text2); } } private static string GameVersionNotice() { string text = GameVersionNote(); if (text == null || warnedGameVersion || (Object)(object)HUDManager.Instance == (Object)null) { return null; } warnedGameVersion = true; return text; } public static string Situation() { bool isServer = RpgState.IsServer; int num = RpgState.ConnectedPlayers().Count(); List<string> list = new List<string> { isServer ? "host" : "client", Network(), string.Format("{0} player{1} connected", num, (num == 1) ? "" : "s") }; string text = SlotsText(); if (text != null) { list.Add(text); } list.Add($"{RpgState.ModdedCrew().Count} with their LethalRPG profile"); StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { list.Add("no lobby"); } else { list.Add(instance.inShipPhase ? "in orbit" : (((Object)(object)instance.currentLevel != (Object)null) ? ("on " + instance.currentLevel.PlanetName) : "on a moon")); if (instance.gameStats != null) { list.Add($"day {instance.gameStats.daysSpent}"); } } GameNetworkManager instance2 = GameNetworkManager.Instance; if (isServer && (Object)(object)instance2 != (Object)null && instance2.isHostingGame) { list.Add("save " + instance2.currentSaveFileName); } return string.Join(", ", list); } } internal static class BugReport { internal static Func<string> Folder = () => Paths.BepInExRootPath; internal static Action<string, string> WriteFile = File.WriteAllText; internal static Action<string> CopyToClipboard = delegate(string text) { GUIUtility.systemCopyBuffer = text; }; public static bool Write(out string message) { string text = Reports.Diagnostics(); string name = "LethalRPG-report-" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture) + ".txt"; string text2 = "BepInEx/" + name; bool flag = Try(delegate { WriteFile(Path.Combine(Folder(), name), text); }, "save the bug report"); bool flag2 = Try(delegate { CopyToClipboard(text); }, "copy the bug report to the clipboard"); message = ((flag && flag2) ? ("Bug report saved as " + text2 + " and copied to the clipboard.") : (flag ? ("Bug report saved as " + text2 + ". Copying it to the clipboard failed.") : (flag2 ? "The bug report could not be saved (see the BepInEx log), but it was copied to the clipboard." : "The bug report could not be saved or copied, see the BepInEx log."))); if (flag) { Plugin.Log.LogInfo((object)("Bug report saved as " + text2 + (flag2 ? " and copied to the clipboard" : ""))); } return flag || flag2; } private static bool Try(Action action, string what) { try { action(); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not " + what + ": " + ex.Message)); return false; } } } internal static class Reports { internal sealed class BuyList { public readonly List<string> Entries = new List<string>(); public int More; public string Note; public string MoreText { get { if (More <= 0) { return null; } return $"and {More} more"; } } } public const string BugReportNote = "It holds versions, settings, other mods, errors and LethalRPG's last log lines. Players appear only as P1, P2, ... without names or Steam IDs. Attach the file, or paste the text, when you report a bug."; private static readonly Regex UpgradePath = new Regex("^Upgrades\\[(\\d+)\\]\\.(.+)$"); private static readonly Regex SteamId = new Regex("(?<!\\d)7656119\\d{10}(?!\\d)"); private static readonly Regex UserFolder = new Regex("(?<folder>(?:[A-Za-z]:)?[\\\\/]+(?:Users|home|Documents and Settings)[\\\\/]+)[^\\\\/\\r\\n\"'<>|:*?]+", RegexOptions.IgnoreCase); private static readonly Regex DefaultName = new Regex("^Player( #\\d+)?$"); private static readonly HashSet<string> seenNames = new HashSet<string>(StringComparer.Ordinal); public const int TerminalWidth = 51; internal static Terminal terminal; internal static readonly Dictionary<CauseOfDeath, string> CauseWords = new Dictionary<CauseOfDeath, string> { [(CauseOfDeath)0] = "lethal damage", [(CauseOfDeath)1] = "a blow", [(CauseOfDeath)2] = "a fall", [(CauseOfDeath)3] = "an explosion", [(CauseOfDeath)4] = "strangling", [(CauseOfDeath)5] = "suffocation", [(CauseOfDeath)6] = "a mauling", [(CauseOfDeath)7] = "gunshots", [(CauseOfDeath)8] = "crushing", [(CauseOfDeath)9] = "drowning", [(CauseOfDeath)10] = "lethal damage", [(CauseOfDeath)11] = "electrocution", [(CauseOfDeath)12] = "a kick", [(CauseOfDeath)13] = "burning", [(CauseOfDeath)14] = "a stab", [(CauseOfDeath)15] = "a fan", [(CauseOfDeath)16] = "a crash", [(CauseOfDeath)17] = "snipping", [(CauseOfDeath)18] = "scratching" }; public const string NotEnoughMoney = "not enough money"; public const string NotEnoughXp = "not enough XP"; public const string ProfileOnly = "profile only"; public const string CanBuyNowTitle = "CAN BUY NOW"; public const int CanBuyNowMost = 6; public const string NothingToBuy = "Nothing you can buy right now."; public const string BuyOnShip = "Buying works on the ship."; public const string BackupsTitle = "BACKUPS (made before your profile shrinks)"; public const string RestoreNote = "The profile you replace becomes backup 1. A restored backup is used from the next lobby you join; until then this session is not saved to your profile."; public const int CompactCrewFrom = 5; private const char Shortened = '~'; internal const char KeptSpace = '\u00a0'; internal const int GuideIndent = 3; internal const int ShipLabelWidth = 10; internal const int ShipLineMax = 140; internal const string WaitingForHost = "Waiting for the host's LethalRPG data. Try again in a moment."; internal const string ScopeNoticeHeader = "Progress on this ship"; internal const string FromProfileNote = "Comes from your profile on this ship: it works here, but cannot be learned or reset here."; internal const int SelfTestColumn = 22; internal const int SelfTestWidth = 50; internal const int SelfTestMostDiffs = 6; internal const string SelfTestNote = "Compares every player's LethalRPG with the host's ('rpg selftest')."; internal const string SelfTestClientNote = "Checks this PC; only the host can compare every player ('rpg selftest')."; private const string SelfTestCompared = "Compared: version, state, settings, data,\nlevels, slots, HP, speeds and patches."; private static readonly List<UpgradeType> RootPages = (from u in Upgrades.All.Where((UpgradeDef u) => u.Category == UpgradeCategory.Body).Concat(Upgrades.All.Where((UpgradeDef u) => u.Category == UpgradeCategory.Tools)) select u.Type).ToList(); internal const string TreeOffText = "No skill tree on this ship: the host has RequirePrerequisites off, so every skill can be learned without other upgrades."; internal const string TreeLegend = "* owned ! can learn now (+X) also needs skill X"; internal const string TreeLevelLegend = "2/4 = your level; 3 Skill = Skill needs level 3"; internal const string TreeNoLevelLegend = "- = no level needed (that upgrade is off)"; internal const string TreePageHint = "Skill tree: rpg tree"; internal static string HostWithoutRpg => "The host has not answered for " + Kept($"{30} s") + ": it probably has no LethalRPG, so LethalRPG does nothing in this lobby."; public static string RulesSummary(RpgSettings settings) { string text = ((settings.Currency == CurrencyMode.SurplusShare) ? $"SurplusShare {settings.SurplusSharePercent}% {settings.Split}" : ("GroupCredits" + ((!settings.SplitUpgradePrices) ? "" : ((settings.PriceShareCap > 0) ? $" SplitUpgradePrices (PriceShareCap {settings.PriceShareCap})" : " SplitUpgradePrices")))); return $"{text}, {settings.Ownership}, skills {settings.UniqueCurrency}, {settings.Difficulty}/{settings.Balancing}" + ((settings.ProgressScope != ProgressScope.Profile) ? (", progress per save" + ((settings.SaveScopedSkills != SaveScopedSkills.Both) ? $" ({settings.SaveScopedSkills})" : "")) : "") + ((settings.OverlapPolicy == OverlapPolicy.PreferOtherMod) ? ", PreferOtherMod" : "") + (settings.DebugCommands ? ", DebugCommands" : ""); } public static string BugReportPage(bool ok, string message) { return "BUG REPORT\n\n" + (ok ? ">> " : "!! ") + message + "\n\nIt holds versions, settings, other mods, errors and LethalRPG's last log lines. Players appear only as P1, P2, ... without names or Steam IDs. Attach the file, or paste the text, when you report a bug.\n"; } public static string Diagnostics() { RpgSettings settings = RpgState.Settings; bool host = RpgState.IsServer; StringBuilder sb = new StringBuilder(); sb.AppendLine("LETHALRPG BUG REPORT"); sb.AppendLine("Written " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + ". Players appear as P1, P2, ... (their slot, P1 is the host) with a short hash of their identity, never by name or Steam ID."); sb.AppendLine(); sb.AppendLine("VERSIONS"); sb.AppendLine(string.Format("LethalRPG {0}, protocol {1}", "0.10.0+9a70785", 4)); sb.AppendLine($"Lethal Company {SessionLog.GameVersionText()} (LethalRPG needs v{80}+, tested on v{81})"); sb.AppendLine("BepInEx " + SessionLog.BepInExVersion()); if (!host) { sb.AppendLine("Host: " + RpgNetwork.HostVersionText()); } sb.AppendLine(); sb.AppendLine("SESSION"); AppendPart(sb, delegate { sb.AppendLine(SessionLog.Situation()); sb.AppendLine("Rules: " + RulesSummary(settings) + ((settings.TeamMode != (settings.Ownership == UpgradeOwnership.Team)) ? (" (upgrades are still " + (settings.TeamMode ? "Team" : "Individual") + " until the ship is started)") : "")); sb.AppendLine($"Rules preset: {RulesPresets.Matching(settings)} (from the values)"); sb.AppendLine(ProgressSessionLine(settings, RpgState.Data)); sb.AppendLine("Profile: " + ProfileState().Replace("\n", "; ")); if (host && (Object)(object)GameNetworkManager.Instance != (Object)null && GameNetworkManager.Instance.isHostingGame) { sb.AppendLine("Save: " + TerminalCommands.SaveBackupLine()); } }); sb.AppendLine(); AppendPart(sb, delegate { AppendSettings(sb, settings, host); }); sb.AppendLine(); AppendPart(sb, delegate { AppendProblems(sb, settings, host); }); sb.AppendLine(); AppendPart(sb, delegate { AppendPlayers(sb, host); }); sb.AppendLine(); AppendPart(sb, delegate { SelfTestReport(host).ForEach(delegate(string line) { sb.AppendLine(line); }); }); sb.AppendLine(); AppendPart(sb, delegate { List<string> list2 = Compat.Plugins(); sb.AppendLine($"PLUGINS ({list2.Count})"); foreach (string item in list2) { sb.AppendLine(item); } }); sb.AppendLine(); List<string> list = SessionLog.Lines(); sb.AppendLine($"LOG (LethalRPG's last {list.Count} lines)"); foreach (string item2 in list) { sb.AppendLine(item2); } return Anonymize(sb.ToString()); } private static void AppendPart(StringBuilder sb, Action part) { try { part(); } catch (Exception ex) { sb.AppendLine("(this part failed: " + ex.GetType().Name + ": " + ex.Message + ")"); } } private static void AppendSettings(StringBuilder sb, RpgSettings settings, bool host) { sb.AppendLine(host ? "SETTINGS IN EFFECT (this host's)" : "SETTINGS IN EFFECT (the host's)"); foreach (KeyValuePair<string, string> item in from v in SettingValues(settings) where !v.Key.Contains(".") select v) { sb.AppendLine(item.Key + " = " + item.Value); } string text = Compat.OverlapLine(settings); if (text != null) { sb.AppendLine(text); } sb.AppendLine(); sb.AppendLine("CONFIG OF THIS PC (entries that differ from their defaults)"); ConfigFile file = ((ConfigEntryBase)Plugin.Cfg.Currency).ConfigFile; List<ConfigEntryBase> list = (from key in file.Keys select file[key] into entry where !object.Equals(entry.BoxedValue, entry.DefaultValue) select entry).OrderBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.Ordinal).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.Ordinal).ToList(); foreach (ConfigEntryBase item2 in list) { sb.AppendLine("[" + item2.Definition.Section + "] " + item2.Definition.Key + " = " + ConfigText(item2.BoxedValue) + " (default " + ConfigText(item2.DefaultValue) + ")" + (Plugin.Cfg.DecidedByPreset(item2) ? " (RulesPreset decides)" : "")); } if (list.Count == 0) { sb.AppendLine("none"); } if (host) { return; } sb.AppendLine(); sb.AppendLine("THIS PC'S OWN RULES WHERE THEY DIFFER FROM THE HOST'S (the host's apply)"); if (RpgState.SyncedSettings == null) { sb.AppendLine("no sync from the host yet"); return; } Dictionary<string, string> dictionary = SettingValues(RpgState.SyncedSettings).ToDictionary((KeyValuePair<string, string> v) => v.Key, (KeyValuePair<string, string> v) => v.Value); int num = 0; foreach (KeyValuePair<string, string> item3 in from v in SettingValues(Plugin.Cfg.ToSettings()) where v.Key != "InventoryBlockedBy" && !v.Key.EndsWith(".DisabledBy", StringComparison.Ordinal) select v) { if (!dictionary.TryGetValue(item3.Key, out var value) || value != item3.Value) { sb.AppendLine(item3.Key + ": host " + (value ?? "-") + ", this PC " + item3.Value); num++; } } if (num == 0) { sb.AppendLine("none"); } } private static string ConfigText(object value) { return Convert.ToString(value, CultureInfo.InvariantCulture); } internal static List<KeyValuePair<string, string>> SettingValues(RpgSettings settings) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002a: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Invalid comparison between Unknown and I4 JsonSerializer val = JsonSerializer.Create(new JsonSerializerSettings { ContractResolver = RpgJson.Wire.ContractResolver, Converters = { (JsonConverter)new StringEnumConverter() } }); List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>(); foreach (JValue item in ((JContainer)JObject.FromObject((object)settings, val)).Descendants().OfType<JValue>()) { string text = ((JToken)item).Path; Match match = UpgradePath.Match(text); if (match.Success) { int num = int.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture); text = ((num < Upgrades.All.Length) ? Upgrades.All[num].Id : ("upgrade" + num)) + "." + match.Groups[2].Value; } list.Add(new KeyValuePair<string, string>(text, ((int)((JToken)item).Type == 10) ? "none" : ConfigText(item.Value))); } return list; } internal static List<string> DegradedSkillLines() { return (from entry in Plugin.DegradedSkills group entry by entry.Key.Skill into skill orderby skill.Key select Upgrades.Get(skill.Key).DisplayName + " may not work fully: " + string.Join("; ", from entry in skill.OrderBy<KeyValuePair<(UpgradeType, string), string>, string>((KeyValuePair<(UpgradeType Skill, string Where), string> entry) => entry.Key.Where, StringComparer.Ordinal) select entry.Value)).ToList(); } internal static List<string> OtherModLines() { SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.Ordinal); foreach (var key in Plugin.DegradedSkills.Keys) { if (!Plugin.FailedPatches.Contains(key.Where)) { sortedSet.Add(key.Where); } } foreach (List<string> value in Plugin.FailedPatchMethods.Values) { sortedSet.UnionWith(value); } return sortedSet.Select(delegate(string method) { List<string> list = Compat.OtherOwners(method); return (list == null || list.Count <= 0) ? ("No other mod patches " + method) : ("Other mods patching " + method + ": " + string.Join(", ", list)); }).ToList(); } private static void AppendProblems(StringBuilder sb, RpgSettings settings, bool host) { sb.AppendLine("PROBLEMS"); List<string> list = new List<string>(); if (Plugin.FailedPatches.Count > 0) { list.Add("Patch groups that failed to load: " + string.Join(", ", Plugin.FailedPatches)); } list.AddRange(DegradedSkillLines()); list.AddRange(OtherModLines()); list.AddRange(Guard.Report()); string text = SessionLog.GameVersionNote(); if (text != null) { list.Add(text); } if (settings.InventoryBlockedBy != null) { string text2 = ((!host) ? "on the host's or a player's PC" : ((Compat.HostInventoryBlocker() != null) ? "on the host" : "on a client's PC, see PLAYERS")); list.Add("Inventory upgrade off for everyone: " + settings.InventoryBlockedBy + " manages the slots (" + text2 + ")."); } if (!host && Compat.InventoryConflict != null) { list.Add("On this PC " + Compat.InventoryConflict + " manages the inventory slots."); } string text3 = LocalProfile.Problem(); if (text3 != null) { list.Add("Profile: " + text3); } string text4 = (host ? RpgServer.SaveProblem() : null); if (text4 != null) { list.Add("Upgrades in the save: " + text4); } string text5 = (host ? RpgNetwork.SyncSizeProblem() : null); if (text5 != null) { list.Add(text5); } string text6 = RpgNetwork.GzipProblem(); if (text6 != null) { list.Add(text6); } string text7 = (host ? null : RpgNetwork.VersionNote()); if (text7 != null) { list.Add(text7); } foreach (var item3 in (List<(ulong, string)>)(host ? ((IList)RpgNetwork.Undelivered()) : ((IList)new List<(ulong, string)>()))) { ulong item = item3.Item1; string item2 = item3.Item2; PlayerControllerB val = RpgState.PlayerForClient(item); list.Add("States do not get through to " + (((Object)(object)val != (Object)null) ? RpgState.SlotName(val) : $"client {item}") + ": " + item2 + "; the host refuses its requests until it takes one."); } foreach (string item4 in list.DefaultIfEmpty("none found")) { sb.AppendLine(item4); } } private static void AppendPlayers(StringBuilder sb, bool host) { sb.AppendLine(host ? "PLAYERS (as the host sees them)" : "PLAYERS (as this client sees them)"); PlayerControllerB localPlayer = RpgState.LocalPlayer; foreach (PlayerControllerB item in from p in RpgState.ConnectedPlayers() orderby p.playerClientId select p) { string text = RpgState.KeyOf(item); PlayerProgress value; PlayerProgress progress = ((text != null && RpgState.Data.Players.TryGetValue(text, out value)) ? value : null); string text2 = (host ? RpgServer.VersionText(item) : (((Object)(object)item == (Object)(object)localPlayer) ? "LethalRPG 0.10.0+9a70785" : ((RpgState.ClientIdOf(item) == 0) ? ("host, " + RpgNetwork.HostVersionText()) : "version known to the host"))); object obj; if (!host) { obj = (((Object)(object)item == (Object)(object)localPlayer) ? new List<string> { RpgNetwork.OwnStateText() } : new List<string>()); } else { ulong? num = RpgState.ClientIdOf(item); if (num.HasValue) { ulong valueOrDefault = num.GetValueOrDefault(); obj = RpgNetwork.DeliveryParts(valueOrDefault); } else { obj = new List<string>(); } } List<string> source = (List<string>)obj; sb.AppendLine(string.Concat(RpgState.SlotName(item), " key ", (text == null) ? "none yet" : RpgState.ShortKey(text), ((Object)(object)item == (Object)(object)localPlayer) ? " (this PC)" : "", " ", text2, ", ", ProfileText(item, progress), string.Concat(source.Select((string s) => ", " + s)))); List<string> list = ItemSlotsParts(item); if (list.Count > 0) { sb.AppendLine(" " + string.Join(" ", list)); } } sb.AppendLine(string.Format("{0}: {1}", host ? "Records in this save" : "Records sent by the host", RpgState.Data.Players.Count)); } internal static void NoteNames() { foreach (PlayerControllerB item in RpgState.ConnectedPlayers()) { if ((Object)(object)item != (Object)null && !string.IsNullOrWhiteSpace(item.playerUsername)) { seenNames.Add(item.playerUsername); } } } internal static string Anonymize(string text) { text = SteamId.Replace(text, "<steam id>"); text = UserFolder.Replace(text, "${folder}<user>"); List<string> list = KnownNames(); if (list.Count == 0) { return text; } string text2 = string.Join("|", list.Select(Regex.Escape)); return Regex.Replace(text, "(?<![\\p{L}\\p{N}])(?:" + text2 + ")(?![\\p{L}\\p{N}])", "<name>"); } private static List<string> KnownNames() { List<string> list = new List<string>(); StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && instance.allPlayerScripts != null) { list.AddRange(from p in instance.allPlayerScripts where (Object)(object)p != (Object)null select p.playerUsername); } IEnumerable<string> collection; if (!RpgState.IsServer) { IEnumerable<string> enumerable = seenNames; collection = enumerable; } else { collection = RpgState.Data.Players.Values.Select((PlayerProgress p) => p.Name); } list.AddRange(collection); if ((Object)(object)GameNetworkManager.Instance != (Object)null) { list.Add(GameNetworkManager.Instance.username); } try { list.Add(Environment.UserName); } catch (Exception) { } return (from n in (from n in list where !string.IsNullOrWhiteSpace(n) select n.Trim() into n where n.Length >= 3 && !DefaultName.IsMatch(n) select n).Distinct() orderby n.Length descending select n).ToList(); } public static int GroupCredits() { if ((Object)(object)terminal == (Object)null) { terminal = Object.FindObjectOfType<Terminal>(); } if (!((Object)(object)terminal != (Object)null)) { return 0; } return terminal.groupCredits; } public static string EnemyName(EnemyAI enemy) { ScanNodeProperties componentInChildren = ((Component)enemy).GetComponentInChildren<ScanNodeProperties>(true); if ((Object)(object)componentInChildren != (Object)null && !string.IsNullOrWhiteSpace(componentInChildren.headerText)) { return componentInChildren.headerText; } string text = (((Object)(object)enemy.enemyType != (Object)null) ? enemy.enemyType.enemyName : null); if (!string.IsNullOrWhiteSpace(text)) { return text; } return "monster"; } public unsafe static string CauseText(CauseOfDeath cause) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CauseWords.TryGetValue(cause, out var value)) { return ((object)(*(CauseOfDeath*)(&cause))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant().Replace('_', ' '); } return value; } public static int Money(PlayerProgress progress) { if (RpgState.Settings.Currency != CurrencyMode.GroupCredits) { return RpgState.Settings.Wallet(progress).Budget; } return GroupCredits(); } public static string MoneyLabel(PlayerProgress progress) { if (RpgState.Settings.Currency != CurrencyMode.GroupCredits) { if (!RpgState.Settings.TeamMode) { return $"Budget ${progress.Budget}"; } return $"Team budget ${RpgState.Data.Team.Budget}"; } return $"Credits ${GroupCredits()}{SplitNote()}"; } public unsafe static string KeyName(Key key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 0) { return null; } try { Keyboard current = Keyboard.current; KeyControl val = ((current != null) ? current[key] : null); if (val != null && !string.IsNullOrWhiteSpace(((InputControl)val).displayName)) { return ((InputControl)val).displayName; } } catch (ArgumentException) { } return ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); } public static string MenuKeyName() { return MenuInput.KeyName(); } public static string SpendHint() { string text = MenuKeyName(); if (text == null) { return "Spend at the terminal: RPG"; } return "Spend at [" + text + "] or terminal: RPG"; } public static string SplitNote() { int num = RpgState.PriceShareCount(); if (num <= 1) { return ""; } return $" (upgrades 1/{num} price)"; } public static string PriceDetail(UpgradeType type, int level) { int num = RpgState.PriceShares(type); if (num <= 1) { return PriceText(type, level); } return $"${RpgState.Settings.PriceFor(type, level, num)} (1/{num} of ${RpgState.Settings.CostForLevel(type, level)})"; } public static string ParamText(UpgradeDef def) { return string.Join(", ", def.Params.Select((SkillParam p) => p.Label + ": " + FormatParam(p, RpgState.Param(def.Type, p.Key)))); } private static string FormatParam(SkillParam param, float value) { if (param.IsInt) { if (!(param.Key == "MaxTwoHandedItems") || !(value <= 0f)) { return Mathf.RoundToInt(value).ToString(); } return "unlimited"; } return value.ToString("0.##", CultureInfo.InvariantCulture); } public static string BlockedReason(PlayerControllerB player, UpgradeType type, bool orbitRule = true) { RpgSettings settings = RpgState.Settings; PlayerProgress playerProgress = RpgState.ProgressOf(player); UpgradeDef upgradeDef = Upgrades.Get(type); string text = RpgState.DisabledReason(type); if (text != null) { return text; } int num = settings.LevelOf(playerProgress, type); if (num >= settings.For(type).MaxLevel) { if (!upgradeDef.Unique) { return "max level"; } return "owned"; } if (ProgressScopes.FromProfile(RpgState.Data, upgradeDef)) { return "profile only"; } string text2 = NeedsText(settings, playerProgress, type); if (text2 != null) { return text2; } if (orbitRule && upgradeDef.Unique && !settings.PaysWithXp(type) && !RpgServer.GameSavesNow) { return "in orbit only"; } if (settings.PaysWithXp(type)) { if (playerProgress.Xp < settings.XpPrice(type)) { return "not enough XP"; } return null; } if (Money(playerProgress) < RpgState.Price(type, num)) { return "not enough money"; } return null; } public static string ShortfallText(PlayerControllerB player, UpgradeType type) { string text = BlockedReason(player, type); if (text != "not enough money" && text != "not enough XP") { return null; } RpgSettings settings = RpgState.Settings; PlayerProgress playerProgress = RpgState.ProgressOf(player); if (!(text == "not enough XP")) { return "$" + (RpgState.Price(type, settings.LevelOf(playerProgress, type)) - Money(playerProgress)); } return $"{settings.XpPrice(type) - playerProgress.Xp} XP"; } public static string NeedsText(RpgSettings settings, PlayerProgress progress, UpgradeType type) { (UpgradeType, int)? tuple = settings.MissingPrerequisite(type, progress); if (tuple.HasValue) { return "needs " + Upgrades.Describe(tuple.Value.Item1, tuple.Value.Item2); } return null; } public static string LimitedSkillNote(UpgradeType type, bool inMenu = false) { if (!Compat.IsLimited(type)) { return null; } return "May not work with your mods (" + (inMenu ? "RULES" : "rpg info") + ")"; } public static string OffNote(UpgradeType type) { string text = RpgState.LeftTo(type); if (text == null) { return null; } string text2 = Compat.Counterpart(type, text); return ((text2 != null) ? ("Off on this ship: the host leaves it to " + text + "' " + text2 + ", which does the same. ") : ("Off on this ship: the host leaves it to " + text + ", which has the same upgrade. ")) + "Levels you bought are kept and work again with OverlapPolicy Stack."; } public static string CappedLevelNote(PlayerProgress progress, UpgradeType type) { RpgSettings settings = RpgState.Settings; if (progress == null || Upgrades.Get(type).Unique) { return null; } int num = settings.LevelOf(progress, type); int maxLevel = settings.For(type).MaxLevel; if (num <= maxLevel) { return null; } if (settings.Balancing != Balancing.Standard) { return $"Level {num}, effect capped at {maxLevel} by {settings.Balancing}"; } return $"Level {num}, effect capped at max level {maxLevel}"; } public static List<UpgradeDef> PageUpgrades(UpgradeCategory category) { return Upgrades.OnPage(category, RpgState.Settings); } public static string PriceText(UpgradeType type, int level) { RpgSettings settings = RpgState.Settings; if (!settings.PaysWithXp(type)) { return "$" + RpgState.Price(type, level); } return $"{settings.XpPrice(type)} XP"; } public static List<UpgradeDef> AffordableDefs(PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return new List<UpgradeDef>(); } RpgSettings settings = RpgState.Settings; PlayerProgress progress = RpgState.ProgressOf(player); return (from def in Upgrades.All where BlockedReason(player, def.Type) == null orderby SortCost(settings, progress, def) select def).ToList(); } private static int SortCost(RpgSettings settings, PlayerProgress progress, UpgradeDef def) { if (!settings.PaysWithXp(def.Type)) { return RpgState.Price(def.Type, settings.LevelOf(progress, def.Type)); } return settings.XpPrice(def.Type) * 5; } public static List<string> Affordable(PlayerControllerB player, int max, bool keepSkill = false, bool withPrice = true) { List<UpgradeDef> source = AffordableDefs(player); List<UpgradeDef> list = source.Take(max).ToList(); if (keepSkill && max > 1 && list.Count == max && list.All((UpgradeDef def) => !def.Unique)) { UpgradeDef upgradeDef = source.Skip(max).FirstOrDefault((UpgradeDef def) => def.Unique); if (upgradeDef != null) { list[max - 1] = upgradeDef; } } RpgSettings settings = RpgState.Settings; PlayerProgress progress = RpgState.ProgressOf(player); return list.Select(delegate(UpgradeDef def) { int num = settings.LevelOf(progress, def.Type); string text = Upgrades.Describe(def.Type, num + 1); return (!withPrice) ? text : (text + " (" + PriceText(def.Type, num) + ")"); }).ToList(); } public static BuyList CanBuyNow(PlayerControllerB player, bool onShip) { BuyList buyList = new BuyList(); if (!onShip) { buyList.Note = "Buying works on the ship."; return buyList; } if (RpgNetwork.RequestRefusal() != null) { buyList.Note = "Nothing you can buy right now."; return buyList; } List<UpgradeDef> list = AffordableDefs(player); if (list.Count == 0) { buyList.Note = "Nothing you can buy right now."; return buyList; } RpgSettings settings = RpgState.Settings; PlayerProgress personal = RpgState.ProgressOf(player); foreach (UpgradeDef item in list.Take(6)) { int num = settings.LevelOf(personal, item.Type); buyList.Entries.Add(Upgrades.Describe(item.Type, num + 1) + " (" + PriceText(item.Type, num) + ")"); } buyList.More = list.Count - buyList.Entries.Count; return buyList; } public static string CanBuyNowPage(PlayerControllerB player, bool onShip) { BuyList buyList = CanBuyNow(player, onShip); StringBuilder sb = new StringBuilder(); sb.AppendLine("CAN BUY NOW"); MoneyLines(RpgState.ProgressOf(player)).ForEach(delegate(string line) { sb.AppendLine(line); }); sb.AppendLine(); if (buyList.Note != null) { sb.AppendLine(buyList.Note); if (buyList.Note == "Nothing you can buy right now.") { sb.AppendLine(); NextStep(player).Lines("NEXT STEP: ").ForEach(delegate(string line) { sb.AppendLine(line); }); } return sb.ToString(); } foreach (string entry in buyList.Entries) { Wrap("* " + entry, 2).ForEach(delegate(string line) { sb.AppendLine(line); }); } if (buyList.MoreText != null) { sb.AppendLine(" " + buyList.MoreText); } sb.AppendLine(); sb.AppendLine("Buy: rpg buy (name) [n|max] Details: rpg (name)"); return sb.ToString(); } internal static List<string> MoneyLines(PlayerProgress progress) { string text = MoneyLabel(progress); string text2 = XpLabel(progress); if (text.Length + 3 + text2.Length > 51) { return new List<string> { text, text2 }; } return new List<string> { text + " " + text2 }; } public static string Stats(PlayerControllerB player) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(StatsSummary(player, withLists: false)); stringBuilder.AppendLine(); stringBuilder.Append(UpgradeTotals(player)); AppendSkillLists(stringBuilder, player); AppendPresets(stringBuilder); stringBuilder.AppendLine(); stringBuilder.AppendLine("Your profile and its backups: rpg profile"); return stringBuilder.ToString(); } public static string Profile() { StringBuilder sb = new StringBuilder(); sb.AppendLine("YOUR PROFILE (XP and skills, on this PC)"); sb.AppendLine(); sb.AppendLine(ProfileState()); string text = ProfileScopeNote(RpgState.Data); if (text != null) { Wrap(text, 0).ForEach(delegate(string line) { sb.AppendLine(line); }); } sb.AppendLine(); sb.AppendLine("BACKUPS (made before your profile shrinks)"); for (int num = 1; num <= 3; num++) { sb.Append(BackupText(num)); } sb.AppendLine(); sb.AppendLine("Restore one: rpg profile restore (n)"); sb.AppendLine(RestoreNoteFor(RpgState.Data)); return sb.ToString(); } public static string ProfileState() { string text = LocalProfile.Problem(); if (text == null) { PlayerProfile saved = LocalProfile.Saved; text = ((saved == null) ? "No profile saved yet." : ("Saved: " + ProfileSummary(saved))); } string testProfile = LocalProfile.TestProfile; if (testProfile != null) { return text + "\nTest profile '" + testProfile + "' (start argument)"; } return text; } public static string ProfileSummary(PlayerProfile profile) { int num = profile.CountSkills(); return string.Format("{0} XP ({1} spent), {2} skill{3}", profile.Xp, profile.SpentXp, num, (num == 1) ? "" : "s"); } public static string BackupText(int number) { ProfileBackup profileBackup = LocalProfile.Backups[number - 1]; if (profileBackup == null) { return $"{number} none\n"; } string text = string.Format("{0} {1}", number, (profileBackup.Record != null) ? profileBackup.Record.LocalTime() : "?"); string text2 = ((profileBackup.Profile == null) ? "cannot be read" : (profileBackup.Usable ? ProfileSummary(profileBackup.Profile) : "from a newer LethalRPG")); StringBuilder stringBuilder = new StringBuilder(); if (text.Length + 2 + text2.Length <= 51) { stringBuilder.AppendLine(text + " " + text2); } else { stringBuilder.AppendLine(text); stringBuilder.AppendLine(" " + text2); } if (profileBackup.Record != null && !string.IsNullOrEmpty(profileBackup.Record.Reason)) { stringBuilder.AppendLine(" " + profileBackup.Record.Reason); } return stringBuilder.ToString(); } private static void AppendPresets(StringBuilder sb) { RpgSettings settings = RpgState.Settings; List<string> list = new List<string>(); if (settings.Difficulty != Difficulty.Normal) { list.Add($"Difficulty: {settings.Difficulty}"); } if (settings.Balancing != Balancing.Standard) { list.Add($"Balancing: {settings.Balancing}"); } if (list.Count > 0) { sb.AppendLine(); sb.AppendLine(string.Join(" ", list)); } } public static string StatsSummary(PlayerControllerB player, bool withLists) { PlayerProgress progress = RpgState.ProgressOf(player); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("YOUR STATS"); stringBuilder.AppendLine(); int num = Mathf.RoundToInt(Mathf.Clamp(player.carryWeight - 1f, 0f, 100f) * 105f); int num2 = Mathf.RoundToInt(Mathf.Clamp(RpgState.EffectiveCarryWeight(player) - 1f, 0f, 100f) * 105f); object arg = ((!player.isPlayerDead) ? player.health : 0); object arg2 = RpgState.MaxHealth(player); GrabbableObject[] itemSlots = player.ItemSlots; stringBuilder.AppendLine($"Health {arg}/{arg2} Slots {((itemSlots != null) ? itemSlots.Length : 4)}"); stringBuilder.AppendLine((num > 0 && num2 != num) ? $"Load {num} lb (feels like {num2} lb)" : $"Load {num} lb"); stringBuilder.AppendLine(FormattableString.Invariant($"Sprint about {player.sprintTime * 0.9f:0.#} s without load")); string text = MoneyLabel(progress); string text2 = XpStats(progress); if (text.Length + 3 + text2.Length <= 51) { stringBuilder.AppendLine(text + " " + text2); } else { stringBuilder.AppendLine(text); stringBuilder.AppendLine(text2); } if (RpgState.Has(player, UpgradeType.SecondWind) && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController) { stringBuilder.AppendLine($"Second Wind: {LocalSkills.SecondWindLeft}/{LocalSkills.SecondWindChargesPerDay} left today"); } if (withLists) { stringBuilder.AppendLine(); AppendSkillLists(stringBuilder, player); AppendPresets(stringBuilder); } return stringBuilder.ToString(); } public static string UpgradeTotals(PlayerControllerB player) { RpgSettings settings = RpgState.Settings; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(settings.TeamMode ? "UPGRADES (shared by the crew)" : "UPGRADES"); List<string[]> list = new List<string[]>(); foreach (UpgradeDef item in Upgrades.All.Where((UpgradeDef u) => !u.Unique)) { int num = RpgState.Level(player, item.Type); if (num > 0) { list.Add(new string[3] { item.DisplayName, $"Lv {num}", item.FormatTotal(settings.EffectPerLevel(item.Type), num) }); } } if (list.Count == 0) { stringBuilder.AppendLine(" none yet"); } foreach (string item2 in Table(" ", list)) { stringBuilder.AppendLine(item2); } return stringBuilder.ToString(); } private static void AppendSkillLists(StringBuilder sb, PlayerControllerB player) { AppendWrapped(sb, "SKILLS: ", from u in Upgrades.All where u.Category == UpgradeCategory.Unique && RpgState.Has(player, u.Type) select u.DisplayName); AppendWrapped(sb, "ULTIMATES: ", from u in Upgrades.All where u.IsUltimate && RpgState.Has(player, u.Type) select u.DisplayName); } public static string Crew() { StringBuilder stringBuilder = new StringBuilder(); List<PlayerControllerB> list = CrewPlayers(); bool flag = list.Count >= 5; stringBuilder.AppendLine(flag ? $"CREW ({list.Count} players)" : "CREW"); if (RpgState.Settings.TeamMode) { stringBuilder.AppendLine(); stringBuilder.Append(TeamUpgrades()); } if (flag) { string header; List<(PlayerControllerB, string)> list2 = CrewList(list, out header); stringBuilder.AppendLine(); stringBuilder.AppendLine(header); foreach (var item in list2) { stringBuilder.AppendLine(item.Item2); } stringBuilder.AppendLine(); stringBuilder.AppendLine($"Details: rpg crew (slot), e.g. rpg crew {list2[1].Item1.playerClientId + 1}"); } else { foreach (PlayerControllerB item2 in list) { stringBuilder.AppendLine(); stringBuilder.Append(CrewMember(item2)); } } string text = OutsideCrew(list); if (text != null) { stringBuilder.AppendLine(); stringBuilder.Append(text); } return stringBuilder.ToString(); } public static List<PlayerControllerB> CrewPlayers() { return RpgState.ModdedCrew(); } public static List<(PlayerControllerB Player, string Line)> CrewList(List<PlayerControllerB> crew, out string header) { RpgSettings settings = RpgState.Settings; List<PlayerControllerB> players = crew.OrderBy((PlayerControllerB p) => p.playerClientId).ToList(); List<(string Title, string[] Values)> columns = new List<(string, string[])>(); if (!settings.TeamMode && settings.Currency != CurrencyMode.GroupCredits) { Column("BUDGET", (PlayerControllerB p) => "$" + RpgState.ProgressOf(p).Budget); } Column("XP", (PlayerControllerB p) => RpgState.ProgressOf(p).Xp.ToString()); if (!settings.TeamMode) { Column("LEVELS", (PlayerControllerB p) => Upgrades.All.Where((UpgradeDef u) => !u.Unique).Sum((UpgradeDef u) => RpgState.Level(p, u.Type)).ToString()); } Column("SKILLS", (PlayerControllerB p) => Upgrades.All.Count((UpgradeDef u) => u.Unique && RpgState.Has(p, u.Type)).ToString()); int[] widths = columns.Select(((string Title, string[] Values) c) => c.Values.Select((string v) => v.Length).Append(c.Title.Length).Max()).ToArray(); int num = 47 - widths.Sum((int w) => 2 + w); int nameWidth = Mathf.Max(6, Mathf.Min(num, players.Select((PlayerControllerB p) => (p.playerUsername ?? "").Length).Append("NAME".Length).Max())); header = Line("", "NAME", (int c) => columns[c].Title); return players.Select((PlayerControllerB p, int i) => (p: p, Line(RpgState.SlotName(p), ShortName(p.playerUsername, nameWidth), (int c) => columns[c].Values[i]))).ToList(); void Column(string title, Func<PlayerControllerB, string> value) { columns.Add((title, players.Select(value).ToArray())); } string Line(string slot, string name, Func<int, string> cell) { return string.Concat(slot.PadRight(4), name.PadRight(nameWidth), string.Concat(widths.Select((int w, int c) => " " + cell(c).PadLeft(w)))).TrimEnd(); } } public static string ShortName(string name, int width) { if (name == null) { name = ""; } if (name.Length <= width) { return name; } int num = Mathf.Max(0, width - 1); if (num > 0 && char.IsHighSurrogate(name[num - 1])) { num--; } return name.Substring(0, num) + "~"; } public static string CrewSlot(PlayerControllerB player) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(RpgState.SlotName(player) + " " + player.playerUsername); stringBuilder.AppendLine(" " + MemberNumbers(player).TrimStart()); AppendMemberLists(stringBuilder, player, " "); return stringBuilder.ToString(); } public static string OutsideCrew(List<PlayerControllerB> crew) { List<string> list = (from p in RpgState.ConnectedPlayers() where RpgState.KeyOf(p) != null && !crew.Contains(p) select p.playerUsername).ToList(); if (list.Count == 0) { return null; } StringBuilder stringBuilder = new StringBuilder(); AppendWrapped(stringBuilder, "Without LethalRPG, another version or still joining: ", list); return stringBuilder.ToString(); } public static string TeamUpgrades() { StringBuilder stringBuilder = new StringBuilder(); PlayerProgress team = RpgState.Data.Team; int num = Upgrades.All.Where((UpgradeDef u) => !u.Unique).Sum((Func<UpgradeDef, int>)Level); string arg = ((RpgState.Settings.Currency == CurrencyMode.GroupCredits) ? "" : $" ${team.Budget}"); stringBuilder.AppendLine($"TEAM UPGRADES{arg} {num} levels"); AppendWrapped(stringBuilder, " ", from u in Upgrades.All where !u.Unique && Level(u) > 0 select $"{u.DisplayName} {Level(u)}"); return stringBuilder.ToString(); int Level(UpgradeDef u) { return Mathf.Clamp(team.GetLevel(u.Type), 0, RpgState.Settings.For(u.Type).MaxLevel); } } public static string CrewMember(PlayerControllerB player, string indent = " ") { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(player.playerUsername + MemberNumbers(player)); AppendMemberLists(stringBuilder, player, indent); return stringBuilder.ToString(); } private static string MemberNumbers(PlayerControllerB player) { PlayerProgress playerProgress = RpgState.ProgressOf(player); if (RpgState.Settings.TeamMode) { return $" {playerProgress.Xp} XP"; } int num = Upgrades.All.Where((UpgradeDef u) => !u.Unique).Sum((UpgradeDef u) => RpgState.Level(player, u.Type)); string arg = ((RpgState.Settings.Currency == CurrencyMode.GroupCredits) ? "" : $" ${playerProgress.Budget}"); return $"{arg} {playerProgress.Xp} XP {num} levels"; } private static void AppendMemberLists(StringBuilder sb, PlayerControllerB player, string indent) { if (!RpgState.Settings.TeamMode) { AppendWrapped(sb, indent, from u in Upgrades.All where !u.Unique && RpgState.Level(player, u.Type) > 0 select $"{u.DisplayName} {RpgState.Level(player, u.Type)}"); } AppendWrapped(sb, indent + "Skills: ", from u in Upgrades.All where u.Category == UpgradeCategory.Unique && RpgState.Has(player, u.Type) select u.DisplayName); AppendWrapped(sb, indent + "Ult: ", from u in Upgrades.All where u.IsUltimate && RpgState.Has(player, u.Type) select u.DisplayName); } internal static string ProfileText(PlayerControllerB player, PlayerProgress progress) { if (progress == null || !progress.ProfileLoaded) { ulong? num = RpgState.ClientIdOf(player); if (num.HasValue) { ulong valueOrDefault = num.GetValueOrDefault(); if (RpgServer.Incompatible(valueOrDefault, out var _)) { return "profile ignored"; } } if (progress != null) { return "no profile yet"; } return "no record"; } return "profile loaded"; } internal static List<string> ItemSlotsParts(PlayerControllerB player) { if (player.ItemSlots == null) { return new List<string>(); } int num = player.ItemSlots.Length; StatApplier.SlotBook value; int num2 = (StatApplier.slotBooks.TryGetValue(player, out value) ? value.Added : 0); int num3 = 3 * Compat.UtilityBelts(player); int num4 = num - 4 - num2 - num3; if (num2 == 0 && num3 == 0 && num4 == 0) { return new List<string> { $"Slots of {RpgState.SlotName(player)}: {num}" }; } List<string> list = new List<string> { $"Slots of {RpgState.SlotName(player)}: {num} = {4}" }; if (num2 != 0) { list.Add($"+ {num2} Inventory"); } if (num3 != 0) { list.Add($"+ {num3} Utility Belt"); } if (num4 != 0) { list.Add((num4 > 0) ? $"+ {num4} other mods" : $"- {-num4} missing"); } return list; } public static string CrewState() { RpgSettings settings = RpgState.Settings; PlayerProgress team = RpgState.Data.Team; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("CREW STATE (debug, host)"); stringBuilder.AppendLine(settings.TeamMode ? $"Team upgrades, team budget ${team.Budget}, spent ${team.SpentMoney}" : ((settings.Currency == CurrencyMode.SurplusShare) ? $"Personal upgrades, quota share {settings.Split}" : "Personal upgrades")); stringBuilder.AppendLine((settings.Currency == CurrencyMode.GroupCredits) ? $"Paid with group credits: ${GroupCredits()}" : "Paid with the budgets"); int num = 0; foreach (PlayerControllerB item in from p in RpgState.ConnectedPlayers() orderby p.playerClientId select p) { string text = RpgState.KeyOf(item); stringBuilder.AppendLine(); stringBuilder.AppendLine(string.Format("{0} client {1} key {2}", RpgState.SlotName(item), item.actualClientId, (text == null) ? "none yet" : RpgState.ShortKey(text))); PlayerProgress value; PlayerProgress playerProgress = ((text != null && RpgState.Data.Players.TryGetValue(text, out value)) ? value : null); stringBuilder.AppendLine(" " + RpgServer.VersionText(item) + ", " + ProfileText(item, playerProgress)); AppendWrapped(stringBuilder, " ", RpgNetwork.DeliveryParts(item.actualClientId, reasons: false)); if (playerProgress != null) { num++; stringBuilder.AppendLine($" budget ${playerProgress.Budget} XP {playerProgress.Xp} scrap ${playerProgress.Contribution}"); stringBuilder.AppendLine($" spent ${playerProgress.SpentMoney} and {playerProgress.SpentXp} XP" + ((playerProgress.PendingXp > 0) ? $", {playerProgress.PendingXp} XP pending" : "")); } AppendWrapped(stringBuilder, " ", ItemSlotsParts(item), ""); } stringBuilder.AppendLine(); stringBuilder.AppendLine($"Records in this save: {RpgState.Data.Players.Count} ({RpgState.Data.Players.Count - num} not here)"); return stringBuilder.ToString(); } public static string Build(PlayerControllerB player, bool withCommands = true) { RpgSettings settings = RpgState.Settings; PlayerProgress playerProgress = settings.Wallet(RpgState.ProgressOf(player)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(settings.TeamMode ? "SAVED TEAM BUILD" : "SAVED BUILD"); stringBuilder.AppendLine(); if (playerProgress.LastBuild == null || playerProgress.LastBuild.Count == 0) { stringBuilder.AppendLine("No build saved yet. Your money upgrades are saved automatically when a run ends."); } else { AppendWrapped(stringBuilder, "", Builds.Totals(playerProgress.LastBuild, settings).Split(new string[1] { ", " }, StringSplitOptions.None)); List<UpgradeType> list = Builds.MissingSteps(playerProgress, playerProgress.LastBuild, settings); stringBuilder.AppendLine((list.Count > 0) ? $"Missing: {list.Count} levels for ${Builds.CostOf(settings, playerProgress, list, RpgState.PriceShareCount())}" : ((Builds.MissingSteps(playerProgress, playerProgress.LastBuild).Count > 0) ? "You have all of it that this ship offers." : "You have all of it.")); } stringBuilder.AppendLine(); stringBuilder.AppendLine("Auto rebuy: " + (playerProgress.AutoRebuy ? "ON" : "off") + ((settings.Currency == CurrencyMode.GroupCredits) ? " (only with personal budgets)" : "")); if (!withCommands) { return stringBuilder.ToString(); } stringBuilder.AppendLine(); stringBuilder.AppendLine("rpg rebuy buy the missing levels now"); stringBuilder.AppendLine("rpg rebuy auto toggle auto rebuy"); stringBuilder.AppendLine("rpg build save save your current upgrades"); return stringBuilder.ToString(); } public static List<string> Table(string prefix, IList<string[]> rows, int width = 51) { List<string> list = new List<string>(); if (rows.Count == 0) { return list; } int num = rows[0].Length; int[] array = new int[num]; foreach (string[]