using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[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 Ratzu.AutoShield
{
[BepInPlugin("ratzu.mods.autoshield", "AutoShield", "1.0.0")]
public class ReviveAllies : BaseUnityPlugin
{
public const string Version = "1.0.0";
public const string Name = "AutoShield";
public const string Guid = "ratzu.mods.autoshield";
public const string Namespace = "RatzuAutoShield";
private Harmony _harmony;
public static ManualLogSource logger;
private void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ratzu.mods.autoshield");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public class Humanoid_Patch
{
[HarmonyPatch(typeof(Humanoid), "EquipItem")]
public static class Humanoid_EquipItem_EquipShieldIfNewlyEquippedItemIsOneHanded
{
public static void Postfix(Humanoid __instance, ref bool __result, ItemData item)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
if (__result && (int)item.m_shared.m_itemType == 3)
{
ShieldEquipper.MaybeEquipShield(__instance, __result);
}
}
}
}
public static class ShieldEquipper
{
public static void MaybeEquipShield(Humanoid humanoid, bool oneHandedWeaponWasEquipped)
{
if (oneHandedWeaponWasEquipped && humanoid.GetLeftItem() == null)
{
List<ItemData> allItems = humanoid.m_inventory.GetAllItems();
ItemData val = allItems.Find((ItemData item) => (int)item.m_shared.m_itemType == 5);
if (val != null)
{
humanoid.EquipItem(val, false);
}
}
}
}
}