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 Ror2Meeeee v0.12.1
Ror2Meeeee.Core.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Microsoft.CodeAnalysis; using Ror2Meeeee.Core.Eligibility; using Ror2Meeeee.Core.Pipeline; [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("Ror2Meeeee.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+baf584b99ffa41c39e917e5364107fb04fc3b69c")] [assembly: AssemblyProduct("Ror2Meeeee.Core")] [assembly: AssemblyTitle("Ror2Meeeee.Core")] [assembly: AssemblyVersion("1.0.0.0")] [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 Ror2Meeeee { public static class ModInfo { public const string Guid = "com.sawcunha.ror2meeeee"; public const string Name = "Ror2Meeeee"; public const string Version = "0.12.1"; public const string ExpectedGameVersion = "1.5.0#1224"; } } namespace Ror2Meeeee.Core.Tempest { public enum OverloadState { Normal, Reduced, Recovering } public sealed class OverloadGovernor { private float _above; private float _below; public float EnterMs { get; private set; } = 33f; public float EnterSeconds { get; private set; } = 10f; public float ExitMs { get; private set; } = 25f; public float ExitSeconds { get; private set; } = 20f; public float RecoverySeconds { get; private set; } = 30f; public OverloadState State { get; private set; } public float Level { get; private set; } = 1f; public void Configure(float enterMs, float enterSeconds, float exitMs, float exitSeconds, float recoverySeconds) { EnterMs = enterMs; EnterSeconds = Math.Max(0f, enterSeconds); ExitMs = ((exitMs < enterMs) ? exitMs : (enterMs * 0.75f)); ExitSeconds = Math.Max(0f, exitSeconds); RecoverySeconds = Math.Max(0.001f, recoverySeconds); } public void Reset() { State = OverloadState.Normal; Level = 1f; _above = (_below = 0f); } public bool Update(float frameMs, float dt) { OverloadState state = State; _above = ((frameMs > EnterMs) ? (_above + dt) : 0f); _below = ((frameMs < ExitMs) ? (_below + dt) : 0f); switch (State) { case OverloadState.Normal: if (_above >= EnterSeconds) { Enter(); } break; case OverloadState.Reduced: if (_below >= ExitSeconds) { State = OverloadState.Recovering; Level = 0f; } break; case OverloadState.Recovering: if (_above >= EnterSeconds) { Enter(); break; } Level = Math.Min(1f, Level + dt / RecoverySeconds); if (Level >= 1f) { State = OverloadState.Normal; } break; } return State != state; } private void Enter() { State = OverloadState.Reduced; Level = 0f; _above = (_below = 0f); } } public readonly struct TempestCurve { public float PerMinute { get; } public float PerStage { get; } public float Max { get; } public TempestCurve(float perMinute, float perStage, float max) { PerMinute = perMinute; PerStage = perStage; Max = max; } public float Evaluate(float minutes, int stagesCleared) { double val = 1.0 + (double)PerMinute * (double)Math.Max(0f, minutes) + (double)PerStage * (double)Math.Max(0, stagesCleared); return (float)Math.Min(Math.Max(1f, Max), Math.Max(1.0, val)); } } public static class TempestRules { public const int MinCapacity = 40; public const int MaxReductionPercent = 99; public const int MaxSteps = 20; public static readonly int[] DefaultSteps = new int[6] { 20, 40, 55, 70, 90, 99 }; public static float Clamp(float value, float defaultValue, float min, float max, out bool corrected) { float num = ((float.IsNaN(value) || float.IsInfinity(value)) ? defaultValue : Math.Min(max, Math.Max(min, value))); corrected = num != value; return num; } public static int Clamp(int value, int min, int max, out bool corrected) { int num = Math.Min(max, Math.Max(min, value)); corrected = num != value; return num; } public static int[] ParseSteps(string text, out bool corrected) { corrected = false; if (string.IsNullOrWhiteSpace(text)) { return Array.Empty<int>(); } string[] array = text.Split(','); List<int> list = new List<int>(array.Length); int val = 0; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i].Trim(); if (text2.Length == 0) { corrected = true; continue; } if (!int.TryParse(text2, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { corrected = true; return (int[])DefaultSteps.Clone(); } int num = Math.Min(99, Math.Max(val, result)); if (num != result) { corrected = true; } val = num; if (list.Count == 20) { corrected = true; break; } list.Add(num); } return list.ToArray(); } public static float Reduction(int stagesCleared, int[] steps) { if (stagesCleared <= 0 || steps == null || steps.Length == 0) { return 0f; } return (float)steps[Math.Min(stagesCleared, steps.Length) - 1] / 100f; } public static float Reduction(int stagesCleared, int[] steps, float multiplier, float exponent) { float num = Reduction(stagesCleared, steps); if (stagesCleared <= 0 || multiplier <= 1f || exponent <= 0f || float.IsNaN(multiplier) || float.IsNaN(exponent)) { return num; } double num2 = (1.0 - (double)num) / (double)MultiplierFactor(multiplier, exponent); return (float)Math.Min(0.99, 1.0 - num2); } public static float MultiplierFactor(float multiplier, float exponent) { if (!(multiplier <= 1f) && !(exponent <= 0f) && !float.IsNaN(multiplier) && !float.IsNaN(exponent)) { return (float)Math.Pow(multiplier, exponent); } return 1f; } public static int ExtraLives(bool boss, bool elite, int normalLives, int eliteLives) { if (!boss) { return Math.Max(0, elite ? eliteLives : normalLives); } return 0; } public static int HealthStacks(float reduction) { return (int)Math.Round(Math.Min(0.99, Math.Max(0.0, reduction)) * 100.0, MidpointRounding.AwayFromZero); } public static int BoostStacks(float multiplier) { if (!float.IsNaN(multiplier) && !(multiplier <= 1f)) { return (int)Math.Min(2147483647.0, Math.Round(((double)multiplier - 1.0) * 10.0, MidpointRounding.AwayFromZero)); } return 0; } public static float EliteBias(float eliteMultiplier) { if (!float.IsNaN(eliteMultiplier) && !(eliteMultiplier <= 1f)) { return 1f / eliteMultiplier; } return 1f; } public static int Capacity(int players, int baseCapacity, int perExtraPlayer, int maxCapacity) { int num = Math.Max(40, maxCapacity); long val = baseCapacity + (long)Math.Max(0, perExtraPlayer) * (long)(Math.Max(1, players) - 1); return (int)Math.Min(num, Math.Max(40L, val)); } public static float Gate(float previous, int capacity, int alive, int headroom, float rampSeconds, float dt) { int num = capacity - Math.Max(1, headroom) - alive; if (num <= 0) { return 0f; } float val = ((rampSeconds > 0f) ? (previous + dt / rampSeconds) : 1f); return Math.Min(1f, Math.Min(val, (float)num / (float)Math.Max(1, headroom))); } public static float Pressure(float stageSeconds, float startSeconds, float perMinute, float max) { if (stageSeconds <= startSeconds || perMinute <= 0f || max <= 0f) { return 0f; } return Math.Min(max, (stageSeconds - startSeconds) / 60f * perMinute); } public static float Credit(float perSecond, float difficultyCoefficient, int players, float spawn, float gate, float perf) { if (perSecond <= 0f || spawn <= 1f || gate <= 0f || perf <= 0f) { return 0f; } return perSecond * (1f + 0.4f * Math.Max(0f, difficultyCoefficient)) * (0.5f + 0.5f * (float)Math.Max(1, players)) * (spawn - 1f) * Math.Min(1f, gate) * Math.Min(1f, perf); } public static bool IsSwarm(float stageSeconds, float swarmSeconds, float heavySeconds) { if (swarmSeconds <= 0f) { return false; } float num = swarmSeconds + Math.Max(0f, heavySeconds); if (stageSeconds < 0f) { stageSeconds = 0f; } return stageSeconds % num < swarmSeconds; } public static int SanitizeFinalStage(int finalStage, out bool corrected) { int num = Math.Max(5, (int)Math.Round((double)finalStage / 5.0, MidpointRounding.AwayFromZero) * 5); corrected = num != finalStage; return num; } public static bool FinalLocked(int stagesCleared, int finalStage) { return stagesCleared + 1 < finalStage; } } } namespace Ror2Meeeee.Core.Tax { public static class TaxRelief { public const int WhitePercent = 20; public const int GreenPercent = 30; public const int RedPercent = 50; public const int WhiteGoldPercent = 10; public const int GreenGoldPercent = 20; public const int RedGoldPercent = 30; public static float Multiplier(bool white, bool green, bool red) { int num = (white ? 20 : 0) + (green ? 30 : 0) + (red ? 50 : 0); return (float)(100 - num) / 100f; } public static uint Gold(uint amount, bool white, bool green, bool red) { int num = (white ? 10 : 0) + (green ? 20 : 0) + (red ? 30 : 0); if (num == 0 || amount == 0) { return amount; } ulong num2 = (ulong)(amount * (100 + num) + 50) / 100uL; if (num2 <= uint.MaxValue) { return (uint)num2; } return uint.MaxValue; } } } namespace Ror2Meeeee.Core.Stats { public static class Bastion { public const float ShieldPerStack = 0.4f; public const float RegenDelaySeconds = 2f; public static float ExtraShield(float maxHealth, int stacks) { if (stacks > 0 && !(maxHealth <= 0f)) { return maxHealth * 0.4f * (float)stacks; } return 0f; } public static bool ShouldForceRegen(float timeSinceLastHit, float shield, float maxShield) { if (maxShield > 0f && shield < maxShield) { return timeSinceLastHit >= 2f; } return false; } } public static class HeavyHeart { public const float HealthPerStack = 0.5f; public const float DamageTakenPerStack = 0.3f; public const double MaxMultiplier = 1E+30; public static float HealthMultiplier(int stacks) { return Compound(1.5, stacks); } public static float DamageTakenMultiplier(int stacks) { return Compound(1.300000011920929, stacks); } private static float Compound(double factor, int stacks) { if (stacks <= 0) { return 1f; } double num = Math.Pow(factor, stacks); return (float)((num < 1E+30) ? num : 1E+30); } } public static class MultiShot { public static int ExtraShots(int stacks, int maxExtra) { if (stacks <= 0 || maxExtra <= 0) { return 0; } if (stacks >= maxExtra) { return maxExtra; } return stacks; } public static float FanAngle(int index, float step) { if (index < 0) { return 0f; } int num = index / 2 + 1; return ((index % 2 == 0) ? 1f : (-1f)) * (float)num * step; } public static int Budget(int wanted, int usedThisFrame, int maxPerFrame) { int num = maxPerFrame - usedThisFrame; if (wanted <= 0 || num <= 0) { return 0; } if (wanted >= num) { return num; } return wanted; } } public static class PortalBattery { public const float ChargePerStack = 0.1f; public static float ChargeRateMultiplier(int teamStacks) { if (teamStacks > 0) { return 1f + 0.1f * (float)teamStacks; } return 1f; } } public static class SelfHeal { public const float SelfishFlat = 5f; public const float SelfishPerStack = 0.0001f; public const float VoidFlat = 15f; public const float VoidPerStack = 0.005f; public const float LevelScaling = 0.2f; public static float PerSecond(int stacks, float flat, float perExtraStack, float fullHealth, float level) { if (stacks <= 0) { return 0f; } float num = ((level < 1f) ? 1f : level); return flat * (1f + 0.2f * (num - 1f)) + perExtraStack * (float)(stacks - 1) * fullHealth; } public static float AmountPerTick(int selfish, int voidStacks, float fullHealth, float level, float interval) { if (interval <= 0f) { return 0f; } return (PerSecond(selfish, 5f, 0.0001f, fullHealth, level) + PerSecond(voidStacks, 15f, 0.005f, fullHealth, level)) * interval; } } public static class ShortNumber { private static readonly CultureInfo Pt = CultureInfo.GetCultureInfo("pt-BR"); private static readonly CultureInfo En = CultureInfo.InvariantCulture; private static readonly (double Div, string Pt, string En)[] Steps = new(double, string, string)[4] { (1000000000000.0, " tri", "T"), (1000000000.0, " bi", "B"), (1000000.0, " mi", "M"), (1000.0, " mil", "K") }; public static string Format(double value, bool english = false) { CultureInfo cultureInfo = (english ? En : Pt); double num = ((value < 0.0) ? (0.0 - value) : value); (double, string, string)[] steps = Steps; for (int i = 0; i < steps.Length; i++) { var (num2, text, text2) = steps[i]; if (num >= num2) { return (value / num2).ToString("0.#", cultureInfo) + (english ? text2 : text); } } return value.ToString("0", cultureInfo); } } public static class SpeedToDamage { public const float FirstStackRatio = 1f; public const float ExtraStackRatio = 0.5f; public static float Ratio(int stacks) { if (stacks > 0) { return 1f + 0.5f * (float)(stacks - 1); } return 0f; } public static bool Convert(float moveSpeed, float neutralSpeed, float damage, int stacks, out float newSpeed, out float newDamage) { newSpeed = moveSpeed; newDamage = damage; if (stacks <= 0 || !(neutralSpeed > 0f) || !(moveSpeed > neutralSpeed) || float.IsInfinity(moveSpeed) || float.IsNaN(damage)) { return false; } float num = moveSpeed / neutralSpeed - 1f; newSpeed = neutralSpeed; newDamage = damage * (1f + num * Ratio(stacks)); return true; } } public static class StatPool { public const float MaxCombined = 1E+09f; public static float ClampScale(float maxHealth, float maxShield) { float num = maxHealth + maxShield; if (!(num > 1E+09f) || !(num > 0f)) { return 1f; } return 1E+09f / num; } public static float Adjust(float current, float previousMax, float newMax) { float num = newMax - previousMax; float num2 = ((num > 0f) ? (current + num) : current); if (!(num2 < newMax)) { return newMax; } return num2; } } } namespace Ror2Meeeee.Core.Spend { public readonly struct SpendRow { public int Id { get; } public string Name { get; } public int Purchases { get; } public long Gold { get; } public SpendRow(int id, string name, int purchases, long gold) { Id = id; Name = name; Purchases = purchases; Gold = gold; } } public sealed class SpendLedger { private sealed class Entry { public string Name; public int Purchases; public long Gold; } private readonly Dictionary<int, Entry> _byId = new Dictionary<int, Entry>(); public int Players => _byId.Count; public bool Knows(int id) { return _byId.ContainsKey(id); } public void Add(int id, Func<string> name, long gold) { if (!_byId.TryGetValue(id, out var value)) { value = new Entry { Name = (name() ?? ("#" + id.ToString(CultureInfo.InvariantCulture))) }; _byId[id] = value; } value.Purchases++; if (gold > 0) { value.Gold = ((long.MaxValue - value.Gold < gold) ? long.MaxValue : (value.Gold + gold)); } } public void Clear() { _byId.Clear(); } public SpendRow[] Snapshot() { SpendRow[] array = new SpendRow[_byId.Count]; int num = 0; foreach (KeyValuePair<int, Entry> item in _byId) { array[num++] = new SpendRow(item.Key, item.Value.Name, item.Value.Purchases, item.Value.Gold); } Array.Sort(array, (SpendRow a, SpendRow b) => b.Gold.CompareTo(a.Gold)); return array; } public static string Format(SpendRow[] rows) { if (rows.Length == 0) { return "Nenhuma compra registrada nesta run."; } StringBuilder stringBuilder = new StringBuilder("Jogador | Compras | Ouro gasto"); long num = 0L; for (int i = 0; i < rows.Length; i++) { SpendRow spendRow = rows[i]; stringBuilder.Append('\n').Append(spendRow.Name).Append(" | ") .Append(spendRow.Purchases) .Append(" | ") .Append(spendRow.Gold); num += spendRow.Gold; } stringBuilder.Append("\nTotal | | ").Append(num); return stringBuilder.ToString(); } } } namespace Ror2Meeeee.Core.RustyNail { public static class RustyNailRules { public const float ChanceBase = 2f; public const float ChancePerStack = 0.1f; public const float VoidChancePerStack = 0.5f; public const float NailBase = 0.1f; public const float NailPerStack = 0.001f; public const float VoidNailPerStack = 0.005f; public const float BleedDuration = 3f; public const float MarkDuration = 3f; public const float DetonationCoefficient = 2.5f; public const float BurstBase = 1.5f; public const float BurstPerStack = 0.5f; public const float BurstRadius = 12f; public const int MaxActiveMarks = 200; public static float ChancePercent(int stacks, float perStack) { if (stacks <= 0) { return 0f; } float num = 2f + perStack * (float)(stacks - 1); if (!(num < 100f)) { return 100f; } return num; } public static float NailCoefficient(int stacks, float perStack) { if (stacks > 0) { return 0.1f + perStack * (float)(stacks - 1); } return 0f; } public static float BurstCoefficient(int stacks) { if (stacks > 0) { return 1.5f + 0.5f * (float)(stacks - 1); } return 0f; } public static bool CanSpread(int generation, int maxChain) { return generation < maxChain; } } } namespace Ror2Meeeee.Core.Progression { public readonly struct LadderRules { public float RaiseAt { get; } public float Step { get; } public float MaxMultiplier { get; } public LadderRules(float raiseAt, float step, float maxMultiplier) { RaiseAt = raiseAt; Step = step; MaxMultiplier = maxMultiplier; } } public static class ProgressionLadder { public const string SummaryPt = "<color=#e5c07b>Ror2Meeeee</color> {0} em {2} min | nota {3}/100\nvelocidade {4} · sobrevivência {5} · dano sofrido {6} · abates {7}\n{8} abates, {9} mortes, {10} vidas de dano sofrido\nDiretor {11}: nível {13} -> {14} (orçamento de spawn x{15} na próxima run)"; public const string SummaryEn = "<color=#e5c07b>Ror2Meeeee</color> {1} in {2} min | score {3}/100\nspeed {4} · survival {5} · damage taken {6} · kills {7}\n{8} kills, {9} deaths, {10} health bars of damage taken\nDirector {12}: level {13} -> {14} (spawn budget x{15} next run)"; public static int Next(int level, float score, bool won, LadderRules r) { level = Math.Max(0, level); int val = ((!won) ? (level - 1) : ((!float.IsNaN(score) && score >= r.RaiseAt) ? (level + 1) : level)); return Math.Max(0, Math.Min(val, MaxLevel(r))); } public static int MaxLevel(LadderRules r) { if (!ValidStep(r.Step) || !(r.MaxMultiplier > 1f) || float.IsInfinity(r.MaxMultiplier)) { return 0; } return (int)Math.Min(10000.0, Math.Ceiling(((double)r.MaxMultiplier - 1.0) / (double)r.Step - 1E-06)); } public static float Multiplier(int level, LadderRules r) { if (level <= 0 || !ValidStep(r.Step) || !(r.MaxMultiplier > 1f)) { return 1f; } return (float)Math.Min(r.MaxMultiplier, 1.0 + (double)level * (double)r.Step); } private static bool ValidStep(float step) { if (!float.IsNaN(step) && !float.IsInfinity(step)) { return step > 0f; } return false; } public static string Serialize(int level, int runs) { return "level=" + Math.Max(0, level).ToString(CultureInfo.InvariantCulture) + "\nruns=" + Math.Max(0, runs).ToString(CultureInfo.InvariantCulture) + "\n"; } public static void Parse(string text, out int level, out int runs) { level = 0; runs = 0; if (string.IsNullOrEmpty(text)) { return; } string[] array = text.Split('\n'); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); int num = text2.IndexOf('='); if (num <= 0 || !int.TryParse(text2.Substring(num + 1).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result < 0) { continue; } string text3 = text2.Substring(0, num).Trim(); if (!(text3 == "level")) { if (text3 == "runs") { runs = result; } } else { level = result; } } } public static string[] SummaryArgs(RunStats s, RunScoreResult score, int oldLevel, int newLevel, float newMultiplier) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; return new string[16] { s.Won ? "vitória" : "derrota", s.Won ? "victory" : "defeat", (s.Seconds / 60.0).ToString("F1", invariantCulture), (score.Total * 100f).ToString("F0", invariantCulture), Pct(score.Speed), Pct(score.Survival), Pct(score.Damage), Pct(score.Kills), s.Kills.ToString(invariantCulture), s.Deaths.ToString(invariantCulture), s.HealthBarsLost.ToString("F1", invariantCulture), (newLevel > oldLevel) ? "sobe" : ((newLevel < oldLevel) ? "desce" : "mantém"), (newLevel > oldLevel) ? "goes up" : ((newLevel < oldLevel) ? "goes down" : "holds"), oldLevel.ToString(invariantCulture), newLevel.ToString(invariantCulture), newMultiplier.ToString("F2", invariantCulture) }; } public static string Summary(RunStats s, RunScoreResult score, int oldLevel, int newLevel, float newMultiplier, bool english = false) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; string format = (english ? "<color=#e5c07b>Ror2Meeeee</color> {1} in {2} min | score {3}/100\nspeed {4} · survival {5} · damage taken {6} · kills {7}\n{8} kills, {9} deaths, {10} health bars of damage taken\nDirector {12}: level {13} -> {14} (spawn budget x{15} next run)" : "<color=#e5c07b>Ror2Meeeee</color> {0} em {2} min | nota {3}/100\nvelocidade {4} · sobrevivência {5} · dano sofrido {6} · abates {7}\n{8} abates, {9} mortes, {10} vidas de dano sofrido\nDiretor {11}: nível {13} -> {14} (orçamento de spawn x{15} na próxima run)"); object[] args = SummaryArgs(s, score, oldLevel, newLevel, newMultiplier); return string.Format(invariantCulture, format, args); } private static string Pct(float v) { return (v * 100f).ToString("F0", CultureInfo.InvariantCulture); } } public readonly struct ScorePars { public float ChargeSeconds { get; } public float DeathsPerPlayer { get; } public float HealthBarsPerPlayerMinute { get; } public float KillsPerMinute { get; } public ScorePars(float chargeSeconds, float deathsPerPlayer, float healthBarsPerPlayerMinute, float killsPerMinute) { ChargeSeconds = chargeSeconds; DeathsPerPlayer = deathsPerPlayer; HealthBarsPerPlayerMinute = healthBarsPerPlayerMinute; KillsPerMinute = killsPerMinute; } } public readonly struct RunScoreResult { public float Speed { get; } public float Survival { get; } public float Damage { get; } public float Kills { get; } public float Total { get; } public RunScoreResult(float speed, float survival, float damage, float kills) { Speed = speed; Survival = survival; Damage = damage; Kills = kills; Total = (speed + survival + damage + kills) / 4f; } } public static class RunScore { public const float Neutral = 0.5f; public static RunScoreResult Compute(RunStats s, ScorePars p) { int num = Math.Max(1, s.Players); double num2 = s.Seconds / 60.0; float speed = ((s.ChargedStages > 0) ? Lower(s.ChargeSeconds / (double)s.ChargedStages, p.ChargeSeconds) : 0.5f); float survival = Lower((double)s.Deaths / (double)num, p.DeathsPerPlayer); float damage = ((num2 > 0.0) ? Lower(s.HealthBarsLost / (double)num / num2, p.HealthBarsPerPlayerMinute) : 0.5f); float kills = ((num2 > 0.0) ? Higher((double)s.Kills / num2, p.KillsPerMinute) : 0.5f); return new RunScoreResult(speed, survival, damage, kills); } internal static float Lower(double value, float par) { if (!Valid(par) || double.IsNaN(value)) { return 0.5f; } return (float)((double)par / ((double)par + Math.Max(0.0, value))); } internal static float Higher(double value, float par) { if (!Valid(par) || double.IsNaN(value)) { return 0.5f; } double num = Math.Max(0.0, value); return (float)(num / (num + (double)par)); } private static bool Valid(float par) { if (!float.IsNaN(par) && !float.IsInfinity(par)) { return par > 0f; } return false; } } public readonly struct RunStats { public int Players { get; } public double Seconds { get; } public int ChargedStages { get; } public double ChargeSeconds { get; } public int Deaths { get; } public int Kills { get; } public double HealthBarsLost { get; } public bool Won { get; } public RunStats(int players, double seconds, int chargedStages, double chargeSeconds, int deaths, int kills, double healthBarsLost, bool won) { Players = players; Seconds = seconds; ChargedStages = chargedStages; ChargeSeconds = chargeSeconds; Deaths = deaths; Kills = kills; HealthBarsLost = healthBarsLost; Won = won; } } } namespace Ror2Meeeee.Core.Pipeline { public readonly struct PickupContext { public ItemKind Kind { get; } public int Count { get; } public int CurrentStack { get; } public bool PlayerAlive { get; } public bool PlayerConnected { get; } public bool CapExempt { get; } public PickupContext(ItemKind kind, int count, int currentStack, bool playerAlive, bool playerConnected, bool capExempt) { Kind = kind; Count = count; CurrentStack = currentStack; PlayerAlive = playerAlive; PlayerConnected = playerConnected; CapExempt = capExempt; } } public readonly struct MultiplierRules { public const int DefaultMultiplier = 10; public int Multiplier { get; } public bool IncludeLunar { get; } public bool IncludeVoid { get; } public int StackCap { get; } public MultiplierRules(int multiplier, bool includeLunar, bool includeVoid, int stackCap) { Multiplier = ((multiplier <= 0) ? 10 : multiplier); IncludeLunar = includeLunar; IncludeVoid = includeVoid; StackCap = ((stackCap >= 0) ? stackCap : 0); } } public static class MultiplierPipeline { public static bool AtHardCap(int currentStack, MultiplierRules rules) { if (rules.StackCap > 0) { return currentStack >= rules.StackCap; } return false; } public static int Resolve(PickupContext ctx, MultiplierRules rules) { if (!ctx.PlayerAlive || !ctx.PlayerConnected) { return 0; } if (ctx.Count <= 0 || !EligibilityTable.IsEligible(ctx.Kind, rules)) { return 0; } long num = (long)ctx.Count * (long)rules.Multiplier; if (num > int.MaxValue) { num = 2147483647L; } long val = num - ctx.Count; if (rules.StackCap > 0 && !ctx.CapExempt) { long val2 = rules.StackCap - ((long)ctx.CurrentStack + (long)ctx.Count); val = Math.Min(val, Math.Max(0L, val2)); } long val3 = int.MaxValue - ((long)ctx.CurrentStack + (long)ctx.Count); return (int)Math.Max(0L, Math.Min(val, val3)); } } public readonly struct Recipient { public int CurrentStack { get; } public bool Alive { get; } public bool Connected { get; } public Recipient(int currentStack, bool alive, bool connected) { CurrentStack = currentStack; Alive = alive; Connected = connected; } } public static class SharingPipeline { public static int[] Resolve(PickupContext ctx, MultiplierRules rules, bool enabled, bool fromSharing, IReadOnlyList<Recipient> others) { int[] array = new int[others.Count]; if (!enabled || fromSharing || ctx.Count <= 0 || !EligibilityTable.IsShareable(ctx.Kind)) { return array; } for (int i = 0; i < others.Count; i++) { Recipient recipient = others[i]; if (recipient.Alive && recipient.Connected && !MultiplierPipeline.AtHardCap(recipient.CurrentStack, rules)) { int num = MultiplierPipeline.Resolve(new PickupContext(ctx.Kind, ctx.Count, recipient.CurrentStack, recipient.Alive, recipient.Connected, ctx.CapExempt), rules); long num2 = (long)ctx.Count + (long)num; array[i] = (int)((num2 > int.MaxValue) ? int.MaxValue : num2); } } return array; } } } namespace Ror2Meeeee.Core.Measurement { public static class FrameStats { public static void Compute(float[] samples, int count, float[] scratch, out float mean, out float p95) { if (count <= 0) { mean = 0f; p95 = 0f; return; } double num = 0.0; for (int i = 0; i < count; i++) { num += (double)samples[i]; } mean = (float)(num / (double)count); Array.Copy(samples, scratch, count); Array.Sort(scratch, 0, count); int num2 = (int)Math.Ceiling(0.95 * (double)count); p95 = scratch[num2 - 1]; } } } namespace Ror2Meeeee.Core.Limits { public static class ChanceAggregate { public static float Factor(int stack, int capped, float chancePerStack) { if (capped <= 0 || stack <= capped || chancePerStack <= 0f) { return 1f; } float num = Math.Min(100f, chancePerStack * (float)stack); float num2 = Math.Min(100f, chancePerStack * (float)capped); return num / num2; } } public struct BudgetWindow { public float Start; public int Count; public float PendingDamage; } public static class ProjectileBudget { public static bool Decide(ref BudgetWindow w, float now, int maxPerSecond, float damage, out float damageToFire) { if (now - w.Start >= 1f || now < w.Start) { w.Start = now; w.Count = 0; } if (maxPerSecond <= 0 || w.Count < maxPerSecond) { w.Count++; damageToFire = damage + w.PendingDamage; w.PendingDamage = 0f; return true; } w.PendingDamage += damage; damageToFire = 0f; return false; } } public enum StackMode { Off, Clamp, Aggregate } public interface IStackPolicy { int Limit { get; } int Apply(int stack); } public static class StackPolicy { private sealed class OffPolicy : IStackPolicy { public int Limit => int.MaxValue; public int Apply(int stack) { return stack; } } private sealed class ClampPolicy : IStackPolicy { private readonly int _limit; public int Limit => _limit; public ClampPolicy(int limit) { _limit = limit; } public int Apply(int stack) { if (stack >= 0) { if (stack <= _limit) { return stack; } return _limit; } return 0; } } public static readonly IStackPolicy Off = new OffPolicy(); public static IStackPolicy Clamp(int limit) { return new ClampPolicy(Math.Max(1, limit)); } public static IStackPolicy Create(StackMode mode, int limit) { if (mode != StackMode.Off) { return Clamp(limit); } return Off; } } } namespace Ror2Meeeee.Core.Helluva { public static class DropRules { public static int ClampCount(int requested, int owned, int max) { if (owned <= 0 || max <= 0) { return 0; } return Math.Min(Math.Max(requested, 1), Math.Min(owned, max)); } } public static class HelluvaRules { public static float GrimoireCredit(float baseCredit, float difficultyCoefficient) { if (float.IsNaN(baseCredit) || baseCredit <= 0f || float.IsNaN(difficultyCoefficient)) { return 0f; } return (float)Math.Min((double)baseCredit * (double)Math.Max(1f, difficultyCoefficient), 10000000.0); } public static float GrimoireCreditGuarded(float baseCredit, float difficultyCoefficient, float maxPerUse, int monstersAlive, int maxMonsters) { if (maxMonsters > 0 && monstersAlive >= maxMonsters) { return 0f; } float num = GrimoireCredit(baseCredit, difficultyCoefficient); if (!(maxPerUse > 0f)) { return num; } return Math.Min(num, maxPerUse); } public static uint ContractGoldCapped(uint goldReward, int teamStacks, uint maxGold) { uint num = ContractGold(goldReward, teamStacks); if (maxGold == 0 || num <= maxGold) { return num; } return maxGold; } public static uint ContractGold(uint goldReward, int teamStacks) { if (goldReward == 0 || teamStacks <= 0) { return 0u; } ulong num = (ulong)(goldReward * teamStacks); if (num <= uint.MaxValue) { return (uint)num; } return uint.MaxValue; } public static bool ReviveStep(ref float progress, bool allyNear, float dt, float required) { if (!allyNear || float.IsNaN(dt) || dt < 0f) { progress = 0f; return false; } progress += dt; if (progress < required) { return false; } progress = 0f; return true; } public static float ReviverCost(float currentHealth, float fraction) { if (float.IsNaN(currentHealth) || currentHealth <= 1f || float.IsNaN(fraction) || fraction <= 0f) { return 0f; } return Math.Min(currentHealth * Math.Min(1f, fraction), currentHealth - 1f); } } } namespace Ror2Meeeee.Core.Gold { public static class GoldCredit { public static float Compute(uint amount, int stacks, float ratioPerStack) { if (amount == 0 || stacks <= 0 || float.IsNaN(ratioPerStack) || float.IsInfinity(ratioPerStack) || ratioPerStack <= 0f) { return 0f; } return (float)Math.Min((double)amount * (double)stacks * (double)ratioPerStack, 3.4028234663852886E+38); } } public static class TitheThanks { public const string PrefixPt = "<color=#c792ea>Diretor:</color> "; public const string PrefixEn = "<color=#c792ea>Director:</color> "; public static readonly string[] LinesPt = new string[4] { "Obrigado pelo dízimo! R$ {1} de vocês já viraram {0} de crédito em monstro.", "Sua generosidade foi notada: R$ {1} viraram +{0} de crédito de spawn.", "R$ {1} recolhidos, {0} de crédito investido em companhia para vocês.", "O diretor agradece a contribuição de R$ {1}. Os monstros também ({0} de crédito)." }; public static readonly string[] LinesEn = new string[4] { "Thanks for the tithe! Your ${3} has already become {2} credit in monsters.", "Your generosity has been noticed: ${3} became +{2} spawn credit.", "${3} collected, {2} credit invested in company for you.", "The director thanks you for the ${3} contribution. So do the monsters ({2} credit)." }; public static bool Due(double now, double lastPost, double interval, double pendingCredit) { if (interval > 0.0 && pendingCredit >= 1.0) { return now - lastPost >= interval; } return false; } public static int Line(int index) { return (int)((uint)index % (uint)LinesPt.Length); } public static string[] Args(double credit, ulong gold) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; string text = Math.Floor(credit).ToString("N0", invariantCulture); string text2 = gold.ToString("N0", invariantCulture); return new string[4] { Thousands(text), Thousands(text2), text, text2 }; } public static string Format(int index, double credit, ulong gold, bool english = false) { int num = Line(index); object[] args; if (!english) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; string format = LinesPt[num]; args = Args(credit, gold); return "<color=#c792ea>Diretor:</color> " + string.Format(invariantCulture, format, args); } CultureInfo invariantCulture2 = CultureInfo.InvariantCulture; string format2 = LinesEn[num]; args = Args(credit, gold); return "<color=#c792ea>Director:</color> " + string.Format(invariantCulture2, format2, args); } private static string Thousands(string invariantN0) { return invariantN0.Replace(',', '.'); } } } namespace Ror2Meeeee.Core.Elites { public static class EliteRules { public static (int First, int Second) PickTwoDistinct(int count, int a, int b) { if (count < 1) { return (First: -1, Second: -1); } if (count < 2) { return (First: 0, Second: -1); } return (First: a, Second: (b >= a) ? (b + 1) : b); } } } namespace Ror2Meeeee.Core.Eligibility { public enum ItemKind { White, Green, Red, Boss, Lunar, Void, Temporary, Scrap, Equipment, Other, Special } public static class EligibilityTable { public static bool IsEligible(ItemKind kind, MultiplierRules rules) { switch (kind) { case ItemKind.White: case ItemKind.Green: case ItemKind.Red: case ItemKind.Boss: return true; case ItemKind.Lunar: return rules.IncludeLunar; case ItemKind.Void: return rules.IncludeVoid; default: return false; } } public static bool IsShareable(ItemKind kind) { if (kind != ItemKind.Equipment) { return kind != ItemKind.Other; } return false; } } } namespace Ror2Meeeee.Core.Difficulty { public readonly struct DifficultyGains { public float Health { get; } public float Damage { get; } public float Quantity { get; } public float Pace { get; } public DifficultyGains(float health, float damage, float quantity, float pace) { Health = health; Damage = damage; Quantity = quantity; Pace = pace; } } public readonly struct DifficultyMultipliers { public static readonly DifficultyMultipliers Identity = new DifficultyMultipliers(1f, 1f, 1f, 1f); public float Health { get; } public float Damage { get; } public float Quantity { get; } public float Pace { get; } public DifficultyMultipliers(float health, float damage, float quantity, float pace) { Health = health; Damage = damage; Quantity = quantity; Pace = pace; } } public static class DifficultyCurve { public const float DefaultFactor = 1f; public const float MinMultiplier = 0.1f; public const float MaxMultiplier = 1000f; public static float SanitizeFactor(float factor) { if (float.IsNaN(factor) || float.IsInfinity(factor) || factor <= 0f) { return 1f; } return factor; } public static DifficultyMultipliers Evaluate(float factor, DifficultyGains gains) { float factor2 = SanitizeFactor(factor); return new DifficultyMultipliers(Axis(factor2, gains.Health), Axis(factor2, gains.Damage), Axis(factor2, gains.Quantity), Axis(factor2, gains.Pace)); } public static float WithBonus(float multiplier, float bonusPercent) { if (float.IsNaN(bonusPercent) || float.IsInfinity(bonusPercent)) { bonusPercent = 0f; } double val = (double)multiplier * (1.0 + (double)bonusPercent / 100.0); return (float)Math.Min(1000.0, Math.Max(0.10000000149011612, val)); } private static float Axis(float factor, float gain) { if (float.IsNaN(gain) || float.IsInfinity(gain)) { return 1f; } double val = 1.0 + ((double)factor - 1.0) * (double)gain; return (float)Math.Min(1000.0, Math.Max(0.10000000149011612, val)); } } public static class HordeCurve { public static float QuantityMultiplier(int stacks, float perStack, float max) { if (stacks <= 0 || float.IsNaN(perStack) || float.IsNaN(max) || perStack <= 0f || max < 1f) { return 1f; } double val = 1.0 + (double)stacks * (double)perStack; return (float)Math.Min(max, val); } } } namespace Ror2Meeeee.Core.Bazaar { public enum BazaarTier { White, Green, Red, Boss, Lunar, Equipment, LunarEquipment } public static class BazaarRules { public const int TierCount = 7; public const int MaxChests = 6; public const int SmallChestBaseCost = 25; public const int Unlimited = -1; public static int PickWeighted(IReadOnlyList<float> weights, double roll) { double num = 0.0; for (int i = 0; i < weights.Count; i++) { num += Valid(weights[i]); } if (num <= 0.0) { return -1; } double num2 = roll * num; int result = -1; for (int j = 0; j < weights.Count; j++) { double num3 = Valid(weights[j]); if (!(num3 <= 0.0)) { if (num2 < num3) { return j; } num2 -= num3; result = j; } } return result; } public static int ScaledCost(int baseCost, float difficultyCoefficient, float multiplier) { double x = ((float.IsNaN(difficultyCoefficient) || difficultyCoefficient <= 0f) ? 1f : difficultyCoefficient); double num = ((float.IsNaN(multiplier) || multiplier < 0f) ? 0f : multiplier); double num2 = (double)Math.Max(0, baseCost) * Math.Pow(x, 1.25) * num; if (!(num2 >= 2147483647.0)) { return (int)num2; } return int.MaxValue; } public static int GoldCost(float difficultyCoefficient, float multiplier) { return ScaledCost(25, difficultyCoefficient, multiplier); } public static bool UnderLimit(int used, int limit) { if (limit >= 0) { return used < limit; } return true; } public static int ClampChests(int n) { if (n >= 1) { if (n <= 6) { return n; } return 6; } return 1; } public static uint AddMoney(uint money, long amount) { long num = money + amount; if (num > 0) { if (num < uint.MaxValue) { return (uint)num; } return uint.MaxValue; } return 0u; } private static double Valid(float w) { return (float.IsNaN(w) || w <= 0f) ? 0f : w; } } } namespace Ror2Meeeee.Core.Aegis { public static class AegisRules { public const float BlockChancePercent = 5f; public const float StealPerStack = 0.08f; public const float StealCap = 0.5f; public const float VoidPerStack = 0.03f; public const float VoidCap = 0.2f; public const float VoidBaseRadius = 13f; public const float VoidRadiusPerStack = 2f; public const float VoidRadiusCap = 30f; public static float StealFraction(int stacks) { return Capped(0.08f * (float)stacks, stacks, 0.5f); } public static float VoidFraction(int stacks) { return Capped(0.03f * (float)stacks, stacks, 0.2f); } public static float VoidRadius(int stacks) { if (stacks <= 0) { return 0f; } float num = 13f + 2f * (float)(stacks - 1); if (!(num < 30f)) { return 30f; } return num; } private static float Capped(float value, int stacks, float cap) { if (stacks > 0) { if (!(value < cap)) { return cap; } return value; } return 0f; } } }
Ror2Meeeee.dll
Decompiled a month 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.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.ClayBoss; using EntityStates.DefectiveUnit; using EntityStates.Drone; using EntityStates.Enforcer; using EntityStates.HallowedCauldron; using EntityStates.LunarTeleporter; using EntityStates.Mimic.Chest; using EntityStates.Totem; using EntityStates.VoidBarnacle; using HG.Reflection; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using On; using On.EntityStates.CaptainSupplyDrop; using On.EntityStates.ClayBoss; using On.EntityStates.DefectiveUnit; using On.EntityStates.Drone; using On.EntityStates.Enforcer; using On.EntityStates.HallowedCauldron; using On.EntityStates.LunarTeleporter; using On.EntityStates.Mimic.Chest; using On.EntityStates.Totem; using On.EntityStates.VoidBarnacle; using On.RoR2; using On.RoR2.Items; using On.RoR2.Orbs; using On.RoR2.Projectile; using R2API; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.AsyncManagement; using RoR2.CharacterAI; using RoR2.Items; using RoR2.Navigation; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using Ror2Meeeee.Core.Aegis; using Ror2Meeeee.Core.Bazaar; using Ror2Meeeee.Core.Difficulty; using Ror2Meeeee.Core.Eligibility; using Ror2Meeeee.Core.Elites; using Ror2Meeeee.Core.Gold; using Ror2Meeeee.Core.Helluva; using Ror2Meeeee.Core.Limits; using Ror2Meeeee.Core.Measurement; using Ror2Meeeee.Core.Pipeline; using Ror2Meeeee.Core.Progression; using Ror2Meeeee.Core.RustyNail; using Ror2Meeeee.Core.Spend; using Ror2Meeeee.Core.Stats; using Ror2Meeeee.Core.Tax; using Ror2Meeeee.Core.Tempest; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.Profiling; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Ror2Meeeee")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+baf584b99ffa41c39e917e5364107fb04fc3b69c")] [assembly: AssemblyProduct("Ror2Meeeee")] [assembly: AssemblyTitle("Ror2Meeeee")] [assembly: AssemblyVersion("1.0.0.0")] [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 Ror2Meeeee { internal interface IHolderSet { bool HasHolders { get; } bool Holds(GameObject body); } internal static class BodyHooks { [CompilerGenerated] private static class <>O { public static hook_RecalculateStats <0>__OnRecalculateStats; public static hook_TakeDamageProcess <1>__OnTakeDamage; } private static bool RawDamage; internal static HeavyHeartFeature Heart; internal static BastionFeature Bastion; internal static CervoFeature Cervo; internal static AegisFeature Aegis; internal static TempestFeature Tempest; private static bool _stats; private static bool _damage; private static readonly Action<CharacterBody, float> SetMaxHealth = Setter("maxHealth"); private static readonly Action<CharacterBody, float> SetMaxShield = Setter("maxShield"); private static readonly Action<CharacterBody, float> SetMaxBarrier = Setter("maxBarrier"); private static readonly Action<CharacterBody, float> SetMaxHull = Setter("maxHull"); internal static void Charge(HealthComponent hc, float damage, bool lethal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown DamageType val = (DamageType)262210; if (!lethal) { val = (DamageType)(val | 1); } ProcChainMask procChainMask = default(ProcChainMask); ((ProcChainMask)(ref procChainMask)).AddProc((ProcType)15); float barrier = hc.barrier; float shield = hc.shield; hc.Networkbarrier = 0f; hc.Networkshield = 0f; RawDamage = true; try { hc.TakeDamage(new DamageInfo { damage = damage, position = (Object.op_Implicit((Object)(object)hc.body) ? hc.body.corePosition : ((Component)hc).transform.position), damageType = DamageTypeCombo.op_Implicit(val), damageColorIndex = (DamageColorIndex)2, procChainMask = procChainMask }); } finally { RawDamage = false; if (Object.op_Implicit((Object)(object)hc)) { hc.Networkbarrier = barrier; hc.Networkshield = shield; } } } private static Action<CharacterBody, float> Setter(string property) { MethodInfo methodInfo = typeof(CharacterBody).GetProperty(property)?.GetSetMethod(nonPublic: true); if (!(methodInfo == null)) { return (Action<CharacterBody, float>)Delegate.CreateDelegate(typeof(Action<CharacterBody, float>), methodInfo); } return null; } private static bool Active(IHolderSet f) { return f?.HasHolders ?? false; } public static void Sync() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown bool flag = Tempest != null && Tempest.HealthHook; bool flag2 = Active(Heart) || Active(Bastion) || Active(Cervo) || flag; if (flag2 != _stats) { if (flag2) { object obj = <>O.<0>__OnRecalculateStats; if (obj == null) { hook_RecalculateStats val = OnRecalculateStats; <>O.<0>__OnRecalculateStats = val; obj = (object)val; } CharacterBody.RecalculateStats += (hook_RecalculateStats)obj; } else { object obj2 = <>O.<0>__OnRecalculateStats; if (obj2 == null) { hook_RecalculateStats val2 = OnRecalculateStats; <>O.<0>__OnRecalculateStats = val2; obj2 = (object)val2; } CharacterBody.RecalculateStats -= (hook_RecalculateStats)obj2; } _stats = flag2; ManualLogSource log = Diag.Log; if (log != null) { log.LogInfo((object)("[BodyHooks] hook de stats " + (flag2 ? "ligado" : "desligado") + " (Coração/Bastião/Cervo/Tormenta)")); } } bool flag3 = Active(Heart) || Active(Aegis) || (Tempest != null && Tempest.DamageHook); if (flag3 == _damage) { return; } if (flag3) { object obj3 = <>O.<1>__OnTakeDamage; if (obj3 == null) { hook_TakeDamageProcess val3 = OnTakeDamage; <>O.<1>__OnTakeDamage = val3; obj3 = (object)val3; } HealthComponent.TakeDamageProcess += (hook_TakeDamageProcess)obj3; } else { object obj4 = <>O.<1>__OnTakeDamage; if (obj4 == null) { hook_TakeDamageProcess val4 = OnTakeDamage; <>O.<1>__OnTakeDamage = val4; obj4 = (object)val4; } HealthComponent.TakeDamageProcess -= (hook_TakeDamageProcess)obj4; } _damage = flag3; ManualLogSource log2 = Diag.Log; if (log2 != null) { log2.LogInfo((object)("[BodyHooks] hook de dano " + (flag3 ? "ligado" : "desligado") + " (Égides/Coração/Tormenta)")); } } private static void OnRecalculateStats(orig_RecalculateStats orig, CharacterBody self) { GameObject val = (Object.op_Implicit((Object)(object)self) ? ((Component)self).gameObject : null); bool flag = Object.op_Implicit((Object)(object)val) && Heart != null && Heart.Holds(val); bool flag2 = Object.op_Implicit((Object)(object)val) && Bastion != null && Bastion.Holds(val); bool flag3 = Object.op_Implicit((Object)(object)val) && Cervo != null && Cervo.Holds(val); int num = ((Object.op_Implicit((Object)(object)val) && Tempest != null && Tempest.HealthHook) ? TempestStacks(self) : 0); if (!flag && !flag2 && !flag3 && num == 0) { orig.Invoke(self); return; } HealthComponent healthComponent = self.healthComponent; float maxHealth = self.maxHealth; float num2 = (Object.op_Implicit((Object)(object)healthComponent) ? healthComponent.health : 0f); float maxShield = self.maxShield; float num3 = (Object.op_Implicit((Object)(object)healthComponent) ? healthComponent.shield : 0f); orig.Invoke(self); if (num > 0) { ApplyTempestHealth(self, num); } if (flag) { Heart.ApplyStats(self); } if (flag2) { Bastion.ApplyStats(self); } if (flag3) { Cervo.ApplyStats(self); } ClampPools(self); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)healthComponent) || !healthComponent.alive) { return; } try { if (flag || num > 0) { healthComponent.Networkhealth = StatPool.Adjust(num2, maxHealth, self.maxHealth); } if (flag2) { healthComponent.Networkshield = StatPool.Adjust(num3, maxShield, self.maxShield); } } catch (Exception ex) { ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[BodyHooks] reajuste de vida/escudo falhou: " + ex.Message)); } } } private static int TempestStacks(CharacterBody self) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) ItemIndex index = TempestHealthItem.Index; Inventory inventory = self.inventory; if ((int)index == -1 || !Object.op_Implicit((Object)(object)inventory)) { return 0; } return inventory.GetItemCountPermanent(index); } private static void ApplyTempestHealth(CharacterBody self, int stacks) { try { if (SetMaxHealth != null && SetMaxBarrier != null && SetMaxHull != null) { float maxHealth = self.maxHealth; float num = maxHealth * (1f + (float)stacks / 100f); SetMaxHealth(self, num); SetMaxBarrier(self, num + self.maxShield); SetMaxHull(self, num + self.maxShield); if (Tempest != null && Tempest.DebugOn) { Tempest.LogHealth(self, maxHealth, stacks); } } } catch (Exception ex) { ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[BodyHooks] vida da Tormenta falhou: " + ex.Message)); } } } private static void ClampPools(CharacterBody self) { try { float num = StatPool.ClampScale(self.maxHealth, self.maxShield); if (!(num >= 1f) && SetMaxHealth != null && SetMaxShield != null && SetMaxBarrier != null && SetMaxHull != null) { float num2 = self.maxHealth * num; float num3 = self.maxShield * num; SetMaxHealth(self, num2); SetMaxShield(self, num3); SetMaxBarrier(self, num2 + num3); SetMaxHull(self, num2 + num3); } } catch (Exception ex) { ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[BodyHooks] teto de vida/escudo falhou: " + ex.Message)); } } } private static void OnTakeDamage(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo) { if (RawDamage) { orig.Invoke(self, damageInfo); return; } CharacterBody body = null; bool num = Aegis != null && Aegis.BeforeDamage(self, damageInfo, out body); Heart?.AmplifyDamage(self, damageInfo); Tempest?.ReduceDamage(self, damageInfo); orig.Invoke(self, damageInfo); if (num && damageInfo.rejected) { Aegis.AfterBlocked(body, damageInfo); } Tempest?.AfterDamage(self, damageInfo); } } public sealed class Cfg { public const int MinMaxFailures = 50; public const int ConfigVersion = 3; private readonly ConfigFile _file; private readonly ManualLogSource _log; private readonly ConfigEntry<bool> _verboseLogging; private readonly ConfigEntry<int> _maxFailures; private readonly List<ConfigEntryBase> _entries = new List<ConfigEntryBase>(); private readonly Dictionary<ConfigEntryBase, string> _pt = new Dictionary<ConfigEntryBase, string>(); private const string EnabledSuffixEn = " Toggles immediately; the effect applies from the next event or stage."; private const string EnabledSuffixPt = " Liga/desliga na hora; o efeito vale a partir do próximo evento ou estágio."; public IReadOnlyList<ConfigEntryBase> Entries => _entries; public ConfigEntry<bool> ProbeEnabledEntry { get; } public bool ProbeEmptyHook { get; } public int ProbeAutoWindowSeconds { get; } public bool VerboseLogging { get; private set; } public int MaxFailures { get; private set; } public int LoadedConfigVersion { get; } public Cfg(ConfigFile file, ManualLogSource log) { _file = file; _log = log; _verboseLogging = Bind("General", "VerboseLogging", defaultValue: false, "Extra debug logs in LogOutput.log. Keep it off for regular play: verbose logging costs FPS.", "Logs extras de depuração no LogOutput.log. Deixe desligado no dia a dia: log verboso custa FPS."); _maxFailures = Bind("General", "MaxFailures", 50, $"How many errors a feature may have before it turns itself off to protect the match. Minimum {50}.", $"Quantos erros uma feature pode ter antes de se desligar sozinha para proteger a partida. Mínimo {50}."); ProbeEnabledEntry = Bind("General", "ProbeEnabled", defaultValue: false, "Performance measurement tool: records frame time, RAM, projectiles and damage to BepInEx/ror2meeeee-probe.csv. For testing only; costs nothing when off. Does not change the game.", "Ferramenta de medição de desempenho: grava tempo de frame, RAM, projéteis e dano em BepInEx/ror2meeeee-probe.csv. Só para testes; desligada não custa nada. Não muda o jogo."); ProbeEmptyHook = Bind("General", "ProbeEmptyHook", defaultValue: false, "Probe test: adds an empty hook to measure what a hook alone costs. Requires restarting the game.", "Teste do Probe: adiciona um hook vazio para medir quanto custa um hook sozinho. Exige reiniciar o jogo.").Value; ProbeAutoWindowSeconds = Math.Max(0, Bind("General", "ProbeAutoWindowSeconds", 30, "Probe: measures on its own during the run in X-second windows (each window becomes a line in the CSV and the log). 0 = only with the ror2meeeee_probe_* commands. Requires restarting the game.", "Probe: mede sozinho durante a run em janelas de X segundos (cada janela vira uma linha no CSV e no log). 0 = só com os comandos ror2meeeee_probe_*. Exige reiniciar o jogo.").Value); ConfigEntry<int> val = Bind("General", "ConfigVersion", 3, "Format version of this file, used to migrate keys between mod versions. Do not change.", "Versão do formato deste arquivo, usada para migrar chaves entre versões do mod. Não altere."); LoadedConfigVersion = val.Value; if (val.Value != 3) { _log.LogInfo((object)$"General.ConfigVersion={val.Value} -> {3}: as features migram as chaves que mudaram."); val.Value = 3; } _verboseLogging.SettingChanged += delegate { Refresh(); }; _maxFailures.SettingChanged += delegate { Refresh(); }; Refresh(); } public ConfigEntry<bool> BindEnabled(string section, string summaryEn = null, string summaryPt = null, bool defaultValue = false) { return Bind(section, "Enabled", defaultValue, (summaryEn ?? "Turns this feature on.") + " Toggles immediately; the effect applies from the next event or stage.", (summaryPt ?? "Liga esta feature.") + " Liga/desliga na hora; o efeito vale a partir do próximo evento ou estágio."); } public ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string descriptionEn, string descriptionPt) { ConfigEntry<T> val = _file.Bind<T>(section, key, defaultValue, descriptionEn); if (!_entries.Contains((ConfigEntryBase)(object)val)) { _entries.Add((ConfigEntryBase)(object)val); _pt[(ConfigEntryBase)(object)val] = descriptionPt; } return val; } public string DescriptionPt(ConfigEntryBase entry) { if (!_pt.TryGetValue(entry, out var value)) { return entry.Description.Description; } return value; } private void Refresh() { VerboseLogging = _verboseLogging.Value; int num = _maxFailures.Value; if (num < 50) { _log.LogWarning((object)$"General.MaxFailures={num} inválido (mínimo {50}); usando {50}."); num = 50; _maxFailures.Value = num; } MaxFailures = num; } } internal static class Diag { internal sealed class RateWatch { private readonly string _name; private readonly int _threshold; private float _start; private int _n; private bool _logged; public RateWatch(string name, int threshold) { _name = name; _threshold = threshold; lock (Watches) { Watches.Add(this); } } public void ResetStage() { _logged = false; } public bool Hit(int scale = 1) { float time = Time.time; if (time - _start >= 1f) { _start = time; _n = 0; } if (++_n < _threshold * Math.Max(1, scale) || _logged) { return false; } _logged = true; return true; } public void Report(string detail = null) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)string.Format("[Diag] enxurrada de {0}: {1} em <1 s{2}; monstros ~{3}. Origem:\n{4}", _name, _n, (detail != null) ? (" (" + detail + ")") : "", Monsters, new StackTrace(1, fNeedFileInfo: false))); } } } [CompilerGenerated] private static class <>O { public static Action<Stage> <0>__OnStageBegin; public static Action<Stage> <1>__OnStageComplete; public static Action<Run> <2>__OnRunDestroy; public static Action<DamageReport> <3>__OnDeath; public static Action <4>__OnUpdate; public static LogCallback <5>__OnUnityLog; public static ThreadStart <6>__WatchLoop; } public static long GoldEvents; public static double CreditGiven; public static long CreditDropped; public static int Exceptions; public static int Revives; public static int GrimoireUses; public static long GhostBladesSkipped; public static double GrimoireTrimmed; public static int Tombstones; public static int Monsters; public static float FrameMsAvg; public static int WindowMaxMonsters; public static double MonsterSum; public static long MonsterSamples; private static readonly string[] KnownNoise = new string[40] { "PushPickupNotification", "FrolicAway", "DroneCopycat", "has no NetworkIdentity", "Non-convex MeshCollider", "InvalidKeyException", "Could not find target object with netId", "Lobby.GetMemberIDs", "already a player at that playerControllerId", "A connection has already been set as ready", "ViewableTag.OnDisable", "SteamworksLobbyDataGenerator.RebuildLobbyData", "ReleasePools called on non-empty pool", "AssignClientAuthority can only be used", "CombatSquad has no living members", "Unable to set gate state for", "PickupDisplay bounds are zero", "invoked wrong io operation", "out of bound or host has been already removed", "SurvivorMannequinSlotController.ApplyLoadoutToMannequinInstance", "ExtractorUnit.ExtractLunge.OnEnter", "SolusAmalgamator.DetatchState.OnEnter", "InventorySafekeepController.OnCharacterMasterLost", "SetStateOnHurt.GetModifiedDuration", "ParticleSystemColorFromEffectData.ResetParticleSystems", "from prefab named 'GenericHugeFootstepDust'", "BaseAchievement: localUser is null", "MasterSuicideOnTimer.OnDestroy", "BrotherUltUtils.EvaluatePattern", "CaptainSupplyDropFinaleAchievement", "AcolyteBodySwapController+ProjectileSkillOverrideManager", "BurnEffectController.Start", "PlaySoundOnEvent.OnDestroy", "ActivityManager::CurrentSurvivor property unable to determine survivor", "Facepunch.Steamworks.Networking.SendP2PPacket", "HurtBox.SimpleColliderBlockFilter", "EnableCustomRenderTextureOnLight.OnDisable", "path \"GhostBladesProjectile", "TeleportOnLowHealthBehavior.OnDisable", "GlobalEventManager.OnCrit" }; private static readonly int[] KnownCounts = new int[KnownNoise.Length]; private static readonly HashSet<string> SeenUnknown = new HashSet<string>(); private static readonly object UnityLogLock = new object(); private static int _unknownCount; private static int _unknownAtStage; private const float StallSeconds = 3f; private const float LongFrameSeconds = 1f; private static int _gcCount; private static long _gcMemory; private static int _frameHeals; private static int _frameDamage; private static ManualLogSource _log; private static long _beat; private static volatile bool _watch; private static float _sampleAcc; private static volatile float _lastFrameMs; private const int HeartbeatSeconds = 5; private static readonly object HeartbeatLock = new object(); private static bool _stageActive; private static string _stageName; private static float _stageStart; private static float _stageWorstMs; private static int _stageKills; private static int _stageMaxMonsters; private static long _gold0; private static double _credit0; private static long _dropped0; private static int _exc0; private static int _rev0; private static readonly List<RateWatch> Watches = new List<RateWatch>(); private static string HeartbeatPath => Path.Combine(Paths.BepInExRootPath, "ror2meeeee-heartbeat.txt"); public static ManualLogSource Log => _log; public static void Install(ManualLogSource log) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown _log = log; Interlocked.Exchange(ref _beat, Stopwatch.GetTimestamp()); Stage.onServerStageBegin += OnStageBegin; Stage.onServerStageComplete += OnStageComplete; Run.onRunDestroyGlobal += OnRunDestroy; GlobalEventManager.onCharacterDeathServer += OnDeath; HealthComponent.onCharacterHealServer += delegate { _frameHeals++; }; GlobalEventManager.onServerDamageDealt += delegate { _frameDamage++; }; RoR2Application.onUpdate += OnUpdate; object obj = <>O.<5>__OnUnityLog; if (obj == null) { LogCallback val = OnUnityLog; <>O.<5>__OnUnityLog = val; obj = (object)val; } Application.logMessageReceivedThreaded += (LogCallback)obj; ReportPreviousSession(); MainThreadSampler.Init(); Thread thread = new Thread(WatchLoop); thread.IsBackground = true; thread.Name = "Ror2Meeeee.Watchdog"; thread.Start(); } private static void ReportPreviousSession() { try { string heartbeatPath = HeartbeatPath; if (File.Exists(heartbeatPath)) { _log.LogWarning((object)("[Vigia] a sessão anterior não fechou normalmente (travou ou foi encerrada à força). Último sinal: " + File.ReadAllText(heartbeatPath).Trim())); File.Delete(heartbeatPath); } } catch (Exception ex) { _log.LogWarning((object)("[Vigia] falha ao ler o último sinal: " + ex.Message)); } } public static void MarkCleanExit() { lock (HeartbeatLock) { try { File.Delete(HeartbeatPath); } catch (Exception) { } } } private static void WriteHeartbeat(double gap) { lock (HeartbeatLock) { if (!Plugin.Quitting) { string contents = string.Format("{0:yyyy-MM-dd HH:mm:ss} | estágio {1} | ", DateTime.Now, _stageActive ? _stageName : "fora de estágio") + $"último frame há {gap:F1} s ({_lastFrameMs:F0} ms) | monstros {Monsters} | abates no estágio {_stageKills} | " + $"eventos de ouro {GoldEvents} | lâminas puladas {GhostBladesSkipped} | exceções do mod {Exceptions} | " + $"RAM gerenciada {GC.GetTotalMemory(forceFullCollection: false) / 1048576} MB"; File.WriteAllText(HeartbeatPath, contents); } } } private static void OnStageBegin(Stage stage) { try { if (_stageActive) { LogStageSummary("(interrompido)"); } _stageActive = true; _stageName = ((Object.op_Implicit((Object)(object)stage) && Object.op_Implicit((Object)(object)stage.sceneDef)) ? stage.sceneDef.cachedName : "?"); _stageStart = Time.time; _stageWorstMs = 0f; _stageKills = 0; _stageMaxMonsters = 0; _gold0 = GoldEvents; _credit0 = CreditGiven; _dropped0 = CreditDropped; _exc0 = Exceptions; _rev0 = Revives; _unknownAtStage = _unknownCount; foreach (RateWatch watch in Watches) { watch.ResetStage(); } DroppedGrants.Clear(); Interlocked.Exchange(ref _beat, Stopwatch.GetTimestamp()); _watch = true; } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[Diag] falha no início do estágio: " + ex.Message)); } } } private static void OnStageComplete(Stage stage) { try { LogStageSummary("concluído"); } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[Diag] falha no resumo do estágio: " + ex.Message)); } } _watch = false; } private static void OnRunDestroy(Run run) { try { if (_stageActive) { LogStageSummary("run encerrada"); } } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[Diag] falha no resumo do estágio: " + ex.Message)); } } _watch = false; } private static void LogStageSummary(string how) { if (_stageActive) { _stageActive = false; int num; lock (UnityLogLock) { num = _unknownCount - _unknownAtStage; } _log.LogInfo((object)($"[Estágio] {_stageName} {how}: {Time.time - _stageStart:F0} s | pior frame {_stageWorstMs:F0} ms | " + $"abates {_stageKills} | monstros pico {_stageMaxMonsters} | ouro {GoldEvents - _gold0} eventos, crédito +{CreditGiven - _credit0:F0} " + $"(cortados {CreditDropped - _dropped0}) | revives {Revives - _rev0} | exceções do mod {Exceptions - _exc0} | erros novos do jogo {num}")); } } private static void OnDeath(DamageReport report) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 if (_stageActive && report != null && (int)report.victimTeamIndex == 2) { _stageKills++; } } private static void OnUpdate() { Interlocked.Exchange(ref _beat, Stopwatch.GetTimestamp()); float unscaledDeltaTime = Time.unscaledDeltaTime; float num = (_lastFrameMs = unscaledDeltaTime * 1000f); FrameMsAvg += (num - FrameMsAvg) * 0.05f; if (num > _stageWorstMs) { _stageWorstMs = num; } int num2 = GC.CollectionCount(0); long totalMemory = GC.GetTotalMemory(forceFullCollection: false); if (unscaledDeltaTime >= 1f && _watch) { LogLongFrame(unscaledDeltaTime, num2 - _gcCount, totalMemory); } _gcCount = num2; _gcMemory = totalMemory; _frameHeals = (_frameDamage = 0); _sampleAcc += unscaledDeltaTime; if (!(_sampleAcc < 0.5f)) { _sampleAcc = 0f; int num3 = (Monsters = (Object.op_Implicit((Object)(object)Run.instance) ? TeamComponent.GetTeamMembers((TeamIndex)2).Count : 0)); MonsterSum += num3; MonsterSamples++; if (num3 > WindowMaxMonsters) { WindowMaxMonsters = num3; } if (num3 > _stageMaxMonsters) { _stageMaxMonsters = num3; } } } private static void LogLongFrame(float dt, int collections, long memory) { try { _log.LogWarning((object)($"[Vigia] frame de {dt:F1} s | coletas do GC no frame {collections}, RAM gerenciada {_gcMemory / 1048576} -> {memory / 1048576} MB | " + $"curas no frame {_frameHeals}, danos no frame {_frameDamage} | monstros: {MonsterBreakdown(8)}")); } catch (Exception ex) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[Vigia] falha no relatório do frame longo: " + ex.Message)); } } } public static string MonsterBreakdown(int top) { ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers((TeamIndex)2); if (teamMembers == null || teamMembers.Count == 0) { return "nenhum"; } Dictionary<string, int> dictionary = new Dictionary<string, int>(); for (int i = 0; i < teamMembers.Count; i++) { TeamComponent val = teamMembers[i]; string text = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.body)) ? ((Object)val.body).name : "?"); if (text.EndsWith("(Clone)")) { text = text.Substring(0, text.Length - 7); } dictionary.TryGetValue(text, out var value); dictionary[text] = value + 1; } List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>(dictionary); list.Sort((KeyValuePair<string, int> a, KeyValuePair<string, int> b) => b.Value.CompareTo(a.Value)); StringBuilder stringBuilder = new StringBuilder(); for (int num = 0; num < list.Count && num < top; num++) { stringBuilder.Append((num == 0) ? "" : ", ").Append(list[num].Key).Append('=') .Append(list[num].Value); } if (list.Count > top) { stringBuilder.Append($" (+{list.Count - top} tipos)"); } return stringBuilder.ToString(); } private static void WatchLoop() { float num = 3f; bool flag = false; int num2 = 0; while (!Plugin.Quitting) { Thread.Sleep(1000); try { double num3 = (double)(Stopwatch.GetTimestamp() - Interlocked.Read(in _beat)) / (double)Stopwatch.Frequency; if (++num2 % 5 == 0) { WriteHeartbeat(num3); } if (!_watch) { flag = false; num = 3f; } else if (num3 >= (double)num) { if (!flag) { _log.LogWarning((object)("[Vigia] " + MainThreadSampler.Sample())); } flag = true; num = (float)num3 + 10f; _log.LogWarning((object)($"[Vigia] jogo sem atualizar há {num3:F0} s (monstros ~{Monsters}, eventos de ouro {GoldEvents}, lápides {Tombstones}; " + $"RAM gerenciada {GC.GetTotalMemory(forceFullCollection: false) / 1048576} MB, coletas do GC desde o último frame {GC.CollectionCount(0) - _gcCount}).")); } else if (num3 < 3.0 && flag) { flag = false; num = 3f; _log.LogInfo((object)"[Vigia] jogo voltou a responder."); } } catch (Exception) { } } } private static void OnUnityLog(string condition, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 if (((int)type != 0 && (int)type != 4 && (int)type != 1) || string.IsNullOrEmpty(condition) || condition.Contains("Ror2Meeeee")) { return; } lock (UnityLogLock) { for (int i = 0; i < KnownNoise.Length; i++) { if (condition.Contains(KnownNoise[i]) || (stackTrace != null && stackTrace.Contains(KnownNoise[i]))) { KnownCounts[i]++; return; } } _unknownCount++; int num = condition.IndexOf('\n'); string text = ((num > 0) ? condition.Substring(0, num) : condition); if (text.Length > 140) { text = text.Substring(0, 140); } StringBuilder stringBuilder = new StringBuilder(text.Length); string text2 = text; foreach (char c in text2) { stringBuilder.Append(char.IsDigit(c) ? '#' : c); } string text3 = (string.IsNullOrEmpty(stackTrace) ? "" : stackTrace.Split('\n')[0].Trim()); if (SeenUnknown.Count < 60 && SeenUnknown.Add(stringBuilder?.ToString() + text3)) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)("[Diag] erro novo do jogo/outro mod (1ª vez): " + text + ((text3.Length > 0) ? (" @ " + text3) : ""))); } } } } public static string Report() { StringBuilder stringBuilder = new StringBuilder("Diagnóstico:\n"); stringBuilder.Append($" ouro: {GoldEvents} eventos, crédito +{CreditGiven:F0}, cortado em {CreditDropped} eventos\n"); stringBuilder.Append($" monstros agora ~{Monsters}, pico do estágio {_stageMaxMonsters}, pior frame do estágio {_stageWorstMs:F0} ms\n"); stringBuilder.Append($" exceções do mod {Exceptions}, revives {Revives}, lápides {Tombstones}, usos do Grimório {GrimoireUses} (crédito cortado {GrimoireTrimmed:F0}), lâminas fantasmas puladas {GhostBladesSkipped}\n"); stringBuilder.Append($" MoneyHub: {MoneyHub.Calls} chamadas, custo do mod ~{MoneyHub.AverageMicros:F1} µs/chamada (amostrado)\n"); lock (UnityLogLock) { stringBuilder.Append($" erros do jogo: {_unknownCount} novos"); for (int i = 0; i < KnownNoise.Length; i++) { if (KnownCounts[i] > 0) { stringBuilder.Append($", {KnownNoise[i]}={KnownCounts[i]}"); } } } return stringBuilder.ToString(); } } internal static class Directors { private static readonly FieldInfo MoneyWavesField = typeof(CombatDirector).GetField("moneyWaves", BindingFlags.Instance | BindingFlags.NonPublic); public static bool Available => MoneyWavesField != null; public static Array GetMoneyWaves(CombatDirector d) { return MoneyWavesField?.GetValue(d) as Array; } public static bool IsMainMonster(CombatDirector d) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)d.teamIndex == 2) { Array moneyWaves = GetMoneyWaves(d); if (moneyWaves != null) { return moneyWaves.Length > 0; } } return false; } } internal sealed class DropMenu : MonoBehaviour { private struct Row { public string Name; public string Internal; public int Count; public Color Color; public Texture Tex; public Rect Uv; } private const float Cell = 104f; private const float Gap = 12f; private static ConfigEntry<string> _key; private static DropMenu _instance; private static string _preselect; private readonly List<Row> _rows = new List<Row>(); private bool _open; private string _selectedName; private int _qty = 1; private string _qtyText = "1"; private float _refreshAt; private string _status = ""; private Vector2 _scroll; private KeyCode _keyCode = (KeyCode)288; private int _cols = 1; private float _gridH = 400f; private bool _savedCursor; private bool _iconLogged; private CursorLockMode _lockBefore; private bool _visibleBefore; private GUIStyle _label; private GUIStyle _big; private GUIStyle _small; private GUIStyle _count; private GUIStyle _name; private GUIStyle _button; private GUIStyle _field; private GUIStyle _panel; private GUIStyle _card; private GUIStyle _slot; private GUIStyle _slotMe; public static bool IsOpen { get { if (Object.op_Implicit((Object)(object)_instance)) { return _instance._open; } return false; } } public static void Install(GameObject host, ConfigEntry<string> key) { if (!Object.op_Implicit((Object)(object)_instance)) { _key = key; _instance = host.AddComponent<DropMenu>(); ((Behaviour)_instance).enabled = false; _instance.ParseKey(); RoR2Application.onUpdate += PollKey; key.SettingChanged += delegate { _instance.ParseKey(); }; } } public static string OpenWith(string name) { if (!Object.op_Implicit((Object)(object)_instance)) { return Loc.T("Menu unavailable.", "Menu indisponível."); } if (!Object.op_Implicit((Object)(object)Run.instance)) { return Loc.T("Join a run first.", "Entre em uma run primeiro."); } if (!FeatureOn()) { return Loc.T("Drop is off (Drop.Enabled=false).", "Drop desligado (Drop.Enabled=false)."); } if (StatsPanel.IsOpen) { return Loc.T("Close the status screen first.", "Feche a tela de status primeiro."); } _preselect = (string.IsNullOrWhiteSpace(name) ? null : name.Trim()); _instance.SetOpen(open: true); return Loc.T("Drop items screen opened.", "Tela de soltar itens aberta."); } private void ParseKey() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!Enum.TryParse<KeyCode>(_key.Value, ignoreCase: true, out _keyCode)) { _keyCode = (KeyCode)288; } } private static DropFeature DropFeatureInstance() { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null) { return null; } foreach (Feature feature in instance.Features) { if (feature is DropFeature result) { return result; } } return null; } private static bool FeatureOn() { return DropFeatureInstance()?.Enabled ?? false; } private static int MaxQty(Row row) { DropFeature dropFeature = DropFeatureInstance(); return DropRules.ClampCount(int.MaxValue, row.Count, dropFeature?.MaxPerCommand ?? 0); } private static void PollKey() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) try { if (Object.op_Implicit((Object)(object)_instance) && Input.GetKeyDown(_instance._keyCode)) { if (_instance._open) { _instance.SetOpen(open: false); } else { OpenWith(null); } } } catch (Exception ex) { ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[DropMenu] falha na tecla: " + ex.Message)); } } } private void SetOpen(bool open) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (open != _open) { _open = open; ((Behaviour)this).enabled = open; if (open) { _status = ""; _refreshAt = 0f; _qty = 1; _qtyText = "1"; _lockBefore = Cursor.lockState; _visibleBefore = Cursor.visible; _savedCursor = true; } else if (_savedCursor) { Cursor.lockState = _lockBefore; Cursor.visible = _visibleBefore; _savedCursor = false; } } } private int SelectedIndex() { for (int i = 0; i < _rows.Count; i++) { if (_rows[i].Internal == _selectedName) { return i; } } return -1; } private void Select(int index) { if (index >= 0 && index < _rows.Count) { bool num = _rows[index].Internal != _selectedName; _selectedName = _rows[index].Internal; if (num) { SetQty(1); } EnsureVisible(index); } } private void EnsureVisible(int index) { float num = (float)(index / _cols) * 116f; if (num < _scroll.y) { _scroll.y = num; } else if (num + 104f > _scroll.y + _gridH) { _scroll.y = num + 104f - _gridH; } } private void Update() { try { if (!_open) { return; } if (!Object.op_Implicit((Object)(object)Run.instance)) { SetOpen(open: false); return; } if (Time.unscaledTime >= _refreshAt) { Refresh(); _refreshAt = Time.unscaledTime + 0.5f; } int num = SelectedIndex(); if (Input.GetKeyDown((KeyCode)275)) { Select((num >= 0) ? Mathf.Min(num + 1, _rows.Count - 1) : 0); } if (Input.GetKeyDown((KeyCode)276)) { Select((num >= 0) ? Mathf.Max(num - 1, 0) : 0); } if (Input.GetKeyDown((KeyCode)274)) { Select((num >= 0) ? Mathf.Min(num + _cols, _rows.Count - 1) : 0); } if (Input.GetKeyDown((KeyCode)273)) { Select((num >= 0) ? Mathf.Max(num - _cols, 0) : 0); } if (Input.GetKeyDown((KeyCode)61) || Input.GetKeyDown((KeyCode)270) || Input.GetKeyDown((KeyCode)280)) { ChangeQty(1); } if (Input.GetKeyDown((KeyCode)45) || Input.GetKeyDown((KeyCode)269) || Input.GetKeyDown((KeyCode)281)) { ChangeQty(-1); } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { DropSelected(); } } catch (Exception ex) { SetOpen(open: false); ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[DropMenu] falha: " + ex.Message)); } } } private void LateUpdate() { if (_open) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void ChangeQty(int delta) { SetQty(_qty + delta); } private void SetQty(int value) { int num = SelectedIndex(); _qty = ((num < 0) ? 1 : Mathf.Clamp(value, 1, Mathf.Max(1, MaxQty(_rows[num])))); _qtyText = _qty.ToString(); } private void OnQtyTyped(string text) { StringBuilder stringBuilder = new StringBuilder(); int i; for (i = 0; i < text.Length; i++) { char c = text[i]; if (c >= '0' && c <= '9') { stringBuilder.Append(c); } } _qtyText = stringBuilder.ToString(); if (_qtyText.Length > 0 && int.TryParse(_qtyText, out var result) && result != _qty) { SetQty(result); } else if (_qtyText.Length > 0 && !int.TryParse(_qtyText, out i)) { SetQty(int.MaxValue); } } private void Refresh() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) _rows.Clear(); LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); Inventory val = ((firstLocalUser != null && Object.op_Implicit((Object)(object)firstLocalUser.cachedMaster)) ? firstLocalUser.cachedMaster.inventory : null); if (!Object.op_Implicit((Object)(object)val)) { return; } Dictionary<ItemIndex, Texture> dictionary = null; foreach (ItemIndex item in val.itemAcquisitionOrder) { ItemDef itemDef = ItemCatalog.GetItemDef(item); int itemCountPermanent = val.GetItemCountPermanent(item); if (DropFeature.Droppable(itemDef) && itemCountPermanent > 0) { Color color = Color.white; ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier); if (Object.op_Implicit((Object)(object)itemTierDef)) { color = Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.colorIndex)); } ResolveIcon(itemDef, item, out var tex, out var uv); if (!Object.op_Implicit((Object)(object)tex)) { (dictionary ?? (dictionary = HudIcons())).TryGetValue(item, out tex); } _rows.Add(new Row { Name = Language.GetString(itemDef.nameToken), Internal = ((Object)itemDef).name, Count = itemCountPermanent, Color = color, Tex = tex, Uv = uv }); } } if (!_iconLogged && _rows.Count > 0) { _iconLogged = true; int count = _rows.FindAll((Row r) => !Object.op_Implicit((Object)(object)r.Tex)).Count; ManualLogSource log = Diag.Log; if (log != null) { log.LogInfo((object)string.Format("[DropMenu] ícones: {0} de {1} itens com imagem{2}", _rows.Count - count, _rows.Count, (count > 0) ? " (o resto mostra o nome)" : "")); } if (count > 0) { LogIconFields(ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(_rows.Find((Row x) => !Object.op_Implicit((Object)(object)x.Tex)).Internal))); } } if (_preselect != null) { int num = _rows.FindIndex((Row r) => string.Equals(r.Internal, _preselect, StringComparison.OrdinalIgnoreCase) || string.Equals(r.Name, _preselect, StringComparison.OrdinalIgnoreCase)); if (num < 0) { num = _rows.FindIndex((Row r) => r.Internal.IndexOf(_preselect, StringComparison.OrdinalIgnoreCase) >= 0 || r.Name.IndexOf(_preselect, StringComparison.OrdinalIgnoreCase) >= 0); } if (num >= 0) { Select(num); } else { _status = Loc.T("None of your items match '" + _preselect + "'.", "Nenhum item seu combina com '" + _preselect + "'."); } _preselect = null; } int num2 = SelectedIndex(); if (num2 < 0 && _rows.Count > 0) { _selectedName = _rows[0].Internal; num2 = 0; } if (num2 >= 0 && Mathf.Clamp(_qty, 1, Mathf.Max(1, MaxQty(_rows[num2]))) != _qty) { SetQty(_qty); } } private void DropSelected() { int num = SelectedIndex(); if (num < 0) { return; } Row row = _rows[num]; int num2 = Mathf.Min(_qty, MaxQty(row)); if (num2 <= 0) { _status = Loc.T("Nothing to drop (Drop.MaxPerCommand = 0?).", "Nada para soltar (Drop.MaxPerCommand = 0?)."); return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser == null || !Object.op_Implicit((Object)(object)firstLocalUser.currentNetworkUser)) { _status = Loc.T("No local user.", "Sem usuário local."); return; } Console.instance.SubmitCmd(firstLocalUser.currentNetworkUser, $"ror2meeeee_drop {row.Internal} {num2}", false); _status = Loc.T($"Dropping {num2}x {row.Name}...", $"Soltando {num2}x {row.Name}..."); row.Count -= num2; if (row.Count > 0) { _rows[num] = row; SetQty(_qty); } else { _rows.RemoveAt(num); } _refreshAt = Time.unscaledTime + 1f; } private void MakeStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01c5: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_023b: Expected O, but got Unknown if (_label == null) { _label = new GUIStyle(GUI.skin.label) { fontSize = 22, wordWrap = true }; _label.normal.textColor = StatsPanel.TextColor; _big = new GUIStyle(GUI.skin.label) { fontSize = 32, fontStyle = (FontStyle)1, wordWrap = true }; _big.normal.textColor = StatsPanel.HeadColor; _small = new GUIStyle(GUI.skin.label) { fontSize = 18, wordWrap = true }; _small.normal.textColor = StatsPanel.HintColor; _count = new GUIStyle(_small) { alignment = (TextAnchor)8, fontStyle = (FontStyle)1 }; _count.normal.textColor = Color.white; _name = new GUIStyle(_big) { fontSize = 28 }; _panel = StatsPanel.Frame("panel", 30); _card = StatsPanel.Frame("card", 16); _slot = StatsPanel.Frame("slot", 12); _slotMe = StatsPanel.Frame("card_me", 16); _button = new GUIStyle(_slot) { fontSize = 30, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _button.normal.textColor = Color.white; GUIStyle button = _button; GUIStyle button2 = _button; GUIStyleState val = new GUIStyleState { background = _slotMe.normal.background, textColor = StatsPanel.HeadColor }; GUIStyleState hover = val; button2.active = val; button.hover = hover; _field = new GUIStyle(_button) { fontSize = 40 }; _field.focused = new GUIStyleState { background = _slotMe.normal.background, textColor = Color.white }; GUIStyle field = _field; GUIStyle slotMe = _slotMe; GUIStyle button3 = _button; RectOffset val2 = new RectOffset(16, 16, 16, 16); RectOffset val3 = val2; button3.border = val2; RectOffset border = (slotMe.border = val3); field.border = border; } } private static void Border(Rect r, Color c, float t) { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = c; GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } private static void ResolveIcon(ItemDef def, ItemIndex idx, out Texture tex, out Rect uv) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) tex = null; uv = new Rect(0f, 0f, 1f, 1f); try { tex = def.pickupIconTexture; } catch (Exception) { } if (Object.op_Implicit((Object)(object)tex)) { return; } Sprite val = null; try { PickupDef pickupDef = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(idx)); if (pickupDef != null) { tex = pickupDef.iconTexture; if (Object.op_Implicit((Object)(object)tex)) { return; } val = pickupDef.iconSprite; } } catch (Exception) { } if (!Object.op_Implicit((Object)(object)val)) { val = def.pickupIconSprite; } if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.texture)) { Rect textureRect = val.textureRect; Texture2D val2 = (Texture2D)(object)(tex = (Texture)(object)val.texture); uv = new Rect(((Rect)(ref textureRect)).x / (float)((Texture)val2).width, ((Rect)(ref textureRect)).y / (float)((Texture)val2).height, ((Rect)(ref textureRect)).width / (float)((Texture)val2).width, ((Rect)(ref textureRect)).height / (float)((Texture)val2).height); } } private static Dictionary<ItemIndex, Texture> HudIcons() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Dictionary<ItemIndex, Texture> dictionary = new Dictionary<ItemIndex, Texture>(); try { ItemIcon[] array = Object.FindObjectsOfType<ItemIcon>(); foreach (ItemIcon val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.image) && Object.op_Implicit((Object)(object)val.image.texture) && (int)val.itemIndex != -1 && !dictionary.ContainsKey(val.itemIndex)) { dictionary[val.itemIndex] = val.image.texture; } } } catch (Exception ex) { ManualLogSource log = Diag.Log; if (log != null) { log.LogWarning((object)("[DropMenu] não consegui ler os ícones do HUD: " + ex.Message)); } } return dictionary; } private static void LogIconFields(ItemDef def) { try { StringBuilder stringBuilder = new StringBuilder("[DropMenu] campos de ícone de ItemDef (" + ((Object)def).name + "):"); FieldInfo[] fields = typeof(ItemDef).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0) { stringBuilder.Append(' ').Append(fieldInfo.Name).Append(':') .Append(fieldInfo.FieldType.Name) .Append((fieldInfo.GetValue(def) == null) ? "=nulo" : "=ok") .Append(';'); } } PropertyInfo[] properties = typeof(ItemDef).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name.IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0 && propertyInfo.GetIndexParameters().Length == 0) { object obj = null; try { obj = propertyInfo.GetValue(def, null); } catch (Exception) { } stringBuilder.Append(' ').Append(propertyInfo.Name).Append(':') .Append(propertyInfo.PropertyType.Name) .Append((obj == null) ? "=nulo" : "=ok") .Append(';'); } } ManualLogSource log = Diag.Log; if (log != null) { log.LogInfo((object)stringBuilder.ToString()); } } catch (Exception ex2) { ManualLogSource log2 = Diag.Log; if (log2 != null) { log2.LogWarning((object)("[DropMenu] diagnóstico de ícones falhou: " + ex2.Message)); } } } private static void DrawIcon(Rect r, Texture tex, Rect uv, Color fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)tex)) { GUI.DrawTextureWithTexCoords(r, tex, uv); return; } Color color = GUI.color; GUI.color = new Color(fallback.r * 0.35f, fallback.g * 0.35f, fallback.b * 0.35f, 1f); GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } private void OnGUI() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) if (!_open) { return; } MakeStyles(); float num = Mathf.Max(0.8f, (float)Screen.height / 1080f) * 1.15f; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; float num4 = Mathf.Min(1180f, num2 - 60f); float num5 = Mathf.Min(720f, num3 - 60f); Rect val = default(Rect); ((Rect)(ref val))..ctor((num2 - num4) / 2f, (num3 - num5) / 2f, num4, num5); GUI.Box(val, GUIContent.none, _panel); GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 12f, num4 - 48f, 44f), Loc.T("DROP ITEMS", "SOLTAR ITENS"), _big); float num6 = num4 * 0.58f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 70f, num6, num5 - 150f); _gridH = ((Rect)(ref val2)).height; _cols = Mathf.Max(1, (int)((((Rect)(ref val2)).width - 24f) / 116f)); int num7 = Mathf.Max(1, Mathf.CeilToInt((float)_rows.Count / (float)_cols)); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, 0f, (float)_cols * 116f, (float)num7 * 116f); int num8 = SelectedIndex(); if (_rows.Count == 0) { GUI.Label(val2, Loc.T("You have no items that can be dropped.", "Você não tem itens que possam ser soltos."), _label); } _scroll = GUI.BeginScrollView(val2, _scroll, val3); Rect val4 = default(Rect); for (int i = 0; i < _rows.Count; i++) { ((Rect)(ref val4))..ctor((float)(i % _cols) * 116f, (float)(i / _cols) * 116f, 104f, 104f); GUI.Box(val4, GUIContent.none, (i == num8) ? _slotMe : _slot); DrawIcon(new Rect(((Rect)(ref val4)).x + 8f, ((Rect)(ref val4)).y + 8f, 88f, 88f), _rows[i].Tex, _rows[i].Uv, _rows[i].Color); if (!Object.op_Implicit((Object)(object)_rows[i].Tex)) { GUI.Label(new Rect(((Rect)(ref val4)).x + 6f, ((Rect)(ref val4)).y + 6f, 92f, 68f), _rows[i].Name, _small); } Border(new Rect(((Rect)(ref val4)).x + 3f, ((Rect)(ref val4)).y + 3f, ((Rect)(ref val4)).width - 6f, ((Rect)(ref val4)).height - 6f), _rows[i].Color * ((i == num8) ? 1f : 0.75f), (i == num8) ? 4f : 2f); GUI.Label(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).yMax - 30f, ((Rect)(ref val4)).width - 6f, 28f), "x" + _rows[i].Count, _count); if (GUI.Button(val4, GUIContent.none, GUIStyle.none)) { Select(i); } } GUI.EndScrollView(); float num9 = ((Rect)(ref val)).x + 24f + num6 + 24f; float num10 = ((Rect)(ref val)).xMax - num9 - 24f; GUI.Box(new Rect(num9 - 12f, ((Rect)(ref val)).y + 62f, num10 + 24f, num5 - 140f), GUIContent.none, _card); if (num8 >= 0) { Row row = _rows[num8]; GUI.Box(new Rect(num9, ((Rect)(ref val)).y + 74f, 150f, 150f), GUIContent.none, _slot); DrawIcon(new Rect(num9 + 8f, ((Rect)(ref val)).y + 82f, 134f, 134f), row.Tex, row.Uv, row.Color); _name.normal.textColor = row.Color; GUI.Label(new Rect(num9 + 164f, ((Rect)(ref val)).y + 74f, num10 - 164f, 100f), row.Name, _name); GUI.Label(new Rect(num9 + 164f, ((Rect)(ref val)).y + 170f, num10 - 164f, 50f), Loc.T($"You have {row.Count}", $"Você tem {row.Count}"), _label); int num11 = MaxQty(row); GUI.Label(new Rect(num9, ((Rect)(ref val)).y + 240f, num10, 40f), Loc.T($"Amount to drop (max. {num11} at a time)", $"Quantidade a soltar (máx. {num11} por vez)"), _label); string text = GUI.TextField(new Rect(num9, ((Rect)(ref val)).y + 284f, num10, 72f), _qtyText, 6, _field); if (text != _qtyText) { OnQtyTyped(text); } float num12 = (num10 - 24f) / 4f; float num13 = ((Rect)(ref val)).y + 366f; if (GUI.Button(new Rect(num9, num13, num12, 64f), "−1", _button)) { ChangeQty(-1); } if (GUI.Button(new Rect(num9 + (num12 + 8f), num13, num12, 64f), "+1", _button)) { ChangeQty(1); } if (GUI.Button(new Rect(num9 + 2f * (num12 + 8f), num13, num12, 64f), "+5", _button)) { ChangeQty(5); } if (GUI.Button(new Rect(num9 + 3f * (num12 + 8f), num13, num12, 64f), "+10", _button)) { ChangeQty(10); } if (GUI.Button(new Rect(num9, num13 + 80f, num10, 90f), Loc.T($"DROP {_qty}x", $"SOLTAR {_qty}x"), _button)) { DropSelected(); } } else { GUI.Label(new Rect(num9, ((Rect)(ref val)).y + 80f, num10, 120f), Loc.T("Click an item to choose it.", "Clique em um item para escolher."), _label); } GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).yMax - 66f, num4 - 48f, 56f), ((_status.Length > 0) ? (_status + "\n") : "") + Loc.T("Click the item · arrows move · type or +/- amount · Enter drops · " + _key.Value + " closes", "Clique no item · setas movem · digite ou +/- quantidade · Enter solta · " + _key.Value + " fecha"), _small); GUI.matrix = matrix; } } internal static class DroppedGrants { private static readonly Dictionary<ItemIndex, int> Pending = new Dictionary<ItemIndex, int>(); private static int _frame = -1; private static ItemIndex _index = (ItemIndex)(-1); private static bool _result; public static void Note(ItemIndex index, int count) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (count > 0) { Pending.TryGetValue(index, out var value); Pending[index] = value + count; } } public static bool IsDropped(ItemIndex index) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) int frameCount = Time.frameCount; if (frameCount == _frame && index == _index) { return _result; } _frame = frameCount; _index = index; _result = false; if (Pending.TryGetValue(index, out var value) && value > 0) { if (value == 1) { Pending.Remove(index); } else { Pending[index] = value - 1; } _result = true; } return _result; } public static void Clear() { Pending.Clear(); _frame = -1; } } public abstract class Feature { private readonly ConfigEntry<bool> _enabledEntry; private int _failureCount; private bool _shutdownByFailures; private readonly List<string> _hookResults = new List<string>(); public string Name { get; } public bool Enabled { get; private set; } public bool ConfigEnabled { get { if (_enabledEntry != null) { return _enabledEntry.Value; } return true; } } internal ConfigEntry<bool> EnabledEntry => _enabledEntry; public int FailureCount => _failureCount; public bool ShutdownByFailures => _shutdownByFailures; public IReadOnlyList<string> HookResults => _hookResults; protected Cfg Cfg { get; } protected ManualLogSource Log { get; } protected Feature(string name, Cfg cfg, ManualLogSource log, string summaryEn, string summaryPt, bool enabledByDefault = false) : this(name, cfg, log, cfg.BindEnabled(name, summaryEn, summaryPt, enabledByDefault)) { } protected Feature(string name, Cfg cfg, ManualLogSource log, ConfigEntry<bool> enabledEntry) { Name = name; Cfg = cfg; Log = log; _enabledEntry = enabledEntry; } public void Enable() { if (Enabled || _shutdownByFailures) { return; } _hookResults.Clear(); try { OnEnable(); Enabled = true; Log.LogInfo((object)(Name + ": hooks registrados")); } catch (Exception arg) { Log.LogError((object)$"{Name}: falha ao registrar hooks, feature desligada: {arg}"); RemoveHooksQuietly(); } } public void Disable() { if (Enabled) { Enabled = false; RemoveHooksQuietly(); } } public virtual void ResetRunState() { } internal void ResetRunStateSafe() { try { ResetRunState(); } catch (Exception ex) { if (Enabled) { Fail(ex); } else { Log.LogError((object)$"{Name}: falha em ResetRunState (feature desligada, não contada): {ex}"); } } } protected void Fail(Exception e) { if (!_shutdownByFailures) { _failureCount++; Diag.Exceptions++; Log.LogError((object)$"{Name}: falha {_failureCount}/{Cfg.MaxFailures}: {e}"); if (_failureCount >= Cfg.MaxFailures && !_shutdownByFailures) { _shutdownByFailures = true; Disable(); Log.LogWarning((object)$"{Name}: desligada após {_failureCount} falhas."); } } } protected void Track(string hookName, Action register) { try { register(); _hookResults.Add(hookName + ": ok"); } catch (Exception ex) { _hookResults.Add(hookName + ": FALHA (" + ex.GetType().Name + ": " + ex.Message + ")"); throw; } } protected abstract void OnEnable(); protected abstract void OnDisable(); private void RemoveHooksQuietly() { try { OnDisable(); } catch (Exception arg) { Log.LogError((object)$"{Name}: falha ao remover hooks: {arg}"); } } } internal static class ItemClassifier { public static bool IsUnique(ItemIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((int)index != -1) { if (!TaxReliefItems.IsReliefItem(index) && index != CanoItem.Index && index != HordeItem.Index) { return index == TempestHealthItem.Index; } return true; } return false; } public static ItemKind Classify(ItemDef def, bool temporaryPickup) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected I4, but got Unknown if (temporaryPickup) { return (ItemKind)6; } if (IsUnique(def.itemIndex)) { return (ItemKind)9; } if (def.ContainsTag((ItemTag)10)) { return (ItemKind)7; } ItemTier tier = def.tier; switch ((int)tier) { case 0: return (ItemKind)0; case 1: return (ItemKind)1; case 2: return (ItemKind)2; case 4: return (ItemKind)3; case 3: return (ItemKind)4; case 6: case 7: case 8: case 9: return (ItemKind)5; default: return (ItemKind)10; } } } internal static class Loc { public const string PtBr = "pt-BR"; public static readonly CultureInfo PtCulture = CultureInfo.GetCultureInfo("pt-BR"); public static readonly CultureInfo EnCulture = CultureInfo.InvariantCulture; public static bool IsPt => Language.currentLanguageName == "pt-BR"; public static string T(string en, string pt) { if (!IsPt) { return en; } return pt; } public static void Add(string token, string en, string pt) { LanguageAPI.Add(token, en); LanguageAPI.Add(token, pt, "pt-BR"); } public static void Broadcast(string token, params string[] args) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = token, paramTokens = args }); } } internal static class MainThreadSampler { private const int Samples = 20; private const int SampleIntervalMs = 50; private const int StackBytes = 2048; private const int ChainDepth = 4; private const uint ThreadSuspendResume = 2u; private const uint ThreadGetContext = 8u; private const uint ThreadQueryInformation = 64u; private const uint ContextControl = 1048577u; private const int ContextSize = 1232; private const int ContextFlagsOffset = 48; private const int RspOffset = 152; private const int RipOffset = 248; private static IntPtr _thread; private static IntPtr _contextRaw; private static IntPtr _context; private static IntPtr _domain; private static readonly ulong[] Rips = new ulong[20]; private static readonly byte[] Stacks = new byte[40960]; private static readonly bool[] Valid = new bool[20]; private static readonly Dictionary<IntPtr, string> Names = new Dictionary<IntPtr, string>(); private static string _disabled; private const string Mono = "mono-2.0-bdwgc"; public static void Init() { try { if (IntPtr.Size != 8) { _disabled = "só em 64 bits"; return; } _thread = OpenThread(74u, inherit: false, GetCurrentThreadId()); if (_thread == IntPtr.Zero) { _disabled = "OpenThread falhou"; return; } _contextRaw = Marshal.AllocHGlobal(1248); _context = new IntPtr((_contextRaw.ToInt64() + 15) & -16); _domain = mono_get_root_domain(); } catch (Exception ex) { _disabled = ex.GetType().Name; } } public static string Sample() { if (_disabled != null) { return "amostrador desligado (" + _disabled + ")"; } try { for (int i = 0; i < 20; i++) { Valid[i] = Capture(i); Thread.Sleep(50); } return Summarize(); } catch (Exception ex) { _disabled = ex.GetType().Name; return "amostrador falhou: " + ex.Message; } } private static bool Capture(int i) { if (SuspendThread(_thread) == uint.MaxValue) { return false; } bool result = false; try { Marshal.WriteInt32(_context, 48, 1048577); if (GetThreadContext(_thread, _context)) { Rips[i] = (ulong)Marshal.ReadInt64(_context, 248); Marshal.Copy(new IntPtr(Marshal.ReadInt64(_context, 152)), Stacks, i * 2048, 2048); result = true; } } finally { ResumeThread(_thread); } return result; } private static string Summarize() { Dictionary<string, int> dictionary = new Dictionary<string, int>(); int num = 0; List<string> list = new List<string>(4); for (int i = 0; i < 20; i++) { if (!Valid[i]) { continue; } num++; list.Clear(); AddFrame(list, Rips[i]); for (int j = 0; j + 8 <= 2048; j += 8) { if (list.Count >= 4) { break; } AddFrame(list, BitConverter.ToUInt64(Stacks, i * 2048 + j)); } string key = ((list.Count > 0) ? string.Join(" ← ", list) : "(fora de código C#: nativo do Unity/Mono)"); dictionary.TryGetValue(key, out var value); dictionary[key] = value + 1; } if (num == 0) { return "nenhuma amostra da thread principal"; } List<KeyValuePair<string, int>> list2 = new List<KeyValuePair<string, int>>(dictionary); list2.Sort((KeyValuePair<string, int> a, KeyValuePair<string, int> b) => b.Value.CompareTo(a.Value)); StringBuilder stringBuilder = new StringBuilder($"thread principal ({num} amostras): "); for (int num2 = 0; num2 < list2.Count && num2 < 3; num2++) { stringBuilder.Append((num2 == 0) ? "" : " | ").Append(list2[num2].Value).Append("x ") .Append(list2[num2].Key); } return stringBuilder.ToString(); } private static void AddFrame(List<string> frames, ulong address) { if (address < 65536) { return; } IntPtr intPtr = mono_jit_info_table_find(_domain, new IntPtr((long)address)); if (intPtr == IntPtr.Zero) { return; } IntPtr intPtr2 = mono_jit_info_get_method(intPtr); if (intPtr2 == IntPtr.Zero) { return; } if (!Names.TryGetValue(intPtr2, out var value)) { IntPtr intPtr3 = mono_method_full_name(intPtr2, 0); value = ((intPtr3 != IntPtr.Zero) ? Marshal.PtrToStringAnsi(intPtr3) : "?"); if (intPtr3 != IntPtr.Zero) { mono_free(intPtr3); } Names[intPtr2] = value; } if (frames.Count == 0 || frames[frames.Count - 1] != value) { frames.Add(value); } } [DllImport("kernel32.dll")] private static extern uint GetCurrentThreadId(); [DllImport("kernel32.dll", SetLastError = true)] private static extern IntPtr OpenThread(uint access, bool inherit, uint threadId); [DllImport("kernel32.dll", SetLastError = true)] private static extern uint SuspendThread(IntPtr thread); [DllImport("kernel32.dll", SetLastError = true)] private static extern uint ResumeThread(IntPtr thread); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool GetThreadContext(IntPtr thread, IntPtr context); [DllImport("mono-2.0-bdwgc")] private static extern IntPtr mono_get_root_domain(); [DllImport("mono-2.0-bdwgc")] private static extern IntPtr mono_jit_info_table_find(IntPtr domain, IntPtr address); [DllImport("mono-2.0-bdwgc")] private static extern IntPtr mono_jit_info_get_method(IntPtr jitInfo); [DllImport("mono-2.0-bdwgc")] private static extern IntPtr mono_method_full_name(IntPtr method, int signature); [DllImport("mono-2.0-bdwgc")] private static extern void mono_free(IntPtr p); } internal static class ModItem { public static ItemDef Register(string name, string token, ItemTier tier, ItemTag[] tags, string iconResource, Color32 iconFallback, (string Name, string Pickup, string Desc, string Lore) en, (string Name, string Pickup, string Desc, string Lore) pt, ManualLogSource log, string modelKey = null) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown try { ItemDef val = ScriptableObject.CreateInstance<ItemDef>(); ((Object)val).name = name; val.nameToken = token + "_NAME"; val.pickupToken = token + "_PICKUP"; val.descriptionToken = token + "_DESC"; val.loreToken = token + "_LORE"; val.canRemove = true; val.hidden = false; val.tags = tags; typeof(ItemDef).GetField("deprecatedTier", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val, tier); val.pickupIconSprite = TitheArtifact.LoadIcon(iconResource, iconFallback); val.pickupModelPrefab = Model(modelKey, name, log); Loc.Add(token + "_NAME", en.Name, pt.Name); Loc.Add(token + "_PICKUP", en.Pickup, pt.Pickup); Loc.Add(token + "_DESC", en.Desc, pt.Desc); Loc.Add(token + "_LORE", en.Lore, pt.Lore); if (!ItemAPI.Add(new CustomItem(val, Array.Empty<ItemDisplayRule>()))) { log.LogError((object)(name + ": ItemAPI.Add recusou o item.")); return null; } log.LogInfo((object)(name + ": item registrado.")); return val; } catch (Exception arg) { log.LogError((object)$"{name}: falha ao registrar o item (o plugin segue sem ele): {arg}"); return null; } } public static void Corrupt(ItemDef normal, ItemDef voidItem, ManualLogSource log) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)normal) || !Object.op_Implicit((Object)(object)voidItem)) { return; } try { ItemRelationshipType val = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion(); if (!Object.op_Implicit((Object)(object)val)) { log.LogWarning((object)(((Object)voidItem).name + ": tipo ContagiousItem indisponível; não corrompe.")); return; } ItemRelationshipProvider val2 = ScriptableObject.CreateInstance<ItemRelationshipProvider>(); ((Object)val2).name = ((Object)voidItem).name + "Contagion"; val2.relationshipType = val; val2.relationships = (Pair[])(object)new Pair[1] { new Pair { itemDef1 = normal, itemDef2 = voidItem } }; if (!ContentAddition.AddItemRelationshipProvider(val2)) { log.LogWarning((object)(((Object)voidItem).name + ": ContentAddition recusou a corrupção.")); } } catch (Exception ex) { log.LogWarning((object)(((Object)voidItem).name + ": falha ao registrar a corrupção (itens seguem sem ela): " + ex.Message)); } } public static GameObject Model(string key, string owner, ManualLogSource log) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (key != null) { try { GameObject val = Addressables.LoadAssetAsync<GameObject>((object)key).WaitForCompletion(); if (Object.op_Implicit((Object)(object)val)) { return val; } log.LogWarning((object)(owner + ": modelo " + key + " indisponível; usando o placeholder.")); } catch (Exception ex) { log.LogWarning((object)(owner + ": modelo " + key + " indisponível (" + ex.GetType().Name + "); usando o placeholder.")); } } try { return LegacyResourcesAPI.Load<GameObject>("Prefabs/PickupModels/PickupMystery"); } catch (Exception ex2) { log.LogWarning((object)(owner + ": modelo placeholder indisponível (" + ex2.GetType().Name + "); o item ficará invisível no chão.")); return null; } } } internal static class ModOptions { private static readonly string[] RestartKeys = new string[4] { "ProbeEmptyHook", "ProbeAutoWindowSeconds", "ScalingValue", "ConfigVersion" }; private const string DescToken = "ROR2MEEEEE_OPTIONS_DESC"; [MethodImpl(MethodImplOptions.NoInlining)] public static void Register(Cfg cfg, ManualLogSource log) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) try { Loc.Add("ROR2MEEEEE_OPTIONS_DESC", "Item multiplier and sharing, adjustable difficulty with progression between runs, the Tempest difficulty, the Tithe and Taxade artifacts (with the Capitalism items), particle limiting and measurement tools. Each section has an Enabled that explains what it does. Only the host needs to configure; changes apply immediately or from the next stage.", "Multiplicador e compartilhamento de itens, dificuldade ajustável com progressão entre runs, a dificuldade Tormenta, artefatos do Dízimo e Taxade (com os itens Capitalismo), corte de partículas e ferramentas de medição. Cada seção tem um Enabled que explica o que ela faz. Só o host precisa configurar; alterações valem na hora ou a partir do próximo estágio."); ModSettingsManager.SetModDescriptionToken("ROR2MEEEEE_OPTIONS_DESC", "com.sawcunha.ror2meeeee", "Ror2Meeeee"); Sprite val = TitheArtifact.LoadIcon("mod_icon.png", default(Color32)); if (Object.op_Implicit((Object)(object)val)) { ModSettingsManager.SetModIcon(val, "com.sawcunha.ror2meeeee", "Ror2Meeeee"); } int num = 0; foreach (ConfigEntryBase entry in cfg.Entries) { BaseOption val2 = Create(entry); if (val2 != null) { AddLocalized(val2, entry, cfg); num++; } } log.LogInfo((object)$"Opções na tela de mods: {num} entradas."); } catch (Exception ex) { log.LogWarning((object)("Tela de mods indisponível (o plugin segue; use o .cfg): " + ex.GetType().Name + ": " + ex.Message)); } } private static void AddLocalized(BaseOption option, ConfigEntryBase entry, Cfg cfg) { ConfigDefinition definition = entry.Definition; string text = ("ROR2MEEEEE_OPTION_" + definition.Section + "_" + definition.Key).Replace(' ', '_').Replace('.', '_').ToUpperInvariant(); LanguageAPI.Add(text + "_NAME", definition.Key); Loc.Add(text + "_DESC", entry.Description.Description, cfg.DescriptionPt(entry)); ModSettingsManager.AddOption(option, "com.sawcunha.ror2meeeee", "Ror2Meeeee", text + "_NAME", text + "_DESC"); } private static BaseOption Create(ConfigEntryBase entry) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown bool flag = Array.IndexOf(RestartKeys, entry.Definition.Key) >= 0; if (!(entry is ConfigEntry<bool> val)) { if (!(entry is ConfigEntry<int> val2)) { if (!(entry is ConfigEntry<float> val3)) { if (entry is ConfigEntry<string> val4) { return (BaseOption)new StringInputFieldOption(val4, flag); } if (!entry.SettingType.IsEnum) { return null; } return (BaseOption)new ChoiceOption(entry, flag); } return (BaseOption)new FloatFieldOption(val3, flag); } return (BaseOption)new IntFieldOption(val2, flag); } return (BaseOption)new CheckBoxOption(val, flag); } } internal static class MoneyHub { [CompilerGenerated] private static class <>O { public static hook_GiveMoney_uint_bool <0>__OnGiveMoney; } private static Func<CharacterMaster, uint, uint> _before; private static Action<CharacterMaster, uint> _after; private static bool _hooked; public static long Calls; private static long _sampleTicks; private static long _samples; public static double AverageMicros { get { if (_samples != 0L) { return (double)_sampleTicks * 1000000.0 / (double)Stopwatch.Frequency / (double)_samples; } return 0.0; } } public static void SetBefore(Func<CharacterMaster, uint, uint> f) { _before = f; Sync(); } public static void SetAfter(Action<CharacterMaster, uint> f) { _after = f; Sync(); } private static void Sync() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown bool flag = _before != null || _after != null; if (flag == _hooked) { return; } if (flag) { object obj = <>O.<0>__OnGiveMoney; if (obj == null) { hook_GiveMoney_uint_bool val = OnGiveMoney; <>O.<0>__OnGiveMoney = val; obj = (object)val; } CharacterMaster.GiveMoney_uint_bool += (hook_GiveMoney_uint_bool)obj; } else { object obj2 = <>O.<0>__OnGiveMoney; if (obj2 == null) { hook_GiveMoney_uint_bool val2 = OnGiveMoney; <>O.<0>__OnGiveMoney = val2; obj2 = (object)val2; } CharacterMaster.GiveMoney_uint_bool -= (hook_GiveMoney_uint_bool)obj2; } _hooked = flag; } private static void OnGiveMoney(orig_GiveMoney_uint_bool orig, CharacterMaster self, uint amount, bool bypassStatManager) { uint arg = amount; bool num = (++Calls & 0xF) == 0; long num2 = (num ? Stopwatch.GetTimestamp() : 0); Func<CharacterMaster, uint, uint> before = _before; if (before != null) { amount = before(self, amount); } long num3 = (num ? Stopwatch.GetTimestamp() : 0); orig.Invoke(self, amount, bypassStatManager); long num4 = (num ? Stopwatch.GetTimestamp() : 0); _after?.Invoke(self, arg); if (num) { _sampleTicks += num3 - num2 + (Stopwatch.GetTimestamp() - num4); _samples++; } } } internal sealed class Overlay : MonoBehaviour { private sealed class Marker { public object Key; public Vector3 Position; public Transform Follow; public string Label; public Color Color; public int Size; } private static Overlay _instance; private static readonly List<Marker> Markers = new List<Marker>(); private static string _banner; private static float _bannerUntil; private static GUIStyle _style; public static void Install(GameObject host) { if (!Object.op_Implicit((Object)(object)_instance)) { _instance = host.AddComponent<Overlay>(); } } public static void Banner(string text, float seconds = 8f) { _banner = text; _bannerUntil = Time.unscaledTime + seconds; } public static void Mark(object key, Vector3 position, string label, Color color, int size = 18) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Add(key, position, null, label, color, size); } public static void Mark(object key, Transform follow, string label, Color color, int size = 18) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Add(key, Vector3.zero, follow, label, color, size); } public static void Unmark(object key) { Markers.RemoveAll((Marker m) => m.Key == key); } public static void Clear() { Markers.Clear(); } private static void Add(object key, Vector3 position, Transform follow, string label, Color color, int size) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Unmark(key); Markers.Add(new Marker { Key = key, Position = position, Follow = follow, Label = label, Color = color, Size = size }); } private static Camera SceneCamera() { ReadOnlyCollection<CameraRigController> readOnlyInstancesList = CameraRigController.readOnlyInstancesList; for (int i = 0; i < readOnlyInstancesList.Count; i++) { if (Object.op_Implicit((Object)(object)readOnlyInstancesList[i]) && Object.op_Implicit((Object)(object)readOnlyInstancesList[i].sceneCam) && ((Behaviour)readOnlyInstancesList[i].sceneCam).enabled) { return readOnlyInstancesList[i].sceneCam; } } return Camera.main; } private void OnGUI() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) bool flag = _banner != null && Time.unscaledTime < _bannerUntil; if (!flag && Markers.Count == 0) { return; } if (_style == null) { _style = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 18, fontStyle = (FontStyle)1, wordWrap = false }; } if (flag) { DrawText(new Rect(0f, (float)Screen.height * 0.12f, (float)Screen.width, 40f), _banner, new Color(1f, 0.9f, 0.4f), 18); } if (Markers.Count == 0) { return; } Camera val = SceneCamera(); if (!Object.op_Implicit((Object)(object)val)) { return; } for (int num = Markers.Count - 1; num >= 0; num--) { Marker marker = Markers[num]; if ((Object)(object)marker.Follow != (Object)null && !Object.op_Implicit((Object)(object)marker.Follow)) { Markers.RemoveAt(num); } else { Vector3 val2 = (Object.op_Implicit((Object)(object)marker.Follow) ? (marker.Follow.position + Vector3.up * 2f) : (marker.Position + Vector3.up * 2f)); Vector3 val3 = val.WorldToScreenPoint(val2); bool num2 = val3.z < 0f; if (num2) { val3.x = (float)Screen.width - val3.x; val3.y = (float)Screen.height - val3.y; } bool num3 = !num2 && val3.x > 60f && val3.x < (float)Screen.width - 60f && val3.y > 60f && val3.y < (float)Screen.height - 60f; float num4 = Mathf.Clamp(val3.x, 60f, (float)Screen.width - 60f); float num5 = Mathf.Clamp(val3.y, 60f, (float)Screen.height - 60f); string text = string.Concat(str2: $" ({Vec