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 VargheimBuilding v1.0.1
VargheimBuilding.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using VargheimProfessions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VargheimBuilding { [BepInPlugin("digi.vargheim.building", "VargheimBuilding", "1.0.1")] [BepInDependency("digi.vargheim.professions", "0.4.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(WearNTear), "ResetHighlight")] [HarmonyPrefix] private static bool KeepLit(WearNTear __instance) { if (EyeOn) { return !s_lit.Contains(__instance); } return true; } [HarmonyPatch(typeof(Piece), "SetCreator")] [HarmonyPostfix] private static void Placed(Piece __instance) { try { if (!((Object)(object)((Component)__instance).GetComponent<WearNTear>() == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<Ship>() != (Object)null) && Api.HasPerk("Building", FortLevel.Value)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.GetZDO().Set("vp_fort", true); } } } catch { } } [HarmonyPatch(typeof(WearNTear), "RPC_Damage")] [HarmonyPrefix] private static void Damage(WearNTear __instance, HitData hit) { try { if (hit == null) { return; } Character attacker = hit.GetAttacker(); if (!((Object)(object)attacker == (Object)null) && !(attacker is Player) && !attacker.IsTamed()) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO().GetBool("vp_fort", false)) { hit.ApplyModifier(1f - FortCut.Value); } } } catch { } } } public const string Guid = "digi.vargheim.building"; public const string Version = "1.0.1"; private const string Prof = "Building"; internal static ConfigEntry<int> EyeLevel; internal static ConfigEntry<int> FortLevel; internal static ConfigEntry<float> EyeRange; internal static ConfigEntry<float> FortCut; internal static ConfigEntry<KeyboardShortcut> EyeKey; internal static bool EyeOn; private static readonly HashSet<WearNTear> s_lit = new HashSet<WearNTear>(); private float _next; private void Awake() { //IL_009a: 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_00d7: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) EyeLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "BuildersEyeLevel", 40, "Builder's eye level."); EyeRange = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "BuildersEyeRange", 15f, "Builder's eye: show support on pieces within this range."); FortLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "FortifyLevel", 75, "Fortify level."); FortCut = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "FortifyDamageReduction", 0.15f, "Fortify: pieces a builder places take this much less damage from monsters and raids."); EyeKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "BuildersEyeToggle", KeyboardShortcut.Empty, "Your own key to turn Builder's eye on and off (it only shows with a hammer in hand). Off by default; also in the Professions window."); Api.RegisterLadder("Building", "VargheimBuilding 1.0.1", "Modded build pieces (Balrond, FineWood, Glass, More Vanilla Build Prefabs) are for builders, by tier; vanilla pieces stay open. Smoothbrain Building: stronger, tougher pieces and less stamina with level.", (Perk[])(object)new Perk[8] { new Perk(25, "Modded pieces I", "Wood and stone sets from the building mods."), new Perk(30, "Hammer wear", "Hammer wear -30% (Smoothbrain Building)."), new Perk(35, "Modded pieces II", "Stone and iron sets, decorative pieces."), new Perk(EyeLevel.Value, "Builder's eye", "With a hammer in hand, every piece within " + EyeRange.Value + " m shows its support colour. Toggle with your own key (Keys settings) or the button below; off by default."), new Perk(45, "Glass", "Glass pieces."), new Perk(50, "Free pieces", "Chance of free pieces (Smoothbrain Building)."), new Perk(60, "Master mason", "Black marble and late-game modded pieces."), new Perk(FortLevel.Value, "Fortify", "Pieces you place take " + Mathf.RoundToInt(FortCut.Value * 100f) + "% less damage from monsters and raids.") }); Content.AddAction("Building", EyeLevel.Value, "Builder's eye: on / off", (Func<string>)delegate { Toggle(); return (string)null; }); new Harmony("digi.vargheim.building").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VargheimBuilding 1.0.1 loaded."); } private static void Toggle() { EyeOn = !EyeOn; Api.Note("Builder's eye " + (EyeOn ? "on (shows with a hammer in hand)." : "off.")); if (!EyeOn) { Clear(); } } private static void Clear() { List<WearNTear> list = new List<WearNTear>(s_lit); s_lit.Clear(); foreach (WearNTear item in list) { if ((Object)(object)item != (Object)null) { try { Traverse.Create((object)item).Method("ResetHighlight", Array.Empty<object>()).GetValue(); } catch { } } } } private static bool HammerOut(Player p) { ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon(); if (currentWeapon != null && (Object)(object)currentWeapon.m_dropPrefab != (Object)null && (Object)(object)currentWeapon.m_shared.m_buildPieces != (Object)null) { return ((Object)currentWeapon.m_dropPrefab).name.IndexOf("Hammer", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private unsafe void Update() { //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_001f: 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_0040: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } try { KeyboardShortcut value = EyeKey.Value; object obj = KeyboardShortcut.Empty; if (!((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).Equals(obj)) { value = EyeKey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && Api.HasPerk("Building", EyeLevel.Value) && ((Object)(object)Chat.instance == (Object)null || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible()) { Toggle(); } } if (Time.time < _next) { return; } _next = Time.time + 1f; if (!EyeOn || !Api.HasPerk("Building", EyeLevel.Value) || !HammerOut(localPlayer)) { if (s_lit.Count > 0) { Clear(); } return; } Vector3 position = ((Component)localPlayer).transform.position; float value2 = EyeRange.Value; List<WearNTear> list = new List<WearNTear>(); foreach (WearNTear item in s_lit) { if ((Object)(object)item == (Object)null || Vector3.Distance(((Component)item).transform.position, position) > value2) { list.Add(item); } } foreach (WearNTear item2 in list) { s_lit.Remove(item2); if ((Object)(object)item2 != (Object)null) { Traverse.Create((object)item2).Method("ResetHighlight", Array.Empty<object>()).GetValue(); } } foreach (WearNTear allInstance in WearNTear.GetAllInstances()) { if ((Object)(object)allInstance != (Object)null && (Object)(object)((Component)allInstance).GetComponent<Ship>() == (Object)null && Vector3.Distance(((Component)allInstance).transform.position, position) <= value2) { s_lit.Add(allInstance); allInstance.Highlight(); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)ex.Message); } } } }