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 DudeWheresMySpear v0.1.2
DudeWheresMySpear.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace DudeWheresMySpear; [BepInPlugin("com.parallel53.dudewheresmyspear", "DudeWheresMySpear", "0.1.2")] public class DudeWheresMySpearPlugin : BaseUnityPlugin { private class Original { public int MaxParticles; public float Lifetime; public float Size; public MinMaxGradient Color; public float Rate; public float RateOverDistance; public Burst[] Bursts; public float Radius; public Vector3 Scale; public float Speed; public float Gravity; public Vector3 Velocity; public Vector3 Force; } private const string SparkleMaterial = "item_particle"; private const string AttachChild = "attach"; private const int EffectsLogged = 8; private const float SharedShare = 0.2f; private const float CheckSeconds = 1f; private static readonly Dictionary<string, Original> Originals = new Dictionary<string, Original>(); private static readonly Dictionary<ParticleSystem, string> PrefabSparkles = new Dictionary<ParticleSystem, string>(); private static bool logged; private static bool changed; private DateTime configWritten; private float nextCheck; private static ManualLogSource log; private static ConfigEntry<float> intensity; private static ConfigEntry<float> count; private static ConfigEntry<float> spread; private static ConfigEntry<float> size; private static ConfigEntry<float> lifetime; private static ConfigEntry<float> drift; private void Awake() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) log = ((BaseUnityPlugin)this).Logger; intensity = Multiplier("Intensity", 1.5f, "Brightness of each sparkle."); count = Multiplier("Count", 2f, "How many sparkles each item gives off."); spread = Multiplier("Spread", 1.5f, "How far around the item the sparkles appear."); size = Multiplier("Size", 1.5f, "How big each sparkle is."); lifetime = Multiplier("Lifetime", 2f, "How long each sparkle lasts."); drift = Multiplier("Drift", 0.5f, "How fast each sparkle drifts away from the item. Longer-lasting sparkles drift further, so this keeps them close."); configWritten = WrittenAt(); new Harmony("com.parallel53.dudewheresmyspear").PatchAll(typeof(DudeWheresMySpearPlugin)); } private ConfigEntry<float> Multiplier(string key, float value, string description) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown ConfigEntry<float> obj = ((BaseUnityPlugin)this).Config.Bind<float>("Sparkles", key, value, new ConfigDescription(description + " A multiple of the game's. Takes effect as soon as the file is saved.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); obj.SettingChanged += delegate { changed = true; }; return obj; } private DateTime WrittenAt() { if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { return DateTime.MinValue; } return File.GetLastWriteTimeUtc(((BaseUnityPlugin)this).Config.ConfigFilePath); } private void Update() { if (Time.unscaledTime >= nextCheck) { nextCheck = Time.unscaledTime + 1f; DateTime dateTime = WrittenAt(); if (dateTime != configWritten) { configWritten = dateTime; ((BaseUnityPlugin)this).Config.Reload(); } } if (changed) { changed = false; ApplyAll(); } } private static void ApplyAll() { foreach (KeyValuePair<ParticleSystem, string> item in PrefabSparkles.Where((KeyValuePair<ParticleSystem, string> pair) => (Object)(object)pair.Key != (Object)null)) { Apply(item.Key, Originals[item.Value]); } int num = 0; ItemDrop[] array = Object.FindObjectsByType<ItemDrop>((FindObjectsSortMode)0); foreach (ItemDrop drop in array) { if (!Originals.TryGetValue(Utils.GetPrefabName(((Component)drop).gameObject), out var value)) { continue; } foreach (ParticleSystem item2 in from particles in ((Component)drop).GetComponentsInChildren<ParticleSystem>(true) where !Equipped(((Component)drop).gameObject, particles) && Key(particles).StartsWith("item_particle") select particles) { Apply(item2, value); num++; } } log.LogInfo((object)("Settings changed: count " + count.Value + ", size " + size.Value + ", lifetime " + lifetime.Value + ", intensity " + intensity.Value + ", spread " + spread.Value + ", drift " + drift.Value + ". Updated " + num + " items on the ground.")); } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void BoostSparkles(ObjectDB __instance) { List<GameObject> list = __instance.m_items.Where((GameObject val2) => (Object)(object)val2 != (Object)null).ToList(); Dictionary<string, List<ParticleSystem>> dictionary = new Dictionary<string, List<ParticleSystem>>(); Dictionary<string, HashSet<GameObject>> owners = new Dictionary<string, HashSet<GameObject>>(); foreach (GameObject item2 in list) { ParticleSystem[] componentsInChildren = item2.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { if (!Equipped(item2, val)) { string key = Key(val); if (!dictionary.ContainsKey(key)) { dictionary[key] = new List<ParticleSystem>(); owners[key] = new HashSet<GameObject>(); } dictionary[key].Add(val); owners[key].Add(item2); } } } if (list.Count == 0) { return; } if (dictionary.Count == 0) { log.LogWarning((object)("No items with particle effects among " + list.Count)); return; } List<string> list2 = owners.Keys.OrderByDescending((string key2) => owners[key2].Count).ToList(); if (!logged) { logged = true; log.LogInfo((object)("Most common item effects among " + list.Count + " items: " + string.Join("; ", (from text in list2.Take(8) select text + " on " + owners[text].Count).ToArray()))); } List<string> list3 = list2.Where((string text) => text.StartsWith("item_particle")).ToList(); if (list3.Count == 0 && (float)owners[list2[0]].Count >= (float)list.Count * 0.2f) { list3.Add(list2[0]); } if (list3.Count == 0) { log.LogWarning((object)"Found no effect shared by most items, so nothing was boosted"); return; } int num2 = 0; foreach (string item3 in list3) { foreach (GameObject item in owners[item3]) { foreach (ParticleSystem item4 in dictionary[item3].Where((ParticleSystem particles) => ((Component)particles).transform.IsChildOf(item.transform))) { if (!PrefabSparkles.ContainsKey(item4)) { if (!Originals.ContainsKey(((Object)item).name)) { Originals[((Object)item).name] = Capture(item4); } PrefabSparkles[item4] = ((Object)item).name; if (PrefabSparkles.Count == 1) { log.LogInfo((object)("Game's sparkles: " + Describe(item4))); } Apply(item4, Originals[((Object)item).name]); num2++; if (PrefabSparkles.Count == 1) { log.LogInfo((object)("Boosted to: " + Describe(item4))); } } } } } if (num2 > 0) { log.LogInfo((object)("Boosted the sparkles on " + num2 + " items")); } } private static string Key(ParticleSystem particles) { ParticleSystemRenderer component = ((Component)particles).GetComponent<ParticleSystemRenderer>(); if (!((Object)(object)component != (Object)null) || !((Object)(object)((Renderer)component).sharedMaterial != (Object)null)) { return "none"; } return ((Object)((Renderer)component).sharedMaterial).name; } private static bool Equipped(GameObject item, ParticleSystem particles) { Transform val = ((Component)particles).transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)item.transform) { if (((Object)val).name == "attach") { return true; } val = val.parent; } return false; } private static Original Capture(ParticleSystem particles) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000d: 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_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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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) MainModule main = particles.main; EmissionModule emission = particles.emission; Burst[] array = (Burst[])(object)new Burst[((EmissionModule)(ref emission)).burstCount]; ((EmissionModule)(ref emission)).GetBursts(array); Original obj = new Original { MaxParticles = ((MainModule)(ref main)).maxParticles, Lifetime = ((MainModule)(ref main)).startLifetimeMultiplier, Size = ((MainModule)(ref main)).startSizeMultiplier, Color = ((MainModule)(ref main)).startColor, Rate = ((EmissionModule)(ref emission)).rateOverTimeMultiplier, RateOverDistance = ((EmissionModule)(ref emission)).rateOverDistanceMultiplier, Bursts = array }; ShapeModule shape = particles.shape; obj.Radius = ((ShapeModule)(ref shape)).radius; shape = particles.shape; obj.Scale = ((ShapeModule)(ref shape)).scale; obj.Speed = ((MainModule)(ref main)).startSpeedMultiplier; obj.Gravity = ((MainModule)(ref main)).gravityModifierMultiplier; VelocityOverLifetimeModule velocityOverLifetime = particles.velocityOverLifetime; float xMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).xMultiplier; velocityOverLifetime = particles.velocityOverLifetime; float yMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier; velocityOverLifetime = particles.velocityOverLifetime; obj.Velocity = new Vector3(xMultiplier, yMultiplier, ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).zMultiplier); ForceOverLifetimeModule forceOverLifetime = particles.forceOverLifetime; float xMultiplier2 = ((ForceOverLifetimeModule)(ref forceOverLifetime)).xMultiplier; forceOverLifetime = particles.forceOverLifetime; float yMultiplier2 = ((ForceOverLifetimeModule)(ref forceOverLifetime)).yMultiplier; forceOverLifetime = particles.forceOverLifetime; obj.Force = new Vector3(xMultiplier2, yMultiplier2, ((ForceOverLifetimeModule)(ref forceOverLifetime)).zMultiplier); return obj; } private static void Apply(ParticleSystem particles, Original original) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) MainModule main = particles.main; ((MainModule)(ref main)).maxParticles = Mathf.CeilToInt((float)original.MaxParticles * count.Value * Mathf.Max(lifetime.Value, 1f)); ((MainModule)(ref main)).startLifetimeMultiplier = original.Lifetime * lifetime.Value; ((MainModule)(ref main)).startSizeMultiplier = original.Size * size.Value; ((MainModule)(ref main)).startColor = Brighter(original.Color, intensity.Value); ((MainModule)(ref main)).startSpeedMultiplier = original.Speed * drift.Value; ((MainModule)(ref main)).gravityModifierMultiplier = original.Gravity * drift.Value; VelocityOverLifetimeModule velocityOverLifetime = particles.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).xMultiplier = original.Velocity.x * drift.Value; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier = original.Velocity.y * drift.Value; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).zMultiplier = original.Velocity.z * drift.Value; ForceOverLifetimeModule forceOverLifetime = particles.forceOverLifetime; ((ForceOverLifetimeModule)(ref forceOverLifetime)).xMultiplier = original.Force.x * drift.Value; ((ForceOverLifetimeModule)(ref forceOverLifetime)).yMultiplier = original.Force.y * drift.Value; ((ForceOverLifetimeModule)(ref forceOverLifetime)).zMultiplier = original.Force.z * drift.Value; EmissionModule emission = particles.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = original.Rate * count.Value; ((EmissionModule)(ref emission)).rateOverDistanceMultiplier = original.RateOverDistance * count.Value; Burst[] array = (Burst[])original.Bursts.Clone(); for (int i = 0; i < array.Length; i++) { MinMaxCurve val = ((Burst)(ref array[i])).count; ((MinMaxCurve)(ref val)).constant = ((MinMaxCurve)(ref val)).constant * count.Value; ((MinMaxCurve)(ref val)).constantMin = ((MinMaxCurve)(ref val)).constantMin * count.Value; ((MinMaxCurve)(ref val)).constantMax = ((MinMaxCurve)(ref val)).constantMax * count.Value; ((MinMaxCurve)(ref val)).curveMultiplier = ((MinMaxCurve)(ref val)).curveMultiplier * count.Value; ((Burst)(ref array[i])).count = val; } ((EmissionModule)(ref emission)).SetBursts(array); ShapeModule shape = particles.shape; ((ShapeModule)(ref shape)).radius = original.Radius * spread.Value; ((ShapeModule)(ref shape)).scale = original.Scale * spread.Value; } private static string Describe(ParticleSystem particles) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000d: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0295: 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_02b7: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) MainModule main = particles.main; EmissionModule emission = particles.emission; Burst[] array = (Burst[])(object)new Burst[((EmissionModule)(ref emission)).burstCount]; ((EmissionModule)(ref emission)).GetBursts(array); string[] array2 = new string[32]; array2[0] = ((Object)particles).name; array2[1] = " max "; array2[2] = ((MainModule)(ref main)).maxParticles.ToString(); array2[3] = ", lifetime "; MinMaxCurve val = ((MainModule)(ref main)).startLifetime; array2[4] = ((MinMaxCurve)(ref val)).constant.ToString(); array2[5] = "-"; val = ((MainModule)(ref main)).startLifetime; array2[6] = ((MinMaxCurve)(ref val)).constantMax.ToString(); array2[7] = ", duration "; array2[8] = ((MainModule)(ref main)).duration.ToString(); array2[9] = (((MainModule)(ref main)).loop ? " looping" : ""); array2[10] = ", rate "; array2[11] = ((EmissionModule)(ref emission)).rateOverTimeMultiplier.ToString(); array2[12] = " ("; val = ((EmissionModule)(ref emission)).rateOverTime; array2[13] = ((object)((MinMaxCurve)(ref val)).mode/*cast due to .constrained prefix*/).ToString(); array2[14] = "), bursts "; array2[15] = string.Join(" ", array.Select(delegate(Burst burst) { //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) string[] array3 = new string[5]; MinMaxCurve val2 = ((Burst)(ref burst)).count; array3[0] = ((MinMaxCurve)(ref val2)).constant.ToString(); array3[1] = "@"; array3[2] = ((Burst)(ref burst)).time.ToString(); array3[3] = "/"; array3[4] = ((Burst)(ref burst)).repeatInterval.ToString(); return string.Concat(array3); }).ToArray()); array2[16] = ", shape "; ShapeModule shape = particles.shape; array2[17] = ((object)((ShapeModule)(ref shape)).shapeType/*cast due to .constrained prefix*/).ToString(); array2[18] = " radius "; shape = particles.shape; array2[19] = ((ShapeModule)(ref shape)).radius.ToString(); array2[20] = ", speed "; array2[21] = ((MainModule)(ref main)).startSpeedMultiplier.ToString(); array2[22] = ", gravity "; array2[23] = ((MainModule)(ref main)).gravityModifierMultiplier.ToString(); array2[24] = ", velocity "; VelocityOverLifetimeModule velocityOverLifetime = particles.velocityOverLifetime; object obj; if (!((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled) { obj = "off"; } else { velocityOverLifetime = particles.velocityOverLifetime; float xMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).xMultiplier; velocityOverLifetime = particles.velocityOverLifetime; float yMultiplier = ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).yMultiplier; velocityOverLifetime = particles.velocityOverLifetime; obj = ((object)new Vector3(xMultiplier, yMultiplier, ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).zMultiplier)/*cast due to .constrained prefix*/).ToString(); } array2[25] = (string)obj; array2[26] = ", force "; ForceOverLifetimeModule forceOverLifetime = particles.forceOverLifetime; object obj2; if (!((ForceOverLifetimeModule)(ref forceOverLifetime)).enabled) { obj2 = "off"; } else { forceOverLifetime = particles.forceOverLifetime; float xMultiplier2 = ((ForceOverLifetimeModule)(ref forceOverLifetime)).xMultiplier; forceOverLifetime = particles.forceOverLifetime; float yMultiplier2 = ((ForceOverLifetimeModule)(ref forceOverLifetime)).yMultiplier; forceOverLifetime = particles.forceOverLifetime; obj2 = ((object)new Vector3(xMultiplier2, yMultiplier2, ((ForceOverLifetimeModule)(ref forceOverLifetime)).zMultiplier)/*cast due to .constrained prefix*/).ToString(); } array2[27] = (string)obj2; array2[28] = ", noise "; NoiseModule noise = particles.noise; object obj3; if (!((NoiseModule)(ref noise)).enabled) { obj3 = "off"; } else { noise = particles.noise; obj3 = ((NoiseModule)(ref noise)).strengthMultiplier.ToString(); } array2[29] = (string)obj3; array2[30] = ", emitting "; array2[31] = ((EmissionModule)(ref emission)).enabled.ToString(); return string.Concat(array2); } private static MinMaxGradient Brighter(MinMaxGradient color, float factor) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown //IL_0022: 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_002d: 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_0035: 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_0042: 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_004d: 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_0086: Unknown result type (might be due to invalid IL or missing references) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref color)).mode; return (MinMaxGradient)((int)mode switch { 0 => new MinMaxGradient(Brighter(((MinMaxGradient)(ref color)).color, factor)), 2 => new MinMaxGradient(Brighter(((MinMaxGradient)(ref color)).colorMin, factor), Brighter(((MinMaxGradient)(ref color)).colorMax, factor)), 1 => new MinMaxGradient(Brighter(((MinMaxGradient)(ref color)).gradient, factor)), 3 => new MinMaxGradient(Brighter(((MinMaxGradient)(ref color)).gradientMin, factor), Brighter(((MinMaxGradient)(ref color)).gradientMax, factor)), _ => color, }); } private static Gradient Brighter(Gradient gradient, float factor) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown Gradient val = new Gradient { mode = gradient.mode }; val.SetKeys(((IEnumerable<GradientColorKey>)gradient.colorKeys).Select((Func<GradientColorKey, GradientColorKey>)((GradientColorKey key) => new GradientColorKey(Brighter(key.color, factor), key.time))).ToArray(), ((IEnumerable<GradientAlphaKey>)gradient.alphaKeys).Select((Func<GradientAlphaKey, GradientAlphaKey>)((GradientAlphaKey key) => new GradientAlphaKey(Mathf.Clamp01(key.alpha * factor), key.time))).ToArray()); return val; } private static Color Brighter(Color color, float factor) { //IL_0000: 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_0010: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r * factor, color.g * factor, color.b * factor, Mathf.Clamp01(color.a * factor)); } }