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 StarTrophies v2.1.4
StarTrophies.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("StarTrophies")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("2.1.1.0")] [assembly: AssemblyInformationalVersion("2.1.1")] [assembly: AssemblyProduct("StarTrophies")] [assembly: AssemblyTitle("StarTrophies")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace StarTrophies { [BepInPlugin("com.startrophies.valheim", "StarTrophies", "2.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class StarTrophiesPlugin : BaseUnityPlugin { public const string PluginGUID = "com.startrophies.valheim"; public const string PluginName = "StarTrophies"; public const string PluginVersion = "2.1.4"; public static readonly string[] NamePrefix = new string[2] { "★ ", "★★ " }; public static readonly HashSet<string> KnownNonStarableTrophies = new HashSet<string> { "TrophyAbomination", "TrophyGolem", "TrophySerpent", "TrophyWraith", "TrophyLox", "TrophyDeathsquito" }; public static ConfigEntry<float> ConfigValueMul1; public static ConfigEntry<float> ConfigValueMul2; public static ConfigEntry<float> ConfigScale1; public static ConfigEntry<float> ConfigScale2; public static ConfigEntry<float> ConfigCommonTrophyChanceCap; public static ConfigEntry<string> ConfigDebugDumpTrophies; public static ConfigEntry<bool> ConfigDebugDropTable; private static bool _dropChancesReduced = false; private Harmony _harmony; private static bool _trophiesCreated = false; public static bool IsDebugDumpTrophy(string trophyName) { if (ConfigDebugDumpTrophies == null || string.IsNullOrEmpty(ConfigDebugDumpTrophies.Value)) { return false; } string[] array = ConfigDebugDumpTrophies.Value.Split(new char[1] { ',' }); foreach (string text in array) { if (text.Trim().Equals(trophyName, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown BindConfig(); _harmony = new Harmony("com.startrophies.valheim"); _harmony.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void BindConfig() { ConfigValueMul1 = ((BaseUnityPlugin)this).Config.Bind<float>("1 Star", "ValueMultiplier", 2f, "Множитель цены для 1★ трофеев"); ConfigValueMul2 = ((BaseUnityPlugin)this).Config.Bind<float>("2 Stars", "ValueMultiplier", 4f, "Множитель цены для 2★ трофеев"); ConfigScale1 = ((BaseUnityPlugin)this).Config.Bind<float>("1 Star", "SizeMultiplier", 1.15f, "Множитель размера модели на стойке/в мире для 1★"); ConfigScale2 = ((BaseUnityPlugin)this).Config.Bind<float>("2 Stars", "SizeMultiplier", 1.4f, "Множитель размера модели на стойке/в мире для 2★"); ConfigCommonTrophyChanceCap = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CommonTrophyDropChanceCap", 0.05f, "Максимальный шанс выпадения трофея у обычных существ (0.05 = 5%). Понижает только те трофеи, у которых ванильный шанс выше этого значения — уже редкие трофеи, боссов и гарантированные (100%) трофеи не трогает."); ConfigDebugDumpTrophies = ((BaseUnityPlugin)this).Config.Bind<string>("Debug", "DumpTrophies", "", "Через запятую: для этих трофеев в лог пишется подробный разбор рендеров, материалов, шейдеров и LevelEffects моба. Оставьте пустым, чтобы отключить."); ConfigDebugDropTable = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogDropTable", false, "Писать в лог таблицу трофеев: шанс до/после, множитель звёзд, псевдослучайный дроп."); } private static void OnVanillaPrefabsAvailable() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; if (!_trophiesCreated) { CreateStarTrophies(); _trophiesCreated = true; if (!_dropChancesReduced) { ReduceCommonTrophyDropChances(); _dropChancesReduced = true; } } } public static void CreateStarTrophies() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Invalid comparison between Unknown and I4 //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Expected O, but got Unknown List<GameObject> list = new List<GameObject>(); Dictionary<string, Object> prefabs = Cache.GetPrefabs(typeof(GameObject)); if (prefabs != null) { foreach (KeyValuePair<string, Object> item in prefabs) { Object value = item.Value; GameObject val = (GameObject)(object)((value is GameObject) ? value : null); if (!((Object)(object)val == (Object)null)) { ItemDrop component = val.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && (int)component.m_itemData.m_shared.m_itemType == 13 && !KnownNonStarableTrophies.Contains(((Object)val).name)) { list.Add(val); } } } } if (list.Count == 0 && (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null) { foreach (GameObject item2 in ObjectDB.instance.m_items) { if (!((Object)(object)item2 == (Object)null)) { ItemDrop component2 = item2.GetComponent<ItemDrop>(); if (!((Object)(object)component2 == (Object)null) && component2.m_itemData != null && (int)component2.m_itemData.m_shared.m_itemType == 13 && !KnownNonStarableTrophies.Contains(((Object)item2).name)) { list.Add(item2); } } } } if (list.Count == 0) { return; } float[] array = new float[2] { ConfigValueMul1.Value, ConfigValueMul2.Value }; float[] array2 = new float[2] { ConfigScale1.Value, ConfigScale2.Value }; int num = 0; foreach (GameObject item3 in list) { ItemDrop component3 = item3.GetComponent<ItemDrop>(); string name = component3.m_itemData.m_shared.m_name; string text = LocalizationManager.Instance.TryTranslate(name); if (string.IsNullOrEmpty(text)) { text = (name.StartsWith("$") ? name.Substring(1) : name); } for (int i = 0; i < 2; i++) { string text2 = $"{((Object)item3).name}_Star{i + 1}"; if ((Object)(object)PrefabManager.Instance.GetPrefab(text2) != (Object)null) { continue; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(text2, item3); if (!((Object)(object)val2 == (Object)null)) { ItemDrop component4 = val2.GetComponent<ItemDrop>(); if (!((Object)(object)component4 == (Object)null) && component4.m_itemData != null) { component4.m_itemData.m_dropPrefab = val2; val2.transform.localScale = item3.transform.localScale * array2[i]; SharedData val3 = SharedDataCopy.ShallowCopy<SharedData>(component3.m_itemData.m_shared); val3.m_name = NamePrefix[i] + text; val3.m_value = Mathf.RoundToInt((float)val3.m_value * array[i]); val3.m_maxQuality = 3; val3.m_scaleByQuality = (array2[i] - 1f) / ((float)i + 1f); component4.m_itemData.m_quality = i + 2; component4.m_itemData.m_shared = val3; NativeStarColorizer.ApplyNativeStarColor(item3, val2, i); ItemManager.Instance.AddItem(new CustomItem(val2, true)); } } } num++; } Logger.LogInfo((object)$"[StarTrophies] Нативные звездные трофеи успешно созданы для {num} видов ({num * 2} предметов)."); } private static void ReduceCommonTrophyDropChances() { float cap = ConfigCommonTrophyChanceCap.Value; int changedEntries = 0; int changedCreatures = 0; HashSet<GameObject> seen = new HashSet<GameObject>(); SortedDictionary<string, string> report = new SortedDictionary<string, string>(); int levelMulCount = 0; Dictionary<string, Object> prefabs = Cache.GetPrefabs(typeof(GameObject)); if (prefabs != null) { foreach (KeyValuePair<string, Object> item in prefabs) { Object value = item.Value; ProcessPrefab((GameObject)(object)((value is GameObject) ? value : null)); } } if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs != null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { ProcessPrefab(prefab); } } CharacterDrop[] array = Resources.FindObjectsOfTypeAll<CharacterDrop>(); foreach (CharacterDrop val in array) { if ((Object)(object)val != (Object)null) { ProcessPrefab(((Component)val).gameObject); } } Logger.LogInfo((object)($"[StarTrophies] Шанс дропа трофеев понижен до {cap:P0} у {changedEntries} записей " + $"({changedCreatures} видов существ). Боссы, гарантированные (100%) и уже редкие трофеи не тронуты.")); if (!ConfigDebugDropTable.Value) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine($"[StarTrophies][DROPS] Трофеи обычных мобов: {report.Count}, из них с m_levelMultiplier=true: {levelMulCount}."); foreach (KeyValuePair<string, string> item2 in report) { stringBuilder.AppendLine(" " + item2.Key + ": " + item2.Value); } Logger.LogInfo((object)stringBuilder.ToString()); void ProcessPrefab(GameObject prefab) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Invalid comparison between Unknown and I4 if (!((Object)(object)prefab == (Object)null) && seen.Add(prefab)) { CharacterDrop component = prefab.GetComponent<CharacterDrop>(); if (!((Object)(object)component == (Object)null) && component.m_drops != null) { Character component2 = prefab.GetComponent<Character>(); if (!((Object)(object)component2 != (Object)null) || !component2.m_boss) { bool flag = false; List<Drop> drops = component.m_drops; for (int j = 0; j < drops.Count; j++) { Drop val2 = drops[j]; if (!((Object)(object)val2.m_prefab == (Object)null)) { ItemDrop component3 = val2.m_prefab.GetComponent<ItemDrop>(); if ((Object)(object)component3 != (Object)null && component3.m_itemData != null && component3.m_itemData.m_shared != null && (int)component3.m_itemData.m_shared.m_itemType == 13) { float chance = val2.m_chance; bool flag2 = val2.m_chance >= 1f; if (val2.m_chance > cap && !flag2) { val2.m_chance = cap; drops[j] = val2; changedEntries++; flag = true; } string key = ((Object)val2.m_prefab).name + " ← " + ((Object)prefab).name; if (!report.ContainsKey(key)) { if (val2.m_levelMultiplier) { levelMulCount++; } float chance2 = val2.m_chance; bool levelMultiplierNotAmount = val2.m_levelMultiplierNotAmount; string text = (val2.m_levelMultiplier ? (string.Format("1★ {0:P0}{1}, 2★ {2:P0}{3}, ", chance2 * 2f, (chance2 * 2f > 0.3f) ? " (без псевдо)" : "", chance2 * 4f, (chance2 * 4f > 0.3f) ? " (без псевдо)" : "") + (levelMultiplierNotAmount ? "кол-во не меняется" : "кол-во ×2/×4")) : "звёзды не влияют"); report[key] = string.Format("{0:P1} → {1:P1}{2}, levelMultiplier={3}, notAmount={4}, dontScale={5}, ", chance, chance2, flag2 ? " (гарантированный, не тронут)" : "", val2.m_levelMultiplier, levelMultiplierNotAmount, val2.m_dontScale) + "псевдо=" + ((chance2 <= 0.3f) ? "да" : "нет") + "; " + text; } } } } if (flag) { changedCreatures++; } } } } } } } public static class NativeStarColorizer { private struct StarColor { public bool FromMob; public float Hue; public float Saturation; public float Value; public bool SetEmissive; public Color Emissive; } private static readonly string[] EmissionPropertyNames = new string[2] { "_EmissionColor", "_EmissiveColor" }; private static readonly string[] TintPropertyNames = new string[3] { "_Color", "_TintColor", "_BaseColor" }; private static readonly Color[] FallbackTint = (Color[])(object)new Color[2] { new Color(1f, 0.85f, 0.55f), new Color(1f, 0.55f, 0.35f) }; private static readonly Color[] FallbackEmission = (Color[])(object)new Color[2] { new Color(0.35f, 0.25f, 0.05f), new Color(0.6f, 0.2f, 0.05f) }; private static Dictionary<string, GameObject> _mobByTrophy; public static void ApplyNativeStarColor(GameObject originalTrophy, GameObject cloneTrophy, int tier) { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) string text = (((Object)(object)originalTrophy != (Object)null) ? ((Object)originalTrophy).name : "?"); GameObject val = FindMobByTrophy(originalTrophy); LevelEffects val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInChildren<LevelEffects>(true) : null); bool flag = (Object)(object)val2 != (Object)null && val2.m_levelSetups != null && tier < val2.m_levelSetups.Count; Renderer val3 = (((Object)(object)val2 != (Object)null) ? val2.m_mainRender : null); if ((Object)(object)val3 == (Object)null && (Object)(object)val != (Object)null) { val3 = FindMainMobBody(val); } if (tier == 0 && StarTrophiesPlugin.IsDebugDumpTrophy(text)) { DumpDiagnostics(text, val, val2, val3, cloneTrophy); } StarColor color = default(StarColor); if (flag) { LevelSetup val4 = val2.m_levelSetups[tier]; color.FromMob = true; color.Hue = val4.m_hue; color.Saturation = val4.m_saturation; color.Value = val4.m_value; color.SetEmissive = val4.m_setEmissiveColor; color.Emissive = val4.m_emissiveColor; } bool usedFallback; List<Renderer> list = FindMatchingRenderers(cloneTrophy, val3, out usedFallback); if (list.Count == 0) { Logger.LogWarning((object)("[StarTrophies] " + text + ": не найдено рендеров для окраски.")); return; } if (usedFallback || !flag) { Logger.LogDebug((object)(string.Format("[StarTrophies] {0} {1}★: моб={2}, ", text, tier + 1, ((Object)(object)val != (Object)null) ? ((Object)val).name : "<не найден>") + "LevelEffects=" + (flag ? "да" : "нет") + ", сопоставление=" + (usedFallback ? "запасное" : "по материалу/текстуре") + ", цели=[" + DescribeRenderers(list) + "]")); } foreach (Renderer item in list) { ColorRenderer(item, color, tier); } if (flag) { GameObject enableObject = val2.m_levelSetups[tier].m_enableObject; if ((Object)(object)enableObject != (Object)null) { ApplyEnableObjectEffects(text, cloneTrophy, enableObject, tier); } } } private static string CleanMatName(Material m) { return ((Object)(object)m == (Object)null) ? string.Empty : ((Object)m).name.Replace(" (Instance)", "").Trim().ToLowerInvariant(); } private static void ApplyEnableObjectEffects(string trophyName, GameObject trophy, GameObject enableObject, int tier) { //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) ParticleSystem[] componentsInChildren = enableObject.GetComponentsInChildren<ParticleSystem>(true); Dictionary<string, ParticleSystem> dictionary = new Dictionary<string, ParticleSystem>(); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>(); string text = (((Object)(object)component != (Object)null) ? CleanMatName(((Renderer)component).sharedMaterial) : string.Empty); if (text.Length > 0 && !dictionary.ContainsKey(text)) { dictionary[text] = val; } } float delta = 0f; bool flag = false; int num = 0; List<ParticleSystem> list = new List<ParticleSystem>(); ParticleSystem[] componentsInChildren2 = trophy.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val2 in componentsInChildren2) { if ((Object)(object)((Component)val2).gameObject == (Object)(object)trophy) { continue; } ParticleSystemRenderer component2 = ((Component)val2).GetComponent<ParticleSystemRenderer>(); string text2 = (((Object)(object)component2 != (Object)null) ? CleanMatName(((Renderer)component2).sharedMaterial) : string.Empty); if (text2.Length > 0 && dictionary.TryGetValue(text2, out var value)) { if (!flag && TryHueDelta(RepresentativeColor(val2), RepresentativeColor(value), out delta)) { flag = true; } CopyParticleColors(value, val2); ParticleSystemRenderer component3 = ((Component)value).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component3 != (Object)null && (Object)(object)component2 != (Object)null && (Object)(object)((Renderer)component3).sharedMaterial != (Object)null) { ((Renderer)component2).sharedMaterial = ((Renderer)component3).sharedMaterial; } num++; } else { list.Add(val2); } } if (!flag) { ParticleSystem[] array2 = componentsInChildren; float num2 = default(float); float num3 = default(float); float num4 = default(float); foreach (ParticleSystem ps in array2) { Color.RGBToHSV(RepresentativeColor(ps), ref num2, ref num3, ref num4); if (num3 > 0.15f) { delta = num2 - 0.07f; flag = true; break; } } } if (flag) { foreach (ParticleSystem item in list) { ShiftParticleSystemHue(item, delta); ParticleSystemRenderer component4 = ((Component)item).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component4 != (Object)null) { ShiftRendererTintHue((Renderer)(object)component4, delta); } } } Light componentInChildren = enableObject.GetComponentInChildren<Light>(true); int num5 = 0; Light[] componentsInChildren3 = trophy.GetComponentsInChildren<Light>(true); foreach (Light val3 in componentsInChildren3) { if ((Object)(object)componentInChildren != (Object)null) { val3.color = componentInChildren.color; } else { if (!flag) { continue; } val3.color = ShiftHsv(val3.color, delta, 0f, 0f); } num5++; } Logger.LogInfo((object)($"[StarTrophies] {trophyName} {tier + 1}★: перенесены эффекты «{((Object)enableObject).name}» — " + $"частиц по материалу: {num}, сдвинуто по оттенку: {(flag ? list.Count : 0)} " + $"(Δhue={delta:0.00}), свет: {num5}.")); } private static bool TryHueDelta(Color from, Color to, out float delta) { //IL_0001: 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) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(from, ref num, ref num2, ref num3); float num4 = default(float); float num5 = default(float); Color.RGBToHSV(to, ref num4, ref num5, ref num3); delta = 0f; if (num2 < 0.15f || num5 < 0.15f) { return false; } delta = num4 - num; return true; } private static void CopyParticleColors(ParticleSystem src, ParticleSystem dst) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0010: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) MainModule main = dst.main; MainModule main2 = src.main; ((MainModule)(ref main)).startColor = ((MainModule)(ref main2)).startColor; ColorOverLifetimeModule colorOverLifetime = src.colorOverLifetime; ColorOverLifetimeModule colorOverLifetime2 = dst.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime2)).enabled = ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { ((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color; } ColorBySpeedModule colorBySpeed = src.colorBySpeed; ColorBySpeedModule colorBySpeed2 = dst.colorBySpeed; ((ColorBySpeedModule)(ref colorBySpeed2)).enabled = ((ColorBySpeedModule)(ref colorBySpeed)).enabled; if (((ColorBySpeedModule)(ref colorBySpeed)).enabled) { ((ColorBySpeedModule)(ref colorBySpeed2)).color = ((ColorBySpeedModule)(ref colorBySpeed)).color; } } private static void ShiftParticleSystemHue(ParticleSystem ps, float dh) { //IL_001c: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: 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) Func<Color, Color> shift = (Color x) => ShiftHsv(x, dh, 0f, 0f); MainModule main = ps.main; ((MainModule)(ref main)).startColor = ShiftGradient(((MainModule)(ref main)).startColor, shift); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = ShiftGradient(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, shift); } } private static void ShiftRendererTintHue(Renderer r, float dh) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_006f: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) Material[] sharedMaterials = r.sharedMaterials; if (sharedMaterials == null) { return; } Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int i = 0; i < sharedMaterials.Length; i++) { if ((Object)(object)sharedMaterials[i] == (Object)null) { continue; } Material val = new Material(sharedMaterials[i]); string[] tintPropertyNames = TintPropertyNames; foreach (string text in tintPropertyNames) { if (val.HasProperty(text)) { val.SetColor(text, ShiftHsv(val.GetColor(text), dh, 0f, 0f)); } } string[] emissionPropertyNames = EmissionPropertyNames; foreach (string text2 in emissionPropertyNames) { if (val.HasProperty(text2)) { val.SetColor(text2, ShiftHsv(val.GetColor(text2), dh, 0f, 0f)); } } array[i] = val; } r.sharedMaterials = array; } private static Color RepresentativeColor(ParticleSystem ps) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003f: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; Color val = AverageColor(((MainModule)(ref main)).startColor); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { val *= AverageColor(((ColorOverLifetimeModule)(ref colorOverLifetime)).color); } return val; } private static Color AverageColor(MinMaxGradient g) { //IL_0003: 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_0009: 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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected I4, but got Unknown //IL_0029: 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_0053: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0088: 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_0085: Unknown result type (might be due to invalid IL or missing references) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode; ParticleSystemGradientMode val = mode; switch ((int)val) { case 0: return ((MinMaxGradient)(ref g)).color; case 2: return Color.Lerp(((MinMaxGradient)(ref g)).colorMin, ((MinMaxGradient)(ref g)).colorMax, 0.5f); case 1: case 4: return AverageColor(((MinMaxGradient)(ref g)).gradient); case 3: return Color.Lerp(AverageColor(((MinMaxGradient)(ref g)).gradientMin), AverageColor(((MinMaxGradient)(ref g)).gradientMax), 0.5f); default: return Color.white; } } private static Color AverageColor(Gradient g) { //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_0009: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (g == null) { return Color.white; } Color val = Color.clear; for (int i = 0; i < 5; i++) { val += g.Evaluate((float)i / 4f); } return val / 5f; } private static void ColorRenderer(Renderer target, StarColor color, int tier) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown Material[] sharedMaterials = target.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { return; } bool flag = false; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int i = 0; i < sharedMaterials.Length; i++) { if (!((Object)(object)sharedMaterials[i] == (Object)null)) { Material val = new Material(sharedMaterials[i]); if (color.FromMob) { flag |= ApplyMobColor(val, color); } else { ApplyFallback(val, tier); } array[i] = val; } } target.sharedMaterials = array; if (target is ParticleSystemRenderer && !flag) { ParticleSystem component = ((Component)target).GetComponent<ParticleSystem>(); if ((Object)(object)component != (Object)null) { ShiftParticleColors(component, color, tier); } } } private static bool ApplyMobColor(Material mat, StarColor c) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (mat.HasProperty("_Hue")) { mat.SetFloat("_Hue", c.Hue); flag = true; } if (mat.HasProperty("_Saturation")) { mat.SetFloat("_Saturation", c.Saturation); flag = true; } if (mat.HasProperty("_Value")) { mat.SetFloat("_Value", c.Value); flag = true; } bool flag2 = c.SetEmissive && SetEmission(mat, c.Emissive); if (!flag && !flag2) { string[] tintPropertyNames = TintPropertyNames; foreach (string text in tintPropertyNames) { if (mat.HasProperty(text)) { mat.SetColor(text, ShiftHsv(mat.GetColor(text), c.Hue, c.Saturation, c.Value)); } } } return flag; } private static void ApplyFallback(Material mat, int tier) { //IL_0019: 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_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) int num = Mathf.Clamp(tier, 0, FallbackTint.Length - 1); if (SetEmission(mat, FallbackEmission[num])) { return; } string[] tintPropertyNames = TintPropertyNames; foreach (string text in tintPropertyNames) { if (mat.HasProperty(text)) { mat.SetColor(text, mat.GetColor(text) * FallbackTint[num]); } } } private static bool SetEmission(Material mat, Color color) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) bool flag = false; string[] emissionPropertyNames = EmissionPropertyNames; foreach (string text in emissionPropertyNames) { if (mat.HasProperty(text)) { mat.SetColor(text, color); flag = true; } } if (flag) { mat.EnableKeyword("_EMISSION"); } return flag; } private static Color ShiftHsv(Color c, float dh, float ds, float dv) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); Color result = Color.HSVToRGB(Mathf.Repeat(num + dh, 1f), Mathf.Clamp01(num2 + ds), Mathf.Clamp01(num3 + dv), true); result.a = c.a; return result; } private static void ShiftParticleColors(ParticleSystem ps, StarColor c, int tier) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a0: Unknown result type (might be due to invalid IL or missing references) Func<Color, Color> shift; if (c.FromMob) { shift = (Color x) => ShiftHsv(x, c.Hue, c.Saturation, c.Value); } else { Color tint = FallbackTint[Mathf.Clamp(tier, 0, FallbackTint.Length - 1)]; shift = (Color x) => x * tint; } MainModule main = ps.main; ((MainModule)(ref main)).startColor = ShiftGradient(((MainModule)(ref main)).startColor, shift); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = ShiftGradient(((ColorOverLifetimeModule)(ref colorOverLifetime)).color, shift); } } private static MinMaxGradient ShiftGradient(MinMaxGradient g, Func<Color, Color> shift) { //IL_0003: 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_0009: 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) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected I4, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref g)).mode; ParticleSystemGradientMode val = mode; switch ((int)val) { case 0: return new MinMaxGradient(shift(((MinMaxGradient)(ref g)).color)); case 2: return new MinMaxGradient(shift(((MinMaxGradient)(ref g)).colorMin), shift(((MinMaxGradient)(ref g)).colorMax)); case 1: case 4: { MinMaxGradient result = default(MinMaxGradient); ((MinMaxGradient)(ref result))..ctor(ShiftGradient(((MinMaxGradient)(ref g)).gradient, shift)); ((MinMaxGradient)(ref result)).mode = ((MinMaxGradient)(ref g)).mode; return result; } case 3: return new MinMaxGradient(ShiftGradient(((MinMaxGradient)(ref g)).gradientMin, shift), ShiftGradient(((MinMaxGradient)(ref g)).gradientMax, shift)); default: return g; } } private static Gradient ShiftGradient(Gradient src, Func<Color, Color> shift) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0051: 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 if (src == null) { return null; } GradientColorKey[] colorKeys = src.colorKeys; for (int i = 0; i < colorKeys.Length; i++) { colorKeys[i].color = shift(colorKeys[i].color); } Gradient val = new Gradient { mode = src.mode }; val.SetKeys(colorKeys, src.alphaKeys); return val; } private static GameObject FindMobByTrophy(GameObject trophyPrefab) { if ((Object)(object)trophyPrefab == (Object)null) { return null; } if (_mobByTrophy == null) { BuildMobIndex(); } _mobByTrophy.TryGetValue(((Object)trophyPrefab).name, out var value); return value; } private static void BuildMobIndex() { _mobByTrophy = new Dictionary<string, GameObject>(); Dictionary<string, int> score = new Dictionary<string, int>(); HashSet<GameObject> seen = new HashSet<GameObject>(); Dictionary<string, Object> prefabs = Cache.GetPrefabs(typeof(GameObject)); if (prefabs != null) { foreach (KeyValuePair<string, Object> item in prefabs) { Object value = item.Value; Consider((GameObject)(object)((value is GameObject) ? value : null)); } } if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs != null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { Consider(prefab); } } CharacterDrop[] array = Resources.FindObjectsOfTypeAll<CharacterDrop>(); foreach (CharacterDrop val in array) { if ((Object)(object)val != (Object)null) { Consider(((Component)val).gameObject); } } Logger.LogInfo((object)$"[StarTrophies] Индекс мобов: {_mobByTrophy.Count} предметов-дропов от {seen.Count} объектов."); void Consider(GameObject prefab) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && seen.Add(prefab)) { CharacterDrop component = prefab.GetComponent<CharacterDrop>(); if (!((Object)(object)component == (Object)null) && component.m_drops != null) { int num = 0; LevelEffects componentInChildren = prefab.GetComponentInChildren<LevelEffects>(true); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.m_levelSetups != null && componentInChildren.m_levelSetups.Count > 0) { num += 4; } if ((Object)(object)prefab.GetComponent<Character>() != (Object)null) { num += 2; } Scene scene = prefab.scene; if (!((Scene)(ref scene)).IsValid()) { num++; } foreach (Drop drop in component.m_drops) { if (!((Object)(object)drop.m_prefab == (Object)null)) { string name = ((Object)drop.m_prefab).name; if (!score.TryGetValue(name, out var value2) || num > value2) { score[name] = num; _mobByTrophy[name] = prefab; } } } } } } } private static bool IsBodyRenderer(Renderer r) { return r is SkinnedMeshRenderer || r is MeshRenderer; } private static Renderer FindMainMobBody(GameObject mob) { Renderer result = null; int num = -1; Renderer[] componentsInChildren = mob.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (IsBodyRenderer(val)) { int num2 = VertexCount(val); if (num2 > num) { result = val; num = num2; } } } return result; } private static int VertexCount(Renderer r) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); if (val != null) { return ((Object)(object)val.sharedMesh != (Object)null) ? val.sharedMesh.vertexCount : 0; } MeshFilter component = ((Component)r).GetComponent<MeshFilter>(); return ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) ? component.sharedMesh.vertexCount : 0; } private static string Normalize(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } string text = name.Replace(" (Instance)", "").ToLowerInvariant(); string[] array = new string[8] { "trophy", "material", "_mat", "mat_", "_diffuse", "_albedo", "_tex", "_d" }; foreach (string oldValue in array) { text = text.Replace(oldValue, ""); } StringBuilder stringBuilder = new StringBuilder(text.Length); string text2 = text; foreach (char c in text2) { if (char.IsLetter(c)) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private static bool NamesMatch(string a, string b) { string text = Normalize(a); string text2 = Normalize(b); if (text.Length < 3 || text2.Length < 3) { return false; } return text == text2 || text.Contains(text2) || text2.Contains(text); } private static List<Renderer> FindMatchingRenderers(GameObject trophyClone, Renderer mobRenderer, out bool usedFallback) { usedFallback = false; List<Renderer> list = new List<Renderer>(); Material val = (((Object)(object)mobRenderer != (Object)null) ? mobRenderer.sharedMaterial : null); Texture val2 = (((Object)(object)val != (Object)null) ? val.mainTexture : null); string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : null); string text2 = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : null); Renderer[] componentsInChildren = trophyClone.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val3 in array) { if (val3.sharedMaterials == null) { continue; } Material[] sharedMaterials = val3.sharedMaterials; foreach (Material val4 in sharedMaterials) { if (!((Object)(object)val4 == (Object)null)) { Texture mainTexture = val4.mainTexture; if (((Object)(object)val != (Object)null && (Object)(object)val4 == (Object)(object)val) || ((Object)(object)val2 != (Object)null && (Object)(object)mainTexture == (Object)(object)val2) || (text != null && NamesMatch(((Object)val4).name, text)) || (text2 != null && (Object)(object)mainTexture != (Object)null && NamesMatch(((Object)mainTexture).name, text2))) { list.Add(val3); break; } } } } if (list.Count == 0) { usedFallback = true; Renderer val5 = null; int num = -1; Renderer[] array2 = componentsInChildren; foreach (Renderer val6 in array2) { if (IsBodyRenderer(val6)) { int num2 = VertexCount(val6); if (num2 > num) { val5 = val6; num = num2; } } } if ((Object)(object)val5 != (Object)null) { list.Add(val5); } } return list; } private static string DescribeRenderers(IEnumerable<Renderer> renderers) { List<string> list = new List<string>(); foreach (Renderer renderer in renderers) { if ((Object)(object)renderer == (Object)null) { continue; } List<string> list2 = new List<string>(); if (renderer.sharedMaterials != null) { Material[] sharedMaterials = renderer.sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null) { list2.Add(((Object)val).name + "<" + (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : "?") + ">"); } } } list.Add(((object)renderer).GetType().Name + ":" + ((Object)renderer).name + "[" + string.Join(",", list2) + "]"); } return string.Join("; ", list); } private static string ShaderProps(Material m) { if ((Object)(object)m == (Object)null || (Object)(object)m.shader == (Object)null) { return ""; } List<string> list = new List<string>(); int propertyCount = m.shader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { list.Add(m.shader.GetPropertyName(i)); } return string.Join(",", list); } private static void DumpDiagnostics(string trophyName, GameObject mob, LevelEffects le, Renderer mobMain, GameObject trophy) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("[StarTrophies][DUMP] ===== " + trophyName + " ====="); stringBuilder.AppendLine(" Моб: " + (((Object)(object)mob != (Object)null) ? ((Object)mob).name : "<не найден>")); if ((Object)(object)le == (Object)null) { stringBuilder.AppendLine(" LevelEffects: нет"); } else { stringBuilder.AppendLine(" LevelEffects.m_mainRender: " + (((Object)(object)le.m_mainRender != (Object)null) ? DescribeRenderers((IEnumerable<Renderer>)(object)new Renderer[1] { le.m_mainRender }) : "<null>")); if (le.m_levelSetups != null) { for (int i = 0; i < le.m_levelSetups.Count; i++) { LevelSetup val = le.m_levelSetups[i]; stringBuilder.AppendLine($" Setup[{i}]: hue={val.m_hue} sat={val.m_saturation} val={val.m_value} " + string.Format("emissive={0}/{1} enableObject={2}", val.m_setEmissiveColor, val.m_emissiveColor, ((Object)(object)val.m_enableObject != (Object)null) ? ((Object)val.m_enableObject).name : "-")); } } } if ((Object)(object)mob != (Object)null) { Renderer[] componentsInChildren = mob.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { stringBuilder.AppendLine(" Моб-рендер: " + DescribeRenderers((IEnumerable<Renderer>)(object)new Renderer[1] { val2 }) + " props=" + ShaderProps(val2.sharedMaterial)); } } Renderer[] componentsInChildren2 = trophy.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren2) { stringBuilder.AppendLine(" Трофей-рендер: " + DescribeRenderers((IEnumerable<Renderer>)(object)new Renderer[1] { val3 }) + " props=" + ShaderProps(val3.sharedMaterial)); } Logger.LogInfo((object)stringBuilder.ToString()); } } public static class SharedDataCopy { public static T ShallowCopy<T>(T source) where T : class { return (T)(typeof(T).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(source, null)); } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] public static class CharacterDrop_Patch { [HarmonyPostfix] public static void Postfix(CharacterDrop __instance, ref List<KeyValuePair<GameObject, int>> __result) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Invalid comparison between Unknown and I4 if ((Object)(object)__instance == (Object)null || __result == null || __result.Count == 0) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return; } int level = component.GetLevel(); if (level <= 1) { return; } int num = level - 2; if (num < 0 || num > 1) { return; } for (int i = 0; i < __result.Count; i++) { KeyValuePair<GameObject, int> keyValuePair = __result[i]; if ((Object)(object)keyValuePair.Key == (Object)null) { continue; } ItemDrop component2 = keyValuePair.Key.GetComponent<ItemDrop>(); if (!((Object)(object)component2 != (Object)null) || component2.m_itemData == null || (int)component2.m_itemData.m_shared.m_itemType != 13) { continue; } string name = ((Object)keyValuePair.Key).name; if (!StarTrophiesPlugin.KnownNonStarableTrophies.Contains(name)) { string text = $"{name}_Star{num + 1}"; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(text) : PrefabManager.Instance.GetPrefab(text)); if ((Object)(object)val != (Object)null) { __result[i] = new KeyValuePair<GameObject, int>(val, keyValuePair.Value); } } } } } }