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 WhoBrokeIt v0.1.1
WhoBrokeIt.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("WhoBrokeIt")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+f0ae82b55bcec2885ebe31942fd80a624af8729d")] [assembly: AssemblyProduct("WhoBrokeIt")] [assembly: AssemblyTitle("WhoBrokeIt")] [assembly: AssemblyVersion("0.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 WhoBrokeIt { [BepInPlugin("com.list.whobrokeit", "WhoBrokeIt", "0.1.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.list.whobrokeit"; public const string PluginName = "WhoBrokeIt"; public const string PluginVersion = "0.1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) //IL_002a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.list.whobrokeit").PatchAll(); GameObject val = new GameObject("WhoBrokeIt_Overlay"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<NotificationOverlay>(); Log.LogInfo((object)"WhoBrokeIt 0.1.0 loaded"); } } internal static class GrabTracker { internal static readonly Dictionary<int, string> LastGrabber = new Dictionary<int, string>(); internal static void Record(int instanceId, string playerName) { LastGrabber[instanceId] = playerName; } internal static string Get(int instanceId) { if (!LastGrabber.TryGetValue(instanceId, out var value)) { return null; } return value; } } [HarmonyPatch(typeof(PhysGrabObject), "Update")] internal static class PhysGrabObject_Update_Patch { private static void Postfix(PhysGrabObject __instance) { if ((Object)(object)__instance == (Object)null) { return; } List<PhysGrabber> playerGrabbing = __instance.playerGrabbing; if (playerGrabbing == null || playerGrabbing.Count == 0) { return; } for (int i = 0; i < playerGrabbing.Count; i++) { PhysGrabber val = playerGrabbing[i]; if ((Object)(object)val == (Object)null) { continue; } PlayerAvatar playerAvatar = val.playerAvatar; if (!((Object)(object)playerAvatar == (Object)null)) { string playerName = playerAvatar.playerName; if (!string.IsNullOrEmpty(playerName)) { GrabTracker.Record(((Object)__instance).GetInstanceID(), playerName); break; } } } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] internal static class BreakRPC_Patch { private static void Postfix(PhysGrabObjectImpactDetector __instance) { if ((Object)(object)__instance == (Object)null) { return; } PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>(); if (!((Object)(object)component == (Object)null)) { string text = GrabTracker.Get(((Object)component).GetInstanceID()) ?? "Unknown (gravity/impact)"; string text2 = CleanName(((Object)((Component)__instance).gameObject).name); ValuableObject component2 = ((Component)__instance).GetComponent<ValuableObject>(); bool flag = (Object)(object)component2 != (Object)null; string text3; if (flag) { int num = Mathf.RoundToInt(component2.dollarValueOriginal - component2.dollarValueCurrent); text3 = $"{text} broke {text2}! -${num}"; } else { text3 = text + " broke " + text2 + "!"; } Plugin.Log.LogWarning((object)text3); NotificationOverlay.Instance?.Show(text3, flag); } } private static string CleanName(string raw) { if (string.IsNullOrEmpty(raw)) { return "Object"; } if (!raw.EndsWith("(Clone)")) { return raw; } return raw.Substring(0, raw.Length - "(Clone)".Length).TrimEnd(); } } public class NotificationOverlay : MonoBehaviour { private class Notification { public string Text; public float TimeRemaining; public bool IsValuable; } private const int MaxMessages = 5; private const float DisplayTime = 5f; private const float FadeTime = 1f; private const int FontSize = 22; private const float TopMargin = 80f; private const float LineHeight = 32f; private static readonly Color ValuableColor = new Color(1f, 0.5f, 0.3f); private static readonly Color OrdinaryColor = Color.yellow; private readonly List<Notification> _notifications = new List<Notification>(); private GUIStyle _labelStyle; private GUIStyle _shadowStyle; public static NotificationOverlay Instance { get; private set; } private void Awake() { Instance = this; } public void Show(string text, bool isValuable) { _notifications.Add(new Notification { Text = text, TimeRemaining = 5f, IsValuable = isValuable }); while (_notifications.Count > 5) { _notifications.RemoveAt(0); } } private void Update() { float unscaledDeltaTime = Time.unscaledDeltaTime; for (int num = _notifications.Count - 1; num >= 0; num--) { _notifications[num].TimeRemaining -= unscaledDeltaTime; if (_notifications[num].TimeRemaining <= 0f) { _notifications.RemoveAt(num); } } } private void OnGUI() { //IL_0064: 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_0069: 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_00a6: 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) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (_notifications.Count != 0) { EnsureStyles(); float num = Screen.width; for (int i = 0; i < _notifications.Count; i++) { Notification notification = _notifications[i]; float num2 = ((notification.TimeRemaining < 1f) ? Mathf.Clamp01(notification.TimeRemaining / 1f) : 1f); Color textColor = (notification.IsValuable ? ValuableColor : OrdinaryColor); textColor.a = num2; _labelStyle.normal.textColor = textColor; _shadowStyle.normal.textColor = new Color(0f, 0f, 0f, 0.8f * num2); float num3 = 80f + (float)i * 32f; GUI.Label(new Rect(2f, num3 + 2f, num, 32f), notification.Text, _shadowStyle); GUI.Label(new Rect(0f, num3, num, 32f), notification.Text, _labelStyle); } } } private void EnsureStyles() { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (_labelStyle == null) { _labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 22, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _shadowStyle = new GUIStyle(_labelStyle); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "WhoBrokeIt"; public const string PLUGIN_NAME = "WhoBrokeIt"; public const string PLUGIN_VERSION = "0.1.1"; } }