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 WiresInstafill v1.0.1
WiresInstafill.dll
Decompiled 2 days agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("WiresInstafill")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WiresInstafill")] [assembly: AssemblyTitle("WiresInstafill")] [assembly: AssemblyVersion("1.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 WiresInstafill { [BepInPlugin("wire.valheim.instafill", "Wire's Instafill", "1.0.1")] [BepInProcess("valheim.exe")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "wire.valheim.instafill"; public const string Name = "Wire's Instafill"; public const string Version = "1.0.1"; internal static Plugin Instance; internal bool IsFilling; private float _bulkSmelterLogUntil; private Harmony _harmony; internal bool ShouldSkipSmelterSuccessLog(object message) { if (message == null || Time.realtimeSinceStartup >= _bulkSmelterLogUntil) { return false; } if (!(message is string text)) { return false; } if (!text.StartsWith("trying to add ", StringComparison.Ordinal)) { return text.StartsWith("Added ore ", StringComparison.Ordinal); } return true; } private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; _harmony = new Harmony("wire.valheim.instafill"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wire's Instafill 1.0.1 loaded."); } internal void BeginFill(Player player, GameObject hover, bool alt) { if (!IsFilling && !((Object)(object)player == (Object)null) && !((Object)(object)hover == (Object)null)) { Interactable componentInParent = hover.GetComponentInParent<Interactable>(); MonoBehaviour val = (MonoBehaviour)(object)((componentInParent is MonoBehaviour) ? componentInParent : null); if (componentInParent != null && !((Object)(object)val == (Object)null)) { ((MonoBehaviour)this).StartCoroutine(FillRoutine(player, componentInParent, val, alt, (Object)(object)hover.GetComponentInParent<Smelter>() != (Object)null)); } } } private IEnumerator FillRoutine(Player player, Interactable interactable, MonoBehaviour behaviour, bool alt, bool smelter) { IsFilling = true; try { for (int i = 0; i < 1024; i++) { if ((Object)(object)player == (Object)null) { break; } if ((Object)(object)behaviour == (Object)null) { break; } if (((Character)player).IsDead()) { break; } if (smelter) { _bulkSmelterLogUntil = Time.realtimeSinceStartup + 1f; } if (!interactable.Interact((Humanoid)(object)player, false, alt)) { break; } yield return null; } } finally { IsFilling = false; } } private void OnDestroy() { ((MonoBehaviour)this).StopAllCoroutines(); if (_harmony != null) { _harmony.UnpatchSelf(); } Instance = null; } } [HarmonyPatch(typeof(Player), "Interact")] internal static class ShiftUseInstafillPatch { [HarmonyPrefix] private static bool Prefix(Player __instance, GameObject go, bool hold, bool alt) { if ((Object)(object)__instance == (Object)null || (Object)(object)go == (Object)null || (Object)(object)Plugin.Instance == (Object)null || !IsShiftHeld() || !IsSupportedRefillTarget(go)) { return true; } if (Plugin.Instance.IsFilling) { return false; } if (hold) { return false; } Plugin.Instance.BeginFill(__instance, go, alt); return false; } private static bool IsShiftHeld() { if (!Input.GetKey((KeyCode)304)) { return Input.GetKey((KeyCode)303); } return true; } private static bool IsSupportedRefillTarget(GameObject go) { if (!((Object)(object)go.GetComponentInParent<Smelter>() != (Object)null) && !((Object)(object)go.GetComponentInParent<Fireplace>() != (Object)null) && !((Object)(object)go.GetComponentInParent<CookingStation>() != (Object)null) && !((Object)(object)go.GetComponentInParent<Fermenter>() != (Object)null) && !((Object)(object)go.GetComponentInParent<Turret>() != (Object)null) && !((Object)(object)go.GetComponentInParent<ShieldGenerator>() != (Object)null)) { return (Object)(object)go.GetComponentInParent<Catapult>() != (Object)null; } return true; } } [HarmonyPatch(typeof(ZLog), "Log", new Type[] { typeof(object) })] internal static class SmelterBulkLogFilter { [HarmonyPrefix] private static bool Prefix(object o) { Plugin instance = Plugin.Instance; if (!((Object)(object)instance == (Object)null)) { return !instance.ShouldSkipSmelterSuccessLog(o); } return true; } } }