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 Venture Area Repair v1.0.0
Plugins/VentureValheim.AreaRepair.dll
Decompiled 6 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; 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: AssemblyTitle("VentureValheim.AreaRepair")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.AreaRepair")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("CD8A336E-516B-4603-982F-8BFE41799896")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VentureValheim.AreaRepair { [BepInPlugin("com.orianaventure.mod.VentureAreaRepair", "VentureAreaRepair", "1.0.0")] public class AreaRepairPlugin : BaseUnityPlugin { private const string ModName = "VentureAreaRepair"; private const string ModVersion = "1.0.0"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.VentureAreaRepair"; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.VentureAreaRepair"); public static readonly ManualLogSource AreaRepairLogger = Logger.CreateLogSource("VentureAreaRepair"); public void Awake() { AreaRepairLogger.LogInfo((object)"Click, click, click, click."); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); } } public class AreaRepair { [HarmonyPatch(typeof(Player), "Repair")] private static class Patch_Player_Repair { private static void Postfix(Player __instance, ItemData toolItem) { //IL_0045: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_016e: Unknown result type (might be due to invalid IL or missing references) if (AltKeyPressed || ((Humanoid)__instance).GetRightItem() == null) { return; } float buildStamina = __instance.GetBuildStamina(); if (!((Character)__instance).HaveStamina(buildStamina)) { return; } Piece hoveringPiece = __instance.GetHoveringPiece(); Vector3 position = (((Object)(object)hoveringPiece != (Object)null) ? ((Component)hoveringPiece).transform.position : ((Component)__instance).transform.position); int num = 0; List<KeyValuePair<Piece, float>> allPiecesInRadius = GetAllPiecesInRadius(position, 20f); allPiecesInRadius = allPiecesInRadius.OrderBy((KeyValuePair<Piece, float> p) => p.Value).ToList(); bool freePlacement = __instance.m_noPlacementCost || ZoneSystem.instance.GetGlobalKey((GlobalKeys)27); float num2 = toolItem.m_shared.m_useDurabilityDrain * Game.m_durabilityRate; for (int num3 = 0; num3 < allPiecesInRadius.Count; num3++) { Piece key = allPiecesInRadius[num3].Key; WearNTear component = ((Component)key).GetComponent<WearNTear>(); if ((Object)(object)component == (Object)null || !CheckCanRepair(((Component)__instance).transform.position, key, 20f, freePlacement)) { continue; } if (component.Repair()) { if (!__instance.m_noPlacementCost) { ((Character)__instance).UseStamina(buildStamina); ((Character)__instance).UseEitr(toolItem.m_shared.m_attack.m_attackEitr); if (toolItem.m_shared.m_useDurability) { toolItem.m_durability -= num2; } } key.m_placeEffect.Create(((Component)key).transform.position, ((Component)key).transform.rotation, (Transform)null, 1f, -1, ((Character)__instance).GetZDOID()); num++; } if (!__instance.m_noPlacementCost && (!((Character)__instance).HaveStamina(buildStamina) || toolItem.m_durability < num2)) { break; } } if (num > 0) { __instance.FaceLookDirection(); ((Character)__instance).m_zanim.SetTrigger(toolItem.m_shared.m_attack.m_attackAnimation); ((Character)__instance).Message((MessageType)1, Localization.instance.Localize("$msg_repaired", new string[1] { num.ToString() }), 0, (Sprite)null, false); } TempStationsInRange.Clear(); } } [HarmonyPatch(typeof(Player))] private static class PlayerPatch { [HarmonyTranspiler] [HarmonyPatch(typeof(Player), "Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Player), "UpdateHover", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Player.Update()!") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "UpdateInputDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void UpdateInputDelegate(Player player, bool takeInput) { AltKeyPressed = takeInput && ZInput.GetKey((KeyCode)308, true); } } private const float RADIUS = 20f; private static bool AltKeyPressed = false; private static Dictionary<string, bool> TempStationsInRange = new Dictionary<string, bool>(); public static List<KeyValuePair<Piece, float>> GetAllPiecesInRadius(Vector3 position, float radius) { //IL_001b: 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) List<KeyValuePair<Piece, float>> list = new List<KeyValuePair<Piece, float>>(); foreach (Piece s_allPiece in Piece.s_allPieces) { float num = Vector3.Distance(position, ((Component)s_allPiece).transform.position); if (((Component)s_allPiece).gameObject.layer != Piece.s_ghostLayer && num <= radius) { list.Add(new KeyValuePair<Piece, float>(s_allPiece, num)); } } return list; } public static bool CheckCanRepair(Vector3 playerPosition, Piece piece, float radius, bool freePlacement) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!freePlacement && (Object)(object)piece.m_craftingStation != (Object)null) { if (!TempStationsInRange.ContainsKey(piece.m_craftingStation.m_name)) { TempStationsInRange.Add(piece.m_craftingStation.m_name, Object.op_Implicit((Object)(object)CraftingStation.HaveBuildStationInRange(piece.m_craftingStation.m_name, playerPosition))); } if (!TempStationsInRange[piece.m_craftingStation.m_name]) { return false; } } return PrivateArea.CheckAccess(((Component)piece).transform.position, 0f, true, false); } } }