Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of KnowMyGrenades v1.0.2
KnowMyGrenades.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ColoredGrenades")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ColoredGrenades")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("51680126-6e7b-4d1d-b646-83f3b9bf3956")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ColoredGrenades; [BepInPlugin("com.OctoLab.KnowMyGrenades", "Know My Grenades", "1.0.2")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Now everyone knows your grenades!"); Harmony val = new Harmony("com.OctoLab.KnowMyGrenades"); val.PatchAll(); } } public class GrenadeSprite { private static Dictionary<string, Texture2D> _textureCache = new Dictionary<string, Texture2D>(); private static Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); public static Texture2D LoadRawTexture(string name) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown if (_textureCache.TryGetValue(name, out var value)) { return value; } byte[] array = null; Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(name)) { continue; } using (Stream stream = executingAssembly.GetManifestResourceStream(text)) { if (stream != null) { array = new byte[stream.Length]; stream.Read(array, 0, array.Length); } } break; } if (array == null) { string path = Path.Combine(Path.GetDirectoryName(executingAssembly.Location), name + ".png"); if (File.Exists(path)) { array = File.ReadAllBytes(path); } } if (array != null) { Texture2D val = new Texture2D(2, 2); ((Texture)val).filterMode = (FilterMode)0; ImageConversion.LoadImage(val, array); _textureCache[name] = val; return val; } return null; } } public class GrenadeDataStorage { private static Dictionary<Grenade, Color> grenadeColors = new Dictionary<Grenade, Color>(); public static void SetColor(Grenade grenade, Color color) { //IL_0025: 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) if (grenadeColors.ContainsKey(grenade)) { grenadeColors[grenade] = color; } else { grenadeColors.Add(grenade, color); } } public static Color GetColor(Grenade grenade) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (grenadeColors.TryGetValue(grenade, out var value)) { return value; } return new Color(0.4f, 0.76862746f, 43f / 85f); } public static void RemoveColor(Grenade grenade) { if (grenadeColors.ContainsKey(grenade)) { grenadeColors.Remove(grenade); } } public static void ClearColors() { grenadeColors = new Dictionary<Grenade, Color>(); } } [HarmonyPatch] public class Patch { [HarmonyPatch(typeof(Grenade), "Initialize")] [HarmonyPostfix] public static void GrenadePostInit(Grenade __instance, ThrowItem2 mu) { //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_0032: 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_0053: 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) if ((Object)(object)mu == (Object)null || (Object)(object)__instance == (Object)null) { return; } try { PlayerInfo value = Traverse.Create((object)mu).Field("playerInfo").GetValue<PlayerInfo>(); Material playerMaterial = value.playerMaterial; if (!((Object)(object)playerMaterial == (Object)null)) { Color color = playerMaterial.GetColor("_ShadowColor"); GrenadeDataStorage.SetColor(__instance, color); } } catch (Exception ex) { Plugin.Logger.LogError((object)("Failed to color grenade: " + ex.Message)); } } [HarmonyPatch(typeof(Grenade), "Awake")] [HarmonyPostfix] public static void GrenadePostAwake(Grenade __instance) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer component = ((Component)__instance).GetComponent<SpriteRenderer>(); Plugin.Logger.LogInfo((object)$"{component.sprite} Sprite!"); Plugin.Logger.LogInfo((object)(((Object)component.sprite).name + " Sprite Name!")); if (((Object)component.sprite).name == "grenade3") { Texture2D val = GrenadeSprite.LoadRawTexture("Grenade"); Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.49f, 0.47f), 100f); component.sprite = sprite; component.color = new Color(0.4f, 0.76862746f, 43f / 85f); } else if (((Object)component.sprite).name == "smokeGrenade") { Texture2D val2 = GrenadeSprite.LoadRawTexture("smokeGrenade"); Sprite sprite2 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.49f, 0.47f), 100f); component.sprite = sprite2; component.color = new Color(0.5f, 0.5f, 0.5f); } } [HarmonyPatch(typeof(Grenade), "UpdateSim")] [HarmonyPostfix] public static void GrenadePostUpdateSim(Grenade __instance) { //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_001d: 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_0024: Unknown result type (might be due to invalid IL or missing references) Color color = GrenadeDataStorage.GetColor(__instance); SpriteRenderer component = ((Component)__instance).GetComponent<SpriteRenderer>(); float num = Time.deltaTime * 5f; component.color = Color.Lerp(component.color, color, num); } [HarmonyPatch(typeof(Grenade), "Detonate")] [HarmonyPrefix] public static void GrenadePreDetonate(Grenade __instance) { Plugin.Logger.LogInfo((object)$"{__instance} Removed Color!"); GrenadeDataStorage.RemoveColor(__instance); } [HarmonyPatch(typeof(GameSessionHandler), "LoadNextLevelScene")] [HarmonyPostfix] public static void PostLoadNextLevelScene() { GrenadeDataStorage.ClearColors(); Plugin.Logger.LogInfo((object)"Grenades Storage Cleared!"); } }