Decompiled source of SpiritOfSirocco v1.3.0

plugins/SpiritOfNewSirocco.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SpiritOfSirocco;

public static class ConfigElements
{
	public static ConfigEntry<bool> includeImmunityToLifeDrain;

	public static void Init(ConfigFile config)
	{
		includeImmunityToLifeDrain = config.Bind<bool>("Spirit of New Sirocco", "Include Immunity To Life Drain", false, (ConfigDescription)null);
	}
}
[BepInPlugin("johbenji.spiritofsirocco", "Spirit of Sirocco", "1.0.0")]
public class SpiritOfSiroccoPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffectBuildUp")]
	[HarmonyPatch(new Type[]
	{
		typeof(StatusEffect),
		typeof(float),
		typeof(Character)
	})]
	private class StatusEffectMalusImmunityPatchBuildup
	{
		[HarmonyPrefix]
		public static bool Prefix(StatusEffect _statusEffect, float _buildUp, Character _dealerChar, Character ___m_character)
		{
			return checkIfValid(___m_character, _statusEffect);
		}
	}

	[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffect")]
	[HarmonyPatch(new Type[]
	{
		typeof(StatusEffect),
		typeof(Character),
		typeof(string[])
	})]
	private class StatusEffectMalusImmunityPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(StatusEffect _statusEffect, Character _dealer, string[] _loadData, Character ___m_character)
		{
			return checkIfValid(___m_character, _statusEffect);
		}
	}

	public const string GUID = "johbenji.spiritofsirocco";

	public const string NAME = "Spirit of Sirocco";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	internal void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		ConfigElements.Init(((BaseUnityPlugin)this).Config);
		new Harmony("johbenji.spiritofsirocco").PatchAll();
	}

	private static bool checkIfValid(Character character, StatusEffect statuseffect)
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Expected O, but got Unknown
		if (character.IsLocalPlayer && character.Initialized && statuseffect.IsMalusEffect && (statuseffect.m_purgeable || (((Object)statuseffect).name == "Life Drain" && ConfigElements.includeImmunityToLifeDrain.Value)))
		{
			GameObject gameObject = ((Component)character).gameObject;
			if ((Object)(object)gameObject != (Object)null)
			{
				CharacterInventory component = gameObject.GetComponent<CharacterInventory>();
				if ((Object)(object)component != (Object)null)
				{
					CharacterEquipment equipment = component.Equipment;
					if ((Object)(object)equipment != (Object)null)
					{
						EquipmentSlot[] equipmentSlots = equipment.EquipmentSlots;
						if (equipmentSlots != null && equipmentSlots.Length > 2)
						{
							EquipmentSlot val = equipmentSlots[1];
							if ((Object)(object)equipmentSlots[1] != (Object)null)
							{
								Armor val2 = (Armor)val.EquippedItem;
								if ((Object)(object)val2 != (Object)null && ((Equipment)val2).m_enchantmentIDs.Contains(-65003))
								{
									return false;
								}
							}
						}
					}
				}
			}
		}
		return true;
	}
}