using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using CSync.Extensions; using CSync.Lib; using HarmonyLib; using JLLItemsModule.Components; using Microsoft.CodeAnalysis; using MoreShipUpgrades.UpgradeComponents.TierUpgrades; using ProteinPowderAddon.Configuration; using ProteinPowderJLLAddon.NetcodePatcher; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 ProteinPowderJLLAddon { public static class PluginInfo { public const string PLUGIN_GUID = "ProteinPowderJLLAddon"; public const string PLUGIN_NAME = "ProteinPowderJLLAddon"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ProteinPowderAddon { [BepInPlugin("com.whitespike.github.ProteinPowderJLLAddon", "Protein Powder JLL Addon", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class ProteinPowderAddon : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.whitespike.github.ProteinPowderJLLAddon"); internal static ProteinPowderAddon Instance { get; set; } internal ConfigurationFile Configuration { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Configuration = new ConfigurationFile(((BaseUnityPlugin)this).Config); harmony.PatchAll(); } } } namespace ProteinPowderAddon.Utils { public class PluginMetadata { public const string PLUGIN_GUID = "com.whitespike.github.ProteinPowderJLLAddon"; public const string PLUGIN_NAME = "Protein Powder JLL Addon"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ProteinPowderAddon.Patches { [HarmonyPatch(typeof(JMeleeWeapon))] public static class JMeleeWeaponPatcher { [HarmonyTranspiler] [HarmonyPatch("OnWeaponHit")] private static IEnumerable OnWeaponHitTranspiler(IEnumerable instructions) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode != OpCodes.Ldfld) && !((FieldInfo)list[i].operand != typeof(JMeleeWeapon).GetField("HitForce"))) { list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)typeof(JMeleeWeaponPatcher).GetMethod("GetModifiedHitForce"))); list.Insert(i + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); break; } } return list; } public static int GetModifiedHitForce(int originalHitForce, JMeleeWeapon weapon) { if (!CheckAllowedWeapon(weapon)) { return originalHitForce; } return ProteinPowder.GetShovelHitForce(originalHitForce); } public static bool CheckAllowedWeapon(JMeleeWeapon weapon) { if (CheckAllowedWeapon(((GrabbableObject)weapon).itemProperties.itemName)) { return true; } ScanNodeProperties componentInChildren = ((Component)weapon).GetComponentInChildren(); return (Object)(object)componentInChildren != (Object)null && CheckAllowedWeapon(componentInChildren.headerText); } public static bool CheckAllowedWeapon(string weaponName) { string[] array = ProteinPowderAddon.Instance.Configuration.AllowedJLLItems.Value.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Equals(weaponName, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } } namespace ProteinPowderAddon.Configuration { [DataContract] public class ConfigurationFile : SyncedConfig2 { [SyncedEntryField] public SyncedEntry AllowedJLLItems; public ConfigurationFile(ConfigFile config) : base("com.whitespike.github.ProteinPowderJLLAddon") { AllowedJLLItems = SyncedBindingExtensions.BindSyncedEntry(config, "General", "Allowed JLL Items", "example1,example2", "List of items where Protein Powder is allowed to manipulate the damage of items that utilize JLL shovel script.\nThe name listed here can be either the name that shows up when purchased from the store or the name that shows up when scanned."); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace ProteinPowderJLLAddon.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }