Decompiled source of NPC Weapons v3.0.0

plugins/JohBenjiNPCWeapons.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JohBenjiNPCWeapons;
using NodeCanvas.DialogueTrees;
using NodeCanvas.Framework;
using NodeCanvas.Tasks.Actions;
using SideLoader;
using SideLoader.Animation;
using SideLoader.Model;
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("JohBenjiNPCWeapons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JohBenjiNPCWeapons")]
[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]
public class AxeOfGiantKindPatch : NPCWeaponPatchClass
{
	public AxeOfGiantKindPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (Object.op_Implicit((Object)(object)Item))
		{
			Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
			if (Object.op_Implicit((Object)(object)itemVisual))
			{
				Transform val = ((Component)itemVisual).transform.Find("OffHand");
				GameObject gameObject = ((Component)val).gameObject;
				Object.Destroy((Object)(object)gameObject);
			}
		}
	}
}
public class BloodSpearPatch : NPCWeaponPatchClass
{
	public BloodSpearPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		Object.Destroy((Object)(object)((Component)Item).GetComponent<DestroyOnOwnerDeath>());
		GameObject gameObject = ((Component)Item).gameObject;
		if (Object.op_Implicit((Object)(object)gameObject))
		{
			GameObject val = new GameObject();
			((Object)val).name = "InteractionHolder";
			InteractionActivator val2 = val.AddComponent<InteractionActivator>();
			InteractionTake val3 = val.AddComponent<InteractionTake>();
			InteractionTriggerBase val4 = val.AddComponent<InteractionTriggerBase>();
			val.transform.parent = gameObject.transform;
			MeleeWeapon component = gameObject.GetComponent<MeleeWeapon>();
			((Item)component).m_interactionActivator = val2;
			((Item)component).m_interactionTrigger = val4;
			val2.BasicInteraction = (IInteraction)(object)gameObject.AddComponent<ItemInteraction>();
			val2.m_defaultBasicInteraction = (IInteraction)(object)val3;
			val2.m_itemPreview = (Item)(object)component;
			val2.m_sceneBasicInteraction = (InteractionBase)(object)val3;
			val2.m_showItemPreview = true;
			val2.tmp = (IItemInteraction)(object)val3;
			val4.m_detectionColliderRadius = 0.1f;
			val4.m_isEnvironmentTrigger = false;
			val4.m_isItemInteractionTrigger = true;
			val4.m_parentItem = (Item)(object)component;
		}
	}
}
public class BloodSwordPatch : NPCWeaponPatchClass
{
	public BloodSwordPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		Object.Destroy((Object)(object)((Component)Item).GetComponent<DestroyOnOwnerDeath>());
		GameObject gameObject = ((Component)Item).gameObject;
		if (Object.op_Implicit((Object)(object)gameObject))
		{
			GameObject val = new GameObject();
			((Object)val).name = "InteractionHolder";
			InteractionActivator val2 = val.AddComponent<InteractionActivator>();
			InteractionTake val3 = val.AddComponent<InteractionTake>();
			InteractionTriggerBase val4 = val.AddComponent<InteractionTriggerBase>();
			val.transform.parent = gameObject.transform;
			MeleeWeapon component = gameObject.GetComponent<MeleeWeapon>();
			((Item)component).m_interactionActivator = val2;
			((Item)component).m_interactionTrigger = val4;
			val2.BasicInteraction = (IInteraction)(object)gameObject.AddComponent<ItemInteraction>();
			val2.m_defaultBasicInteraction = (IInteraction)(object)val3;
			val2.m_itemPreview = (Item)(object)component;
			val2.m_sceneBasicInteraction = (InteractionBase)(object)val3;
			val2.m_showItemPreview = true;
			val2.tmp = (IItemInteraction)(object)val3;
			val4.m_detectionColliderRadius = 0.1f;
			val4.m_isEnvironmentTrigger = false;
			val4.m_isItemInteractionTrigger = true;
			val4.m_parentItem = (Item)(object)component;
		}
	}
}
public class CageFistPatch : NPCWeaponPatchClass
{
	public CageFistPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Item))
		{
			return;
		}
		SLPack sLPack = SL.GetSLPack("johbenji-npcweapons");
		if (sLPack == null)
		{
			return;
		}
		GameObject val = SL.GetSLPack("johbenji-npcweapons").AssetBundles["cagefisteffect"].LoadAsset<GameObject>("CageFistFX");
		GameObject val2 = SL.GetSLPack("johbenji-npcweapons").AssetBundles["cagefisteffect"].LoadAsset<GameObject>("CageFistFX");
		if (!((Object)(object)val != (Object)null) || !((Object)(object)val2 != (Object)null))
		{
			return;
		}
		GameObject val3 = Object.Instantiate<GameObject>(val);
		GameObject val4 = Object.Instantiate<GameObject>(val2);
		Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
		if ((Object)(object)itemVisual != (Object)null)
		{
			Transform val5 = itemVisual;
			Transform val6 = ((Component)itemVisual).transform.Find("WeaponModel");
			Transform val7 = ((Component)itemVisual).transform.Find("LeftHandModel");
			if ((Object)(object)val6 != (Object)null && (Object)(object)val7 != (Object)null)
			{
				val3.transform.parent = val6;
				val4.transform.parent = val7;
				val3.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
				val3.transform.localPosition = new Vector3(-0.02f, 0f, -0.01f);
				val4.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
				val4.transform.localPosition = new Vector3(0f, 0f, -0.02f);
			}
		}
	}
}
public class DisplacementConfig
{
	public Vector3 StartPosition = Vector3.right;

	public Vector3 EndPosition = Vector3.right;

	public float maxspeed;

	public float initiallength;

	public float totallength;

	public Transform DisplacementObject;
}
public class DjinnsChakram : NPCWeaponPatchClass
{
	public DjinnsChakram(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (!Object.op_Implicit((Object)(object)Item))
		{
			return;
		}
		Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
		if (!Object.op_Implicit((Object)(object)itemVisual))
		{
			return;
		}
		Transform val = ((Component)itemVisual).transform.Find("Model");
		if (Object.op_Implicit((Object)(object)val))
		{
			Rotator val2 = ((Component)val).gameObject.AddComponent<Rotator>();
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.rot_speed_x = 100f;
				val2.rot_speed_y = 0f;
				val2.rot_speed_z = 0f;
				val2.local = true;
			}
		}
	}
}
public class GenericAddComponentPatch<T> : NPCWeaponPatchClass where T : MonoBehaviour
{
	public GenericAddComponentPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
		if (Object.op_Implicit((Object)(object)Item))
		{
			T val = ((Component)itemVisual).gameObject.AddComponent<T>();
		}
	}
}
public class GoldenLichCannonPatch : NPCWeaponPatchClass
{
	public GoldenLichCannonPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (Object.op_Implicit((Object)(object)Item))
		{
			Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
			Transform val = ((Component)itemVisual).transform.Find("GoldLichCannon(Clone)");
			MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(2000080);
			Transform itemVisual2 = itemPrefab.GetItemVisual(itemPrefab.HasSpecialVisualPrefab);
			Transform val2 = ((Component)itemVisual2).transform.Find("Sword");
			MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
			Material[] array = (Material[])(object)new Material[((Renderer)component).materials.Length];
			array[0] = ((Renderer)component2).materials[0];
			array[1] = ((Renderer)component).materials[1];
			array[2] = ((Renderer)component2).materials[0];
			array[3] = ((Renderer)component2).materials[0];
			((Renderer)component).materials = array;
		}
	}
}
public class MarbleParryAxePatch : NPCWeaponPatchClass
{
	public MarbleParryAxePatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (Object.op_Implicit((Object)(object)Item))
		{
			Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
			Transform val = ((Component)itemVisual).transform.Find("AxeGreat");
			((Object)val).name = "shield";
			Transform val2 = ((Component)itemVisual).transform.Find("OffHand");
			Object.Destroy((Object)(object)((Component)val2).gameObject);
			Transform val3 = ((Component)itemVisual).transform.Find("Trail");
			Object.Destroy((Object)(object)((Component)val3).gameObject);
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(2300000);
			Transform itemVisual2 = itemPrefab.GetItemVisual(itemPrefab.HasSpecialVisualPrefab);
			Transform val4 = ((Component)itemVisual2).transform.Find("RangeBlock");
			GameObject val5 = Object.Instantiate<GameObject>(((Component)val4).gameObject);
			val5.transform.parent = itemVisual;
			Transform val6 = ((Component)itemVisual).transform.Find("RangeBlock(Clone)");
			((Object)val6).name = "RangeBlock";
		}
	}
}
public abstract class NPCWeaponPatchClass
{
	protected Item ItemReference;

	public event Action<Item> OnPatchComplete;

	protected NPCWeaponPatchClass(Item itemReference)
	{
		ItemReference = itemReference;
		if ((Object)(object)itemReference != (Object)null)
		{
			global::JohBenjiNPCWeapons.JohBenjiNPCWeapons.Log.LogMessage((object)("Patching Item : " + itemReference.Name));
			PatchItem(itemReference);
			this.OnPatchComplete?.Invoke(itemReference);
			global::JohBenjiNPCWeapons.JohBenjiNPCWeapons.Log.LogMessage((object)"Patching Complete.");
		}
	}

	public abstract void PatchItem(Item Item);

	public virtual void AddInteractorToItem(Item Item)
	{
	}
}
public class RingRotationConfig
{
	public float Speed;

	public Vector3 Axis = Vector3.right;

	public Transform Ring;
}
public class ScarletFangKnucklesPatch : NPCWeaponPatchClass
{
	public ScarletFangKnucklesPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (Object.op_Implicit((Object)(object)Item))
		{
			Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
			Transform val = ((Component)itemVisual).transform.Find("ScarletFangKnuckles(Clone)");
			MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
			MeshRenderer component2 = ((Component)val).GetComponent<MeshRenderer>();
			Transform val2 = ((Component)itemVisual).transform.Find("LeftHandModel");
			MeshFilter component3 = ((Component)val2).GetComponent<MeshFilter>();
			MeshRenderer component4 = ((Component)val2).GetComponent<MeshRenderer>();
			component3.mesh = component.mesh;
			component3.sharedMesh = component.sharedMesh;
			((Renderer)component4).material = ((Renderer)component2).material;
			((Renderer)component4).materials[0] = ((Renderer)component2).materials[0];
		}
	}
}
public class WolfTowerShieldPatch : NPCWeaponPatchClass
{
	public WolfTowerShieldPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		if (Object.op_Implicit((Object)(object)Item))
		{
			Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
			Transform val = ((Component)itemVisual).transform.Find("WolfTowerShield(Clone)");
			MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
			Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(2100010);
			Transform itemVisual2 = itemPrefab.GetItemVisual(itemPrefab.HasSpecialVisualPrefab);
			Transform val2 = ((Component)itemVisual2).transform.Find("mdl_itm_prayerClaymore");
			MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
			((Renderer)component).material = ((Renderer)component2).material;
			((Renderer)component).materials[0] = ((Renderer)component2).materials[0];
		}
	}
}
namespace JohBenjiNPCWeapons;

public class SL_ChangeImbueLifeSpan : SL_Effect, ICustomModel
{
	public float LifeSpan;

	public Type SLTemplateModel => typeof(SL_ChangeImbueLifeSpan);

	public Type GameModel => typeof(ChangeImbueLifeSpan);

	public override void ApplyToComponent<T>(T component)
	{
		ChangeImbueLifeSpan changeImbueLifeSpan = component as ChangeImbueLifeSpan;
		changeImbueLifeSpan.LifeSpan = LifeSpan;
	}

	public override void SerializeEffect<T>(T effect)
	{
		ChangeImbueLifeSpan changeImbueLifeSpan = effect as ChangeImbueLifeSpan;
		LifeSpan = changeImbueLifeSpan.LifeSpan;
	}
}
public class ChangeImbueLifeSpan : Effect
{
	public float LifeSpan;

	private float imbueLifeSpan;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected O, but got Unknown
		if (!((Object)(object)_affectedCharacter != (Object)null) || !((Object)(object)_affectedCharacter.CurrentWeapon != (Object)null) || !(((object)_affectedCharacter.CurrentWeapon).GetType() == typeof(MeleeWeapon)))
		{
			return;
		}
		MeleeWeapon val = (MeleeWeapon)_affectedCharacter.CurrentWeapon;
		if (!((Weapon)val).Imbued)
		{
			return;
		}
		ImbueStack firstImbue = ((Weapon)val).FirstImbue;
		if (firstImbue != null)
		{
			imbueLifeSpan = firstImbue.RemainingLifespan;
			if (((Effect)this).Lifespan < firstImbue.RemainingLifespan)
			{
				firstImbue.RemainingLifespan = imbueLifeSpan + LifeSpan;
			}
			else
			{
				firstImbue.RemainingLifespan = 0.1f;
			}
		}
	}
}
internal class DTAppend
{
	private List<Character> charactersSquad;

	private List<Character> charactersSquad2;

	private List<Character> charactersStatic;

	private List<Character> characters;

	private Dropable[] modifiedList;

	public void Apply(Dictionary<string, Tuple<string, SL_DropTable>> inputdictionary)
	{
		JohBenjiNPCWeapons.Log.LogMessage((object)"JohBenjiNPCWeapons: Initiating function Apply() of class DTAppend");
		charactersSquad = GetCharactersFromAISquads();
		charactersSquad2 = GetCharactersFromAISquads2();
		charactersStatic = GetCharactersFromStaticContainer();
		characters = charactersSquad.Concat(charactersSquad2).Concat(charactersStatic).ToList();
		foreach (Character character in characters)
		{
			GameObject gameObject = ((Component)character).gameObject;
			foreach (KeyValuePair<string, Tuple<string, SL_DropTable>> item3 in inputdictionary)
			{
				string key = item3.Key;
				SL_DropTable item = item3.Value.Item2;
				if (!(character.Name == key) || !character.Alive)
				{
					continue;
				}
				LootableOnDeath component = gameObject.GetComponent<LootableOnDeath>();
				if ((Object)(object)component != (Object)null && !component.m_lootable)
				{
					component.m_lootable = true;
				}
				CharacterInventory component2 = gameObject.GetComponent<CharacterInventory>();
				if (!((Object)(object)component2 != (Object)null))
				{
					continue;
				}
				GameObject gameObject2 = ((Component)component2.Pouch).gameObject;
				List<int> list = new List<int>();
				Transform transform = gameObject2.transform;
				List<Transform> list2 = new List<Transform>();
				for (int i = 0; i < transform.childCount; i++)
				{
					Transform child = transform.GetChild(i);
					ItemStats component3 = ((Component)child).gameObject.GetComponent<ItemStats>();
					if ((Object)(object)component3 != (Object)null)
					{
						Item item2 = component3.m_item;
						string itemIDString = item2.ItemIDString;
						list.Add(int.Parse(itemIDString));
					}
				}
				List<SL_ItemDrop> guaranteedDrops = item.GuaranteedDrops;
				if (guaranteedDrops.Count <= 0)
				{
					continue;
				}
				foreach (SL_ItemDrop item4 in guaranteedDrops)
				{
					int droppedItemID = item4.DroppedItemID;
					if (!IsIntegerInList(droppedItemID, list))
					{
						GameObject gameObject3 = ((Component)ResourcesPrefabManager.Instance.GetItemPrefab(droppedItemID)).gameObject;
						Object.Instantiate<GameObject>(gameObject3).transform.parent = gameObject2.transform;
						JohBenjiNPCWeapons.Log.LogMessage((object)$"JohBenjiNPCWeapons: Added item of UID:{droppedItemID} to {character.Name}");
					}
				}
			}
		}
	}

	private List<Character> GetCharactersFromAISquads()
	{
		List<Character> list = new List<Character>();
		foreach (AISquad value in AISquadManager.Instance.m_allSquads.Values)
		{
			foreach (AISquadMember member in value.Members)
			{
				list.Add(member.Character);
			}
		}
		JohBenjiNPCWeapons.Log.LogMessage((object)$"JohBenjiNPCWeapons: {list.Count} Characters found from GetCharactersFromAISquads()");
		return list;
	}

	private List<Character> GetCharactersFromAISquads2()
	{
		List<Character> list = new List<Character>();
		foreach (CharacterAI item in AISceneManager.Instance.m_characterAI)
		{
			Character character = ((CharacterControl)item).Character;
			if ((Object)(object)character != (Object)null)
			{
				list.Add(character);
			}
		}
		JohBenjiNPCWeapons.Log.LogMessage((object)$"JohBenjiNPCWeapons: {list.Count} Characters found from GetCharactersFromAISquads2()");
		return list;
	}

	private List<Character> GetCharactersFromStaticContainer()
	{
		List<Character> list = new List<Character>();
		Transform val = ((Component)AISceneManager.Instance).transform.Find("StaticEnemies");
		if (Object.op_Implicit((Object)(object)val))
		{
			CharacterAI[] componentsInChildren = ((Component)val).GetComponentsInChildren<CharacterAI>();
			foreach (CharacterAI val2 in componentsInChildren)
			{
				list.Add(((CharacterControl)val2).Character);
			}
			JohBenjiNPCWeapons.Log.LogMessage((object)$"JohBenjiNPCWeapons: {list.Count} Characters found from GetCharactersFromStaticContainer()");
		}
		else
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)"JohBenjiNPCWeapons: Static Enemy Container not found");
		}
		return list;
	}

	private static T[] AddArrayElement<T>(T[] array, T element)
	{
		List<T> list = new List<T>(array);
		list.Add(element);
		return list.ToArray();
	}

	private bool CheckForChildrenWithName(Transform transform, string checkname)
	{
		for (int i = 0; i < transform.childCount; i++)
		{
			Transform child = transform.GetChild(i);
			if (((Object)child).name == checkname)
			{
				return true;
			}
		}
		return false;
	}

	public static bool IsIntegerInList(int targetInteger, List<int> integerList)
	{
		return integerList.Contains(targetInteger);
	}
}
public class DTLoadByName : MonoBehaviour
{
	public Dictionary<string, Tuple<string, SL_DropTable>> Load(Dictionary<string, Tuple<string, SL_DropTable>> dictionary)
	{
		dictionary = LoadDropTables(dictionary);
		return dictionary;
	}

	private Dictionary<string, Tuple<string, SL_DropTable>> LoadDropTables(Dictionary<string, Tuple<string, SL_DropTable>> incompleteDictionary)
	{
		string text = "DropTables";
		string[] xMLFilePaths = getXMLFilePaths(text);
		JohBenjiNPCWeapons.Log.LogMessage((object)$"JohBenjiNPCWeapons: in directory [{text}], [{xMLFilePaths.Length}] xml(s) were found.");
		List<SL_DropTable> list = new List<SL_DropTable>();
		string[] array = xMLFilePaths;
		foreach (string text2 in array)
		{
			string text3 = text2;
			SL_DropTable val = null;
			try
			{
				val = DeserializeFromXML<SL_DropTable>(text3);
			}
			catch (Exception ex)
			{
				JohBenjiNPCWeapons.Log.LogMessage((object)("Failed To deserialize file " + text3 + " exception -> \r\n " + ex.Message + " "));
			}
			if (val != null)
			{
				JohBenjiNPCWeapons.Log.LogMessage((object)("Created Droptable from the definition, UID : " + val.UID + "."));
				list.Add(val);
			}
		}
		Dictionary<string, Tuple<string, SL_DropTable>> dictionary = incompleteDictionary.ToDictionary((KeyValuePair<string, Tuple<string, SL_DropTable>> x) => x.Key, (KeyValuePair<string, Tuple<string, SL_DropTable>> x) => x.Value);
		foreach (string key in dictionary.Keys)
		{
			if (!incompleteDictionary.ContainsKey(key))
			{
				continue;
			}
			Tuple<string, SL_DropTable> tuple = incompleteDictionary[key];
			if (tuple == null)
			{
				continue;
			}
			string item = tuple.Item1;
			foreach (SL_DropTable item2 in list)
			{
				if (item == item2.UID)
				{
					incompleteDictionary[key] = new Tuple<string, SL_DropTable>(incompleteDictionary[key].Item1, item2);
					break;
				}
			}
		}
		return incompleteDictionary;
	}

	private string[] getXMLFilePaths(string sl_FolderName)
	{
		string location = ((BaseUnityPlugin)JohBenjiNPCWeapons.Instance).Info.Location;
		string directoryName = Path.GetDirectoryName(location);
		string text = directoryName + "\\Sideloader\\" + sl_FolderName + "\\";
		JohBenjiNPCWeapons.Log.LogMessage((object)("JohBenjiNPCWeapons: Getting the folder '" + text + "'"));
		if (!HasFolder(text))
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)"JohBenjiNPCWeapons: DropTables Folder does not exist, creating folder...");
			Directory.CreateDirectory(text);
		}
		return Directory.GetFiles(text, "*.xml", SearchOption.AllDirectories);
	}

	private bool HasFolder(string FolderLocation)
	{
		return Directory.Exists(FolderLocation);
	}

	public T DeserializeFromXML<T>(string path)
	{
		XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
		StreamReader streamReader = new StreamReader(path);
		T result = (T)xmlSerializer.Deserialize(streamReader.BaseStream);
		streamReader.Close();
		return result;
	}
}
public class SL_IsAllied : SL_EffectCondition, ICustomModel
{
	public Type SLTemplateModel => typeof(SL_IsAllied);

	public Type GameModel => typeof(IsAllied);

	public override void ApplyToComponent<T>(T component)
	{
		IsAllied isAllied = component as IsAllied;
	}

	public override void SerializeEffect<T>(T component)
	{
		IsAllied isAllied = component as IsAllied;
	}
}
public class IsAllied : EffectCondition
{
	private Character[] characters;

	public override bool CheckIsValid(Character _affectedCharacter)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Invalid comparison between Unknown and I4
		characters = CharacterManager.Instance.Characters.ValuesArray;
		int num = characters.Length;
		Character[] array = characters;
		foreach (Character val in array)
		{
			if ((Object)(object)_affectedCharacter == (Object)(object)val && (int)val.Faction == 1)
			{
				return true;
			}
		}
		return false;
	}
}
public class SL_IsPlayerCharacter : SL_EffectCondition, ICustomModel
{
	public Type SLTemplateModel => typeof(SL_IsPlayerCharacter);

	public Type GameModel => typeof(IsPlayerCharacter);

	public override void ApplyToComponent<T>(T component)
	{
		IsPlayerCharacter isPlayerCharacter = component as IsPlayerCharacter;
	}

	public override void SerializeEffect<T>(T component)
	{
		IsPlayerCharacter isPlayerCharacter = component as IsPlayerCharacter;
	}
}
public class IsPlayerCharacter : EffectCondition
{
	public override bool CheckIsValid(Character _affectedCharacter)
	{
		return _affectedCharacter.IsLocalPlayer;
	}
}
public class SL_ImbueDamageTypeCondition : SL_EffectCondition, ICustomModel
{
	public Types DamageType;

	public Type SLTemplateModel => typeof(SL_ImbueDamageTypeCondition);

	public Type GameModel => typeof(ImbueDamageTypeCondition);

	public override void ApplyToComponent<T>(T component)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		ImbueDamageTypeCondition imbueDamageTypeCondition = component as ImbueDamageTypeCondition;
		imbueDamageTypeCondition.DamageType = DamageType;
	}

	public override void SerializeEffect<T>(T component)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		ImbueDamageTypeCondition imbueDamageTypeCondition = component as ImbueDamageTypeCondition;
		imbueDamageTypeCondition.DamageType = DamageType;
	}
}
public class ImbueDamageTypeCondition : EffectCondition
{
	public Types DamageType;

	public override bool CheckIsValid(Character _affectedCharacter)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		Weapon currentWeapon = _affectedCharacter.CurrentWeapon;
		if ((Object)(object)currentWeapon != (Object)null)
		{
			MeleeWeapon val = (MeleeWeapon)currentWeapon;
			if ((Object)(object)val != (Object)null && ((Weapon)val).Imbued)
			{
				ImbueStack firstImbue = currentWeapon.FirstImbue;
				if (firstImbue != null)
				{
					Effect[] imbuedEffects = firstImbue.ImbuedEffects;
					if (imbuedEffects != null)
					{
						Effect[] array = imbuedEffects;
						for (int i = 0; i < array.Length; i++)
						{
							WeaponDamage val2 = (WeaponDamage)array[i];
							if ((Object)(object)val2 != (Object)null)
							{
								Types overrideDType = val2.OverrideDType;
								if (overrideDType == DamageType)
								{
									return true;
								}
							}
						}
					}
				}
			}
		}
		return false;
	}
}
public class SL_HasMana : SL_EffectCondition, ICustomModel
{
	public float Value;

	public bool CheckPercent;

	public bool IgnoreBurntForPercent;

	public Type SLTemplateModel => typeof(SL_HasMana);

	public Type GameModel => typeof(HasMana);

	public override void ApplyToComponent<T>(T component)
	{
		HasMana hasMana = component as HasMana;
		hasMana.Value = Value;
		hasMana.CheckPercent = CheckPercent;
		hasMana.IgnoreBurntForPercent = IgnoreBurntForPercent;
	}

	public override void SerializeEffect<T>(T component)
	{
		HasMana hasMana = component as HasMana;
		hasMana.Value = Value;
		hasMana.CheckPercent = CheckPercent;
		hasMana.IgnoreBurntForPercent = IgnoreBurntForPercent;
	}
}
public class HasMana : EffectCondition
{
	public float Value;

	public bool CheckPercent;

	public bool IgnoreBurntForPercent;

	public override bool CheckIsValid(Character _affectedCharacter)
	{
		if (!Object.op_Implicit((Object)(object)_affectedCharacter) || !Object.op_Implicit((Object)(object)_affectedCharacter.Stats))
		{
			return false;
		}
		float currentMana = _affectedCharacter.Stats.CurrentMana;
		if (CheckPercent)
		{
			float num = (IgnoreBurntForPercent ? _affectedCharacter.Stats.ActiveMaxMana : _affectedCharacter.Stats.MaxMana);
			float num2 = num * Value * 0.01f;
			return currentMana >= num2;
		}
		return currentMana >= Value;
	}
}
internal class StatusEmitterAoE : MonoBehaviour
{
	private Character[] playerCharacters;

	private float radius;

	private float TickDuration = 0.1f;

	private float TickTimer = 0f;

	private string EquipTag = "ThrowStaff";

	private void Awake()
	{
		Setup();
	}

	private void Setup()
	{
		playerCharacters = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
		radius = 3f;
	}

	private void Update()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		TickTimer += Time.deltaTime;
		if (!(TickTimer >= TickDuration))
		{
			return;
		}
		Character[] array = playerCharacters;
		foreach (Character val in array)
		{
			Equipment equippedItem = val.Inventory.Equipment.GetMatchingSlot((EquipmentSlotIDs)5).EquippedItem;
			if (!((Object)(object)equippedItem != (Object)null))
			{
				continue;
			}
			Tag tagFromName = GetTagFromName(EquipTag);
			if (tagFromName != default(Tag) && !val.StatusEffectMngr.HasStatusEffect("Plasmonic Sigil Effect") && ((Item)equippedItem).HasTag(tagFromName))
			{
				Vector3 position = ((Component)val).transform.position;
				Vector3 position2 = ((Component)this).transform.position;
				Vector3 val2 = position - position2;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < radius && (Object)(object)val != (Object)null && !val.IsDead)
				{
					val.StatusEffectMngr.AddStatusEffect("Plasmonic Sigil Effect");
				}
			}
		}
		TickTimer = 0f;
	}

	public static Tag GetTagFromName(string tagName)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		Tag[] tags = TagSourceManager.Instance.m_tags;
		foreach (Tag val in tags)
		{
			if (val.TagName == tagName)
			{
				return val;
			}
		}
		return default(Tag);
	}
}
public class SL_PanicCharacterStats : SL_Effect, ICustomModel
{
	public string UIDPrefix = "npcweapons.PanicCharacterStats";

	public Type SLTemplateModel => typeof(SL_PanicCharacterStats);

	public Type GameModel => typeof(PanicCharacterStats);

	public override void ApplyToComponent<T>(T component)
	{
		PanicCharacterStats panicCharacterStats = component as PanicCharacterStats;
		panicCharacterStats.UIDPrefix = UIDPrefix;
	}

	public override void SerializeEffect<T>(T effect)
	{
		PanicCharacterStats panicCharacterStats = effect as PanicCharacterStats;
		UIDPrefix = panicCharacterStats.UIDPrefix;
	}
}
public class PanicCharacterStats : Effect
{
	public string UIDPrefix;

	private string Cj;

	private float duration;

	private CharacterStats characterStats;

	private Stat[] characterResistanceList;

	private float statValue;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Invalid comparison between Unknown and I4
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Expected O, but got Unknown
		characterStats = _affectedCharacter.m_characterStats;
		if ((Object)(object)characterStats != (Object)null)
		{
			StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab("Panic");
			if ((Object)(object)statusEffectPrefab != (Object)null)
			{
				duration = statusEffectPrefab.StartLifespan;
			}
			else
			{
				JohBenjiNPCWeapons.Log.LogMessage((object)"Did not find original Pain status effect prefab. Setting default duration to 10 seconds. ");
				duration = 10f;
			}
			characterResistanceList = characterStats.m_damageResistance;
			int num = 9;
			for (int i = 0; i <= num; i++)
			{
				if (i > 5 && i != 8)
				{
					continue;
				}
				Types val = (Types)i;
				if ((int)val != 7 && (int)val != 6)
				{
					statValue = characterResistanceList[i].BaseValue;
					Cj = UIDPrefix + i;
					if (statValue > 0f && !characterResistanceList[i].m_rawStack.ContainsKey(Cj))
					{
						StatStack val2 = new StatStack(Cj, duration, 0f - statValue, (Tag[])null);
						characterResistanceList[i].m_rawStack.Add(Cj, val2);
					}
				}
			}
		}
		else
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)"characterStats == null. Cannot apply Panic to CharacterStats.");
		}
	}
}
public class SL_ChangeGhostLifeSpan : SL_Effect, ICustomModel
{
	public float LifeSpan;

	public bool Percentage;

	public Type SLTemplateModel => typeof(SL_ChangeGhostLifeSpan);

	public Type GameModel => typeof(ChangeGhostLifeSpan);

	public override void ApplyToComponent<T>(T component)
	{
		ChangeGhostLifeSpan changeGhostLifeSpan = component as ChangeGhostLifeSpan;
		changeGhostLifeSpan.LifeSpan = LifeSpan;
		changeGhostLifeSpan.Percentage = Percentage;
	}

	public override void SerializeEffect<T>(T effect)
	{
		ChangeGhostLifeSpan changeGhostLifeSpan = effect as ChangeGhostLifeSpan;
		LifeSpan = changeGhostLifeSpan.LifeSpan;
		Percentage = changeGhostLifeSpan.Percentage;
	}
}
public class ChangeGhostLifeSpan : Effect
{
	public float LifeSpan;

	public bool Percentage;

	private float ghostLifeSpan;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		if ((Object)(object)_affectedCharacter == (Object)null || (Object)(object)_affectedCharacter.CurrentSummon == (Object)null)
		{
			return;
		}
		Character currentSummon = _affectedCharacter.CurrentSummon;
		ghostLifeSpan = currentSummon.Lifetime;
		if (ghostLifeSpan != -1f)
		{
			if (!Percentage)
			{
				currentSummon.m_remainingLifespan += LifeSpan;
			}
			else if (Percentage)
			{
				currentSummon.m_remainingLifespan += ghostLifeSpan * LifeSpan;
			}
		}
	}
}
public class PlasmonicSigilPatch : NPCWeaponPatchClass
{
	public class DestroySigilInteraction : InteractionBase
	{
		private Item ParentItem => ((Component)this).GetComponentInParent<Item>();

		public override bool CanBeActivated => true;

		public override string DefaultHoldText => "Disassemble";

		public override void Activate(Character _character)
		{
			if ((Object)(object)ParentItem != (Object)null)
			{
				_character.SpellCastAnim((SpellCastType)4, (SpellCastModifier)0, 1);
				Object.Destroy((Object)(object)((Component)ParentItem).gameObject);
				_character.Inventory.ReceiveItemReward(-40043, 1, false);
			}
		}
	}

	public class NoInteractionInteraction : InteractionBase
	{
		public override bool CanBeActivated => false;

		public override string DefaultPressText => "";

		public override void Activate(Character _character)
		{
		}
	}

	public PlasmonicSigilPatch(Item itemReference)
		: base(itemReference)
	{
	}

	public override void PatchItem(Item Item)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		Transform itemVisual = Item.GetItemVisual(Item.HasSpecialVisualPrefab);
		if (Object.op_Implicit((Object)(object)Item))
		{
			ParticleSystem component = ((Component)itemVisual.Find("mdl_itm_firestone/FX_Bolt")).GetComponent<ParticleSystem>();
			ParticleSystem component2 = ((Component)itemVisual.Find("mdl_fx_magicCircle/FX_Bolt")).GetComponent<ParticleSystem>();
			Light component3 = ((Component)itemVisual.Find("Point light")).GetComponent<Light>();
			GameObject gameObject = ((Component)itemVisual.Find("Sparks Blast (2)")).gameObject;
			Object.Destroy((Object)(object)gameObject);
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2))
			{
				ColorOverLifetimeModule colorOverLifetime = component.colorOverLifetime;
				ColorOverLifetimeModule colorOverLifetime2 = component2.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = false;
				((ColorOverLifetimeModule)(ref colorOverLifetime2)).enabled = false;
				MainModule main = component.main;
				MainModule main2 = component2.main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.65f, 0.11f, 0.01f));
				((MainModule)(ref main2)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.65f, 0.11f, 1f));
				component3.color = new Color(1f, 0.65f, 0.11f, 1f);
			}
			GameObject gameObject2 = ((Component)itemVisual.Find("mdl_itm_firestone/smoke_desu")).gameObject;
			if ((Object)(object)gameObject2 != (Object)null)
			{
				Object.Destroy((Object)(object)gameObject2);
			}
			Object.Destroy((Object)(object)((Component)ItemReference).GetComponent<Ephemeral>());
			GameObject val = new GameObject();
			((Object)val).name = "StatusEmitter";
			val.transform.parent = ((Component)Item).transform;
			StatusEmitterAoE statusEmitterAoE = val.AddComponent<StatusEmitterAoE>();
			GameObject fromAssetBundle = this.GetFromAssetBundle<GameObject>("johbenji-npcweapons", "sigilofresonance", "SigilStone");
			if ((Object)(object)fromAssetBundle != (Object)null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(fromAssetBundle, itemVisual, false);
				if ((Object)(object)val2 != (Object)null)
				{
					SigilStoneDriver sigilStoneDriver = val2.AddComponent<SigilStoneDriver>();
				}
				else
				{
					Debug.Log((object)"Sigil Stone: NewInstance = Null");
				}
			}
			else
			{
				Debug.Log((object)"Sigil Stone: Prefab Reference = Null");
			}
		}
		if (Object.op_Implicit((Object)(object)Item))
		{
			AddInteractorToItem(Item);
		}
	}

	public T GetFromAssetBundle<T>(string SLPackName, string AssetBundle, string key) where T : Object
	{
		if (!SL.PacksLoaded)
		{
			return default(T);
		}
		return SL.GetSLPack(SLPackName).AssetBundles[AssetBundle].LoadAsset<T>(key);
	}

	public override void AddInteractorToItem(Item Item)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		GameObject val = new GameObject();
		((Object)val).name = "InteractionHolder";
		val.transform.parent = ((Component)Item).transform;
		NoInteractionInteraction noInteractionInteraction = val.AddComponent<NoInteractionInteraction>();
		DestroySigilInteraction destroySigilInteraction = val.AddComponent<DestroySigilInteraction>();
		InteractionActivator InteractionActivator = val.AddComponent<InteractionActivator>();
		InteractionTriggerBase InteractionTriggerBase = val.AddComponent<InteractionTriggerBase>();
		((MonoBehaviour)JohBenjiNPCWeapons.Instance).StartCoroutine(DelayDo(delegate
		{
			InteractionTriggerBase val2 = InteractionTriggerBase;
			InteractionActivator val3 = InteractionActivator;
			DestroySigilInteraction holdInteraction = destroySigilInteraction;
			NoInteractionInteraction noInteractionInteraction2 = noInteractionInteraction;
			val3.BasicInteraction = (IInteraction)(object)noInteractionInteraction;
			val3.HoldInteraction = (IInteraction)(object)holdInteraction;
			val2.DetectionColliderRadius = 1f;
		}));
	}

	private IEnumerator DelayDo(Action ThingToDo)
	{
		yield return (object)new WaitForSeconds(5f);
		ThingToDo?.Invoke();
	}
}
public class SL_CustomLexiconCheck : SL_EffectCondition, ICustomModel
{
	public Type SLTemplateModel => typeof(SL_CustomLexiconCheck);

	public Type GameModel => typeof(CustomLexiconCheck);

	public override void ApplyToComponent<T>(T component)
	{
		CustomLexiconCheck customLexiconCheck = component as CustomLexiconCheck;
	}

	public override void SerializeEffect<T>(T component)
	{
		CustomLexiconCheck customLexiconCheck = component as CustomLexiconCheck;
	}
}
public class CustomLexiconCheck : EffectCondition
{
	public override bool CheckIsValid(Character _affectedCharacter)
	{
		//IL_001b: 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)
		bool flag = (Object)(object)_affectedCharacter.CurrentWeapon != (Object)null && ((Item)_affectedCharacter.CurrentWeapon).HasTag(GetTagFromName("Lexicon"));
		bool flag2 = (Object)(object)_affectedCharacter.LeftHandEquipment != (Object)null && ((Item)_affectedCharacter.LeftHandEquipment).HasTag(GetTagFromName("Lexicon"));
		bool flag3 = ((CharacterKnowledge)_affectedCharacter.Inventory.SkillKnowledge).IsItemLearned(8205170);
		if (flag || flag2 || flag3)
		{
			return true;
		}
		return false;
	}

	public Tag GetTagFromName(string tagName)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		Tag[] tags = TagSourceManager.Instance.m_tags;
		foreach (Tag val in tags)
		{
			if (val.TagName == tagName)
			{
				return val;
			}
		}
		return default(Tag);
	}
}
public class SL_EquipItemFromUID : SL_Effect, ICustomModel
{
	public int ItemID;

	public Type SLTemplateModel => typeof(SL_EquipItemFromUID);

	public Type GameModel => typeof(EquipItemFromUID);

	public override void ApplyToComponent<T>(T component)
	{
		EquipItemFromUID equipItemFromUID = component as EquipItemFromUID;
		equipItemFromUID.ItemID = ItemID;
	}

	public override void SerializeEffect<T>(T effect)
	{
		EquipItemFromUID equipItemFromUID = effect as EquipItemFromUID;
		equipItemFromUID.ItemID = ItemID;
	}
}
public class EquipItemFromUID : Effect
{
	public int ItemID;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)_affectedCharacter))
		{
			return;
		}
		ItemContainer inventoryPouch = _affectedCharacter.Inventory.m_inventoryPouch;
		for (int num = inventoryPouch.m_containedItems.Values.Count - 1; num >= 0; num--)
		{
			Item val = inventoryPouch.m_containedItems.Values[num];
			if (val.ItemID.Equals(ItemID) && val.IsEquippable)
			{
				Equipment val2 = (Equipment)val;
				_affectedCharacter.Inventory.EquipItem(val2, true);
				return;
			}
		}
		if (!_affectedCharacter.Inventory.HasABag)
		{
			return;
		}
		ItemContainer container = (ItemContainer)(object)_affectedCharacter.Inventory.EquippedBag.Container;
		for (int num2 = container.m_containedItems.Values.Count - 1; num2 >= 0; num2--)
		{
			Item val3 = container.m_containedItems.Values[num2];
			if (val3.ItemID.Equals(ItemID) && val3.IsEquippable)
			{
				Equipment val4 = (Equipment)val3;
				_affectedCharacter.Inventory.EquipItem(val4, true);
				break;
			}
		}
	}
}
public class SL_OwnsItemConditionOR : SL_EffectCondition, ICustomModel
{
	public int[] ReqItemIDs;

	public Type SLTemplateModel => typeof(SL_OwnsItemConditionOR);

	public Type GameModel => typeof(OwnsItemConditionOR);

	public override void ApplyToComponent<T>(T component)
	{
		OwnsItemConditionOR ownsItemConditionOR = component as OwnsItemConditionOR;
		ownsItemConditionOR.ReqItemIDs = ReqItemIDs;
	}

	public override void SerializeEffect<T>(T component)
	{
		OwnsItemConditionOR ownsItemConditionOR = component as OwnsItemConditionOR;
		ownsItemConditionOR.ReqItemIDs = ReqItemIDs;
	}
}
public class OwnsItemConditionOR : EffectCondition
{
	public int[] ReqItemIDs;

	public override bool CheckIsValid(Character _affectedCharacter)
	{
		bool result = false;
		int[] reqItemIDs = ReqItemIDs;
		foreach (int num in reqItemIDs)
		{
			if (_affectedCharacter.Inventory.OwnsOrHasEquipped(num))
			{
				result = true;
				break;
			}
		}
		return result;
	}
}
public class SL_RestoreEquippedItemDurability : SL_Effect, ICustomModel
{
	public EquipmentSlotIDs EquipmentSlot;

	public float Durability;

	public bool Percentage;

	public Type SLTemplateModel => typeof(SL_RestoreEquippedItemDurability);

	public Type GameModel => typeof(RestoreEquippedItemDurability);

	public override void ApplyToComponent<T>(T component)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		RestoreEquippedItemDurability restoreEquippedItemDurability = component as RestoreEquippedItemDurability;
		restoreEquippedItemDurability.EquipmentSlot = EquipmentSlot;
		restoreEquippedItemDurability.Durability = Durability;
		restoreEquippedItemDurability.Percentage = Percentage;
	}

	public override void SerializeEffect<T>(T effect)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		RestoreEquippedItemDurability restoreEquippedItemDurability = effect as RestoreEquippedItemDurability;
		EquipmentSlot = restoreEquippedItemDurability.EquipmentSlot;
		Durability = restoreEquippedItemDurability.Durability;
		Percentage = restoreEquippedItemDurability.Percentage;
	}
}
public class RestoreEquippedItemDurability : Effect
{
	public EquipmentSlotIDs EquipmentSlot;

	public float Durability;

	public bool Percentage;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_affectedCharacter == (Object)null || (Object)(object)_affectedCharacter.Inventory == (Object)null || (Object)(object)_affectedCharacter.Inventory.Equipment == (Object)null || !_affectedCharacter.Inventory.Equipment.IsEquipmentSlotActive(EquipmentSlot))
		{
			return;
		}
		EquipmentSlot matchingSlot = _affectedCharacter.Inventory.Equipment.GetMatchingSlot(EquipmentSlot);
		if ((Object)(object)matchingSlot == (Object)null || !matchingSlot.HasItemEquipped)
		{
			return;
		}
		Item equippedItem = (Item)(object)matchingSlot.EquippedItem;
		if (matchingSlot.SlotName == "RightHand")
		{
			EquipmentSlotIDs val = (EquipmentSlotIDs)6;
			EquipmentSlot matchingSlot2 = _affectedCharacter.Inventory.Equipment.GetMatchingSlot(val);
			if ((Object)(object)matchingSlot.EquippedItem == (Object)(object)matchingSlot2.EquippedItem)
			{
				return;
			}
		}
		RepairEquipment(equippedItem, Durability);
	}

	private void RepairEquipment(Item ItemToRepair, float RepairAmount)
	{
		if (ItemToRepair is Equipment)
		{
			float num = 0f;
			num = (Percentage ? (Durability / 100f * (float)ItemToRepair.MaxDurability) : RepairAmount);
			ItemToRepair.RepairAmount(num);
		}
	}
}
public class DialogueCharacter
{
	public int HelmetID = -1;

	public int ChestID = -1;

	public int BootsID = -1;

	public int WeaponID = -1;

	public int OffhandID = -1;

	public int BackpackID = -1;

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private Action<DialogueTree, Character> m_OnSetupDialogueGraph;

	public string UID { get; set; }

	public string Name { get; set; }

	public string SpawnSceneBuildName { get; set; }

	public Vector3 SpawnPosition { get; set; }

	public Vector3 SpawnRotation { get; set; }

	public SpellCastType StartingPose { get; set; }

	public VisualData CharVisualData { get; set; } = new VisualData
	{
		Gender = (Gender)0,
		SkinIndex = 0,
		HairColorIndex = 0,
		HairStyleIndex = 0,
		HeadVariationIndex = 0
	};


	public event Action<DialogueTree, Character> OnSetupDialogueGraph
	{
		[CompilerGenerated]
		add
		{
			Action<DialogueTree, Character> val = this.m_OnSetupDialogueGraph;
			Action<DialogueTree, Character> val2;
			do
			{
				val2 = val;
				Action<DialogueTree, Character> value2 = (Action<DialogueTree, Character>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_OnSetupDialogueGraph, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			Action<DialogueTree, Character> val = this.m_OnSetupDialogueGraph;
			Action<DialogueTree, Character> val2;
			do
			{
				val2 = val;
				Action<DialogueTree, Character> value2 = (Action<DialogueTree, Character>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_OnSetupDialogueGraph, value2, val2);
			}
			while (val != val2);
		}
	}

	public SL_Character CreateAndApplyTemplate()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		SL_Character val = new SL_Character
		{
			UID = UID,
			Name = Name,
			Faction = (Factions)0,
			StartingPose = StartingPose,
			SaveType = (CharSaveType)1,
			SceneToSpawn = SpawnSceneBuildName,
			SpawnPosition = SpawnPosition,
			SpawnRotation = SpawnRotation,
			CharacterVisualsData = CharVisualData,
			Helmet_ID = HelmetID,
			Chest_ID = ChestID,
			Boots_ID = BootsID,
			Weapon_ID = WeaponID,
			Shield_ID = OffhandID,
			Backpack_ID = BackpackID
		};
		((ContentTemplate)val).ApplyTemplate();
		val.OnSpawn += Template_OnSpawn;
		return val;
	}

	private void Template_OnSpawn(Character character, string rpcData)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(Resources.Load<GameObject>("editor/templates/DialogueTemplate"));
		val.transform.parent = ((Component)character).transform;
		val.transform.position = ((Component)character).transform.position;
		DialogueActor componentInChildren = ((Component)character).GetComponentInChildren<DialogueActor>();
		componentInChildren.SetName(Name);
		DialogueTreeController componentInChildren2 = ((Component)character).GetComponentInChildren<DialogueTreeController>();
		Graph graph = ((GraphOwner)componentInChildren2).graph;
		List<ActorParameter> actorParameters = ((DialogueTree)((graph is DialogueTree) ? graph : null))._actorParameters;
		actorParameters[0].actor = (IDialogueActor)(object)componentInChildren;
		actorParameters[0].name = componentInChildren.name;
		this.OnSetupDialogueGraph?.Invoke((DialogueTree)(object)((graph is DialogueTree) ? graph : null), character);
	}
}
public class DialogueTreeBuilder
{
	public DialogueTree TargetDialogueTree { get; private set; }

	public ActorParameter Actor { get; private set; }

	public DialogueTreeBuilder(DialogueTree targetDialogueTree, bool ClearGraph = true)
	{
		TargetDialogueTree = targetDialogueTree;
		Actor = TargetDialogueTree.actorParameters[0];
		if (ClearGraph)
		{
			((Graph)TargetDialogueTree).allNodes.Clear();
		}
	}

	public StatementNodeExt SetInitialStatement(string InitialStatement)
	{
		StatementNodeExt val = CreateNPCStatement(InitialStatement);
		((Graph)TargetDialogueTree).primeNode = (Node)(object)val;
		return val;
	}

	public DTNode AddNode(DTNode NewNode)
	{
		if (!((Graph)TargetDialogueTree).allNodes.Contains((Node)(object)NewNode))
		{
			((Graph)TargetDialogueTree).allNodes.Add((Node)(object)NewNode);
			return NewNode;
		}
		return NewNode;
	}

	public MultipleChoiceNodeExt AddMultipleChoiceNode(string[] choices, ConditionTask[] Condition = null)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		MultipleChoiceNodeExt val = ((Graph)TargetDialogueTree).AddNode<MultipleChoiceNodeExt>();
		for (int i = 0; i < choices.Length; i++)
		{
			Choice item = new Choice
			{
				statement = new Statement
				{
					text = choices[i]
				},
				condition = ((Condition != null && Condition[i] != null) ? Condition[i] : null)
			};
			val.availableChoices.Add(item);
		}
		return val;
	}

	public StatementNodeExt CreateNPCStatement(string AnswerText, bool ContinueOnFinish = false)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		StatementNodeExt val = ((Graph)TargetDialogueTree).AddNode<StatementNodeExt>();
		val.statement = new Statement(AnswerText);
		val.SetActorName(Actor.name);
		val.ContinueOnStatementFinished = ContinueOnFinish;
		AddNode((DTNode)(object)val);
		return val;
	}

	public StatementNode CreatePlayerStatement(string AnswerText)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		StatementNode val = ((Graph)TargetDialogueTree).AddNode<StatementNode>();
		val.statement = new Statement(AnswerText);
		AddNode((DTNode)(object)val);
		return val;
	}

	public T AddAnswerToMultipleChoice<T>(MultipleChoiceNodeExt multiChoice, int answerIndex, T NewNode) where T : DTNode
	{
		((Graph)TargetDialogueTree).ConnectNodes((Node)(object)multiChoice, (Node)(object)NewNode, answerIndex, -1);
		return NewNode;
	}

	public ConditionNode AddConditionalAnswerToMultiChoice(MultipleChoiceNodeExt multiChoice, DialogueTree DT, int answerIndex, ConditionTask Condition)
	{
		ConditionNode val = this.AddAnswerToMultipleChoice<ConditionNode>(multiChoice, answerIndex, ((Graph)DT).AddNode<ConditionNode>());
		val.condition = Condition;
		return val;
	}

	public T AddAnswerToMultipleChoice<T>(MultipleChoiceNodeExt multiChoice, int answerIndex, string AnswerText, T AnswerNode = default(T)) where T : DTNode
	{
		StatementNodeExt val = CreateNPCStatement(AnswerText);
		if (AnswerNode != null)
		{
			AddNode((DTNode)(object)AnswerNode);
			((Graph)TargetDialogueTree).ConnectNodes((Node)(object)multiChoice, (Node)(object)val, answerIndex, -1);
			((Graph)TargetDialogueTree).ConnectNodes((Node)(object)val, (Node)(object)AnswerNode, -1, -1);
			return AnswerNode;
		}
		((Graph)TargetDialogueTree).ConnectNodes((Node)(object)multiChoice, (Node)(object)val, answerIndex, -1);
		return (T)(object)val;
	}
}
public static class NodeExtensions
{
	public static DTNode ConnectTo(this DTNode sourceNode, DialogueTree DT, DTNode TargetNode, int sourceIndex = -1, int targetIndex = -1)
	{
		if (!((Graph)DT).allNodes.Contains((Node)(object)TargetNode))
		{
			((Graph)DT).allNodes.Add((Node)(object)TargetNode);
		}
		((Graph)DT).ConnectNodes((Node)(object)sourceNode, (Node)(object)TargetNode, sourceIndex, targetIndex);
		return TargetNode;
	}

	public static ConditionNode SetCondition(this ConditionNode sourceNode, ConditionTask Condition)
	{
		if (Condition != null)
		{
			sourceNode.task = (Task)(object)Condition;
		}
		return sourceNode;
	}

	public static DTNode OnSuccess(this ConditionNode sourceNode, DialogueTree DT, DTNode SuccessfulNode)
	{
		if (!((Graph)DT).allNodes.Contains((Node)(object)SuccessfulNode))
		{
			((Graph)DT).allNodes.Add((Node)(object)SuccessfulNode);
		}
		((Graph)DT).ConnectNodes((Node)(object)sourceNode, (Node)(object)SuccessfulNode, 0, -1);
		return SuccessfulNode;
	}

	public static DTNode OnFailure(this ConditionNode sourceNode, DialogueTree DT, DTNode FailureNode)
	{
		if (!((Graph)DT).allNodes.Contains((Node)(object)FailureNode))
		{
			((Graph)DT).allNodes.Add((Node)(object)FailureNode);
		}
		((Graph)DT).ConnectNodes((Node)(object)sourceNode, (Node)(object)FailureNode, 1, -1);
		return FailureNode;
	}
}
[HarmonyPatch(typeof(Character), "Die")]
public class GoldLich_Die_Patch
{
	private static void Prefix(Character __instance, Vector3 _hitVec, bool _loadedDead = false)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.UID == UID.op_Implicit("EwoPQ0iVwkK-XtNuaVPf3g") && !_loadedDead)
		{
			Character[] array = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
			Character[] array2 = array;
			foreach (Character val in array2)
			{
				if (val.IsWorldHost)
				{
					val.Inventory.ReceiveItemReward(-40020, 1, false);
				}
			}
		}
		if (__instance.UID == UID.op_Implicit("acpY6mlPgUiJpR3LXt9fVg") && !_loadedDead)
		{
			Character[] array3 = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
			Character[] array4 = array3;
			foreach (Character val2 in array4)
			{
				if (val2.IsWorldHost)
				{
					val2.Inventory.ReceiveItemReward(-40008, 1, false);
				}
			}
		}
		if (__instance.UID == UID.op_Implicit("X-dfltOoGUm7YlCE_Li1zQ") && !_loadedDead)
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)("JohBenjiNPCWeapons: " + __instance.Name));
			if (__instance.Name == "Nicolas")
			{
				Character[] array5 = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
				Character[] array6 = array5;
				foreach (Character val3 in array6)
				{
					if (val3.IsWorldHost)
					{
						val3.Inventory.ReceiveItemReward(-40035, 1, false);
					}
				}
			}
		}
		if (__instance.UID == UID.op_Implicit("eCz766tEIEOWfK81om19wg") && !_loadedDead && ((Object)__instance).name.Contains("EliteCalixa"))
		{
			Character[] array7 = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
			Character[] array8 = array7;
			foreach (Character val4 in array8)
			{
				if (val4.IsWorldHost)
				{
					val4.Inventory.ReceiveItemReward(-40003, 1, false);
					val4.Inventory.ReceiveItemReward(-40034, 1, false);
				}
			}
		}
		if (__instance.UID == UID.op_Implicit("9jsiejBtHkOzeo4tOyyweg") && !_loadedDead && ((Object)__instance).name.Contains("EliteImmaculate"))
		{
			Character[] array9 = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
			Character[] array10 = array9;
			foreach (Character val5 in array10)
			{
				if (val5.IsWorldHost)
				{
					val5.Inventory.ReceiveItemReward(-40010, 1, false);
				}
			}
		}
		if (!(__instance.UID == UID.op_Implicit("Q1WF0liivEm5Khr_c06KXg")) || _loadedDead || !((Object)__instance).name.Contains("Q1WF0liivEm5Khr_c06KXg"))
		{
			return;
		}
		Character[] array11 = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
		Character[] array12 = array11;
		foreach (Character val6 in array12)
		{
			if (val6.IsWorldHost)
			{
				val6.Inventory.ReceiveItemReward(-40041, 1, false);
				val6.Inventory.ReceiveItemReward(-40042, 1, false);
			}
		}
	}
}
[HarmonyPatch(typeof(DualMeleeWeapon), "ProcessVisuals")]
public class DualMeleeWeaponProcessVisuals
{
	private static bool Prefix(DualMeleeWeapon __instance)
	{
		Transform[] array = UnityEngineExtensions.FindAllInAllChildren(((Component)((Equipment)__instance).EquippedVisuals).transform, "LeftHandModel");
		Transform[] array2 = array;
		foreach (Transform val in array2)
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)((Object)val).name);
		}
		return true;
	}
}
[HarmonyPatch(typeof(Disease))]
public static class DieaseDegenerationPatch
{
	public static Dictionary<string, string> DieaseDegenTable = new Dictionary<string, string>
	{
		{ "FungalNecrosis1", "FungalNecrosis2" },
		{ "FungalNecrosis2", "FungalNecrosis3" }
	};

	[HarmonyPatch("ProcessUpdate")]
	[HarmonyPrefix]
	public static bool Prefix(Disease __instance)
	{
		if (DieaseDegenTable.ContainsKey(((StatusEffect)__instance).IdentifierName))
		{
			string text = DieaseDegenTable[((StatusEffect)__instance).IdentifierName];
			if (CanDegenerate(__instance))
			{
				if (!string.IsNullOrEmpty(text))
				{
					__instance.m_degenerating = true;
					((StatusEffect)__instance).m_affectedCharacter.StatusEffectMngr.AddStatusEffect(text);
					return false;
				}
				return true;
			}
			return true;
		}
		return true;
	}

	public static bool CanDegenerate(Disease __instance)
	{
		return ((StatusEffect)__instance).IsActive && __instance.m_degenerateTime != -1f && !__instance.IsReceding && __instance.m_canDegenerate && !__instance.m_degenerating && (double)((StatusEffect)__instance).Age + 0.01 >= (double)__instance.m_degenerateTime;
	}
}
[HarmonyPatch(typeof(Item))]
public static class ItemPatches
{
	[HarmonyPatch("ReduceDurability")]
	[HarmonyPostfix]
	public static void Item_ReduceDurability_Postfix(Item __instance, float _durabilityLost)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Invalid comparison between Unknown and I4
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Invalid comparison between Unknown and I4
		if (__instance.m_currentDurability <= 0f && !PhotonNetwork.isNonMasterClientInRoom && (int)__instance.BehaviorOnNoDurability != 1 && (int)__instance.BehaviorOnNoDurability == 3)
		{
			if (__instance.ItemID == -40000)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(6500031, 1, false);
			}
			else if (__instance.ItemID == -40001)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(6500031, 1, false);
			}
			else if (__instance.ItemID == -40037)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(-40039, 1, true);
			}
			else if (__instance.ItemID == -40038)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(-40040, 1, true);
			}
			else if (__instance.ItemID == -40000)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(6500031, 1, true);
			}
			else if (__instance.ItemID == -40001)
			{
				((EffectSynchronizer)__instance).OwnerCharacter.Inventory.ReceiveItemReward(6500031, 1, true);
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterInventory), "EquipItem", new Type[]
{
	typeof(Equipment),
	typeof(bool)
})]
public class CharacterOnEquipPatched
{
	[HarmonyPostfix]
	public static void Postfix(CharacterInventory __instance, Equipment _itemToEquip, bool _playAnim)
	{
		JohBenjiNPCWeapons.OnItemEquipped?.Invoke((Item)(object)_itemToEquip, __instance.m_character);
	}
}
public class SL_ForceUnEquip : SL_Effect, ICustomModel
{
	public EquipmentSlotIDs EquipmentSlot;

	public Type SLTemplateModel => typeof(SL_ForceUnEquip);

	public Type GameModel => typeof(ForceUnEquip);

	public override void ApplyToComponent<T>(T component)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		ForceUnEquip forceUnEquip = component as ForceUnEquip;
		forceUnEquip.EquipmentSlot = EquipmentSlot;
	}

	public override void SerializeEffect<T>(T effect)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		ForceUnEquip forceUnEquip = effect as ForceUnEquip;
		EquipmentSlot = forceUnEquip.EquipmentSlot;
	}
}
public class ForceUnEquip : Effect
{
	public EquipmentSlotIDs EquipmentSlot;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)_affectedCharacter))
		{
			return;
		}
		EquipmentSlot matchingSlot = _affectedCharacter.Inventory.Equipment.GetMatchingSlot(EquipmentSlot);
		if (!((Object)(object)matchingSlot != (Object)null))
		{
			return;
		}
		if (((Object)matchingSlot).name == "Helmet" || ((Object)matchingSlot).name == "Chest" || ((Object)matchingSlot).name == "Legs" || ((Object)matchingSlot).name == "MainHand" || ((Object)matchingSlot).name == "LeftHand")
		{
			if (matchingSlot.HasItemEquipped)
			{
				Equipment equippedItem = matchingSlot.EquippedItem;
				if ((Object)(object)equippedItem != (Object)null)
				{
					_affectedCharacter.Inventory.UnequipItem(equippedItem);
				}
				else
				{
					JohBenjiNPCWeapons.Log.LogMessage((object)"SL ForceUnEquip: Equipped Item is null.");
				}
			}
			else
			{
				JohBenjiNPCWeapons.Log.LogMessage((object)"SL ForceUnEquip: Chosen slot does not have an Item Equipped.");
			}
		}
		else
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)"SL ForceUnEquip: Item slot not appropriate");
		}
	}
}
public class NPC_Manager
{
	private SL_Character YourNPC = null;

	private string SLPack = "johbenji-npcweapons";

	private string AssetBundle = "audiofiles";

	private string AudioClipName = "WeaponsResearcher";

	private string TrainerUID = "WeaponResearcher-johbenji";

	public NPC_Manager()
	{
		SL.OnPacksLoaded += SL_OnPacksLoaded;
	}

	private void SL_OnPacksLoaded()
	{
		SLPack sLPack = SL.GetSLPack(SLPack);
		YourNPC = sLPack.CharacterTemplates[TrainerUID];
		YourNPC.OnSpawn += CalledWhenNPCSpawns;
	}

	private void CalledWhenNPCSpawns(Character NewNPC, string _somethingAboutArguements)
	{
		GenericTrainerSetup(NewNPC, NewNPC.Name, "WeaponSkillTree-johbenji");
	}

	public void GenericTrainerSetup(Character trainer, string ActorName, string treeUID)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Expected O, but got Unknown
		Object.DestroyImmediate((Object)(object)((Component)trainer).GetComponent<CharacterStats>());
		Object.DestroyImmediate((Object)(object)((Component)trainer).GetComponent<StartingEquipment>());
		DialogueActor componentInChildren = ((Component)trainer).GetComponentInChildren<DialogueActor>();
		componentInChildren.SetName(ActorName);
		Trainer componentInChildren2 = ((Component)trainer).GetComponentInChildren<Trainer>();
		componentInChildren2.m_skillTreeUID = new UID(treeUID);
		DialogueTreeController componentInChildren3 = ((Component)trainer).GetComponentInChildren<DialogueTreeController>();
		Graph graph = ((GraphOwner)componentInChildren3).graph;
		AudioClip val = SL.GetSLPack(SLPack).AssetBundles[AssetBundle].LoadAsset<AudioClip>(AudioClipName);
		if ((Object)(object)val == (Object)null)
		{
			JohBenjiNPCWeapons.Log.LogMessage((object)("Could not find the AudioClip at SLPack " + SLPack + " AssetBundle " + AssetBundle + " AudioClipName " + AudioClipName));
		}
		else
		{
			DTNode val2 = (DTNode)graph.allNodes[0];
			ActionNode val3 = graph.AddNode<ActionNode>();
			val3.action = (ActionTask)new PlayAudioAtPosition
			{
				audioClip = new BBParameter<AudioClip>
				{
					value = val
				},
				waitActionFinish = false
			};
			graph.primeNode = (Node)(object)val3;
			graph.ConnectNodes((Node)(object)val3, (Node)(object)val2, -1, -1);
		}
	}
}
[BepInPlugin("johbenji.npcweapons", "JohBenjiNPCWeapons", "3.0.0")]
public class JohBenjiNPCWeapons : BaseUnityPlugin
{
	public const string GUID = "johbenji.npcweapons";

	public const string NAME = "JohBenjiNPCWeapons";

	public const string VERSION = "3.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	public static NPC_Manager NPCManager;

	public static Action<Item, Character> OnItemEquipped;

	public Dictionary<string, Tuple<string, SL_DropTable>> dropTableDictionary = new Dictionary<string, Tuple<string, SL_DropTable>>();

	public static JohBenjiNPCWeapons Instance;

	private AnimationOverride myOverride;

	public InteractionActivator InteractionActivator { get; private set; }

	public InteractionTriggerBase InteractionTriggerBase { get; private set; }

	internal void Awake()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogMessage((object)"JohBenjiNPCWeapons: JohBenjiNPCWeapons.Awake()");
		NPCManager = new NPC_Manager();
		ExampleConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("ExampleCategory", "ExampleSetting", false, "This is an example setting.");
		SL.OnPacksLoaded += SL_OnPacksLoaded;
		SL.OnSceneLoaded += SL_OnSceneLoaded;
		new Harmony("johbenji.npcweapons").PatchAll();
	}

	internal void Update()
	{
	}

	public void SL_OnSceneLoaded()
	{
		Log.LogMessage((object)"JohBenjiNPCWeapons: OnSceneLoaded Applying Specialized DropTables");
		if (dropTableDictionary.Count != 0)
		{
			DTAppend dTAppend = new DTAppend();
			dTAppend.Apply(dropTableDictionary);
		}
		else
		{
			Log.LogMessage((object)"JohBenjiNPCWeapons: dropTableDictionary is empty.");
		}
	}

	private void SL_OnPacksLoaded()
	{
		Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(-40000);
		new BloodSpearPatch(itemPrefab);
		Item itemPrefab2 = ResourcesPrefabManager.Instance.GetItemPrefab(-40001);
		new BloodSwordPatch(itemPrefab2);
		Item itemPrefab3 = ResourcesPrefabManager.Instance.GetItemPrefab(-40008);
		new DjinnsChakram(itemPrefab3);
		Item itemPrefab4 = ResourcesPrefabManager.Instance.GetItemPrefab(-40016);
		new AxeOfGiantKindPatch(itemPrefab4);
		Item itemPrefab5 = ResourcesPrefabManager.Instance.GetItemPrefab(-40019);
		new GoldenLichCannonPatch(itemPrefab5);
		Item itemPrefab6 = ResourcesPrefabManager.Instance.GetItemPrefab(-40028);
		new ScarletFangKnucklesPatch(itemPrefab6);
		Item itemPrefab7 = ResourcesPrefabManager.Instance.GetItemPrefab(-40034);
		new WolfTowerShieldPatch(itemPrefab7);
		Item itemPrefab8 = ResourcesPrefabManager.Instance.GetItemPrefab(-40035);
		new CageFistPatch(itemPrefab8);
		Item itemPrefab9 = ResourcesPrefabManager.Instance.GetItemPrefab(-40042);
		new MarbleParryAxePatch(itemPrefab9);
		Item itemPrefab10 = ResourcesPrefabManager.Instance.GetItemPrefab(-40044);
		new PlasmonicSigilPatch(itemPrefab10);
		dropTableDictionary["Lightning Dancer"] = new Tuple<string, SL_DropTable>("LightningDancerDrop-custom", null);
		dropTableDictionary["Guardian of the Compass"] = new Tuple<string, SL_DropTable>("GuardianOfTheCompassDrop-custom", null);
		DTLoadByName dTLoadByName = new DTLoadByName();
		Dictionary<string, Tuple<string, SL_DropTable>> dictionary = dTLoadByName.Load(dropTableDictionary);
		foreach (string key in dictionary.Keys)
		{
			dropTableDictionary[key] = new Tuple<string, SL_DropTable>(dictionary[key].Item1, dictionary[key].Item2);
		}
	}
}
public class SL_TransmuteItemPairs : SL_Effect, ICustomModel
{
	public int[] InReqItemIDs;

	public int[] OutReqItemIDs;

	public int TransmutationNumber;

	public Type SLTemplateModel => typeof(SL_TransmuteItemPairs);

	public Type GameModel => typeof(TransmuteItemPairs);

	public override void ApplyToComponent<T>(T component)
	{
		TransmuteItemPairs transmuteItemPairs = component as TransmuteItemPairs;
		transmuteItemPairs.InReqItemIDs = InReqItemIDs;
		transmuteItemPairs.OutReqItemIDs = OutReqItemIDs;
		transmuteItemPairs.TransmutationNumber = TransmutationNumber;
	}

	public override void SerializeEffect<T>(T effect)
	{
		TransmuteItemPairs transmuteItemPairs = effect as TransmuteItemPairs;
		transmuteItemPairs.InReqItemIDs = InReqItemIDs;
		transmuteItemPairs.OutReqItemIDs = OutReqItemIDs;
		transmuteItemPairs.TransmutationNumber = TransmutationNumber;
	}
}
public class TransmuteItemPairs : Effect
{
	public int[] InReqItemIDs;

	public int[] OutReqItemIDs;

	public int TransmutationNumber;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		int num = 0;
		if (num > TransmutationNumber)
		{
			return;
		}
		for (int i = 0; i < InReqItemIDs.Length; i++)
		{
			int num2 = InReqItemIDs[i];
			if (_affectedCharacter.Inventory.OwnsOrHasEquipped(num2))
			{
				_affectedCharacter.Inventory.RemoveItem(num2, 1);
				_affectedCharacter.Inventory.ReceiveItemReward(OutReqItemIDs[i], 1, false);
				num++;
				break;
			}
		}
	}
}
internal class SigilStoneDriver : MonoBehaviour
{
	public List<RingRotationConfig> RotationConfigs;

	public DisplacementConfig DisplacementConfig;

	private float t_ref;

	private float t_counter;

	private Rigidbody _Rigidbody;

	private Light Light;

	private Rigidbody Rigidbody
	{
		get
		{
			if ((Object)(object)_Rigidbody == (Object)null)
			{
				_Rigidbody = ((Component)this).GetComponentInParent<Rigidbody>();
			}
			return _Rigidbody;
		}
	}

	private void Awake()
	{
	}

	private void OnEnable()
	{
		t_ref = Time.time;
		t_counter = 0f;
		Setup();
	}

	private void OnDisable()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.localPosition = new Vector3(0f, 0f, 0f);
		foreach (RingRotationConfig rotationConfig in RotationConfigs)
		{
			if (rotationConfig != null && (Object)(object)rotationConfig.Ring != (Object)null)
			{
				rotationConfig.Ring.Rotate(rotationConfig.Axis, 0f);
			}
		}
	}

	private void SetupLight()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		Light = ((Component)((Component)this).transform).gameObject.GetComponentInChildren<Light>();
		Light.color = Color.yellow;
		Light.type = (LightType)2;
		Light.range = 18f;
		Light.intensity = 1.035f;
	}

	private void EnableLight()
	{
		if (Object.op_Implicit((Object)(object)Light))
		{
			((Behaviour)Light).enabled = true;
		}
	}

	private void DisableLight()
	{
		if (Object.op_Implicit((Object)(object)Light))
		{
			((Behaviour)Light).enabled = false;
		}
	}

	private void Setup()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		RingRotationConfig ringRotationConfig = new RingRotationConfig();
		ringRotationConfig.Speed = 60f;
		ringRotationConfig.Axis = new Vector3(90f, 90f, 90f);
		ringRotationConfig.Ring = ((Component)this).transform.Find("Resonator");
		RingRotationConfig ringRotationConfig2 = new RingRotationConfig();
		ringRotationConfig2.Speed = 30f;
		ringRotationConfig2.Axis = new Vector3(90f, 0f, 0f);
		ringRotationConfig2.Ring = ((Component)this).transform.Find("Resonator/Outer_Ring");
		RingRotationConfig ringRotationConfig3 = new RingRotationConfig();
		ringRotationConfig3.Speed = 45f;
		ringRotationConfig3.Axis = new Vector3(90f, 0f, 0f);
		ringRotationConfig3.Ring = ((Component)this).transform.Find("Resonator/Outer_Ring/Middle_Ring");
		RingRotationConfig ringRotationConfig4 = new RingRotationConfig();
		ringRotationConfig4.Speed = 90f;
		ringRotationConfig4.Axis = new Vector3(90f, 0f, 0f);
		ringRotationConfig4.Ring = ((Component)this).transform.Find("Resonator/Outer_Ring/Middle_Ring/Inner_Ring");
		RingRotationConfig[] source = new RingRotationConfig[4] { ringRotationConfig, ringRotationConfig2, ringRotationConfig3, ringRotationConfig4 };
		RotationConfigs = source.ToList();
		DisplacementConfig displacementConfig = new DisplacementConfig();
		displacementConfig.DisplacementObject = ((Component)this).transform;
		displacementConfig.StartPosition = ((Component)this).transform.localPosition + new Vector3(0f, 1.55f, 0.5f);
		displacementConfig.EndPosition = ((Component)this).transform.localPosition + new Vector3(0f, 3f, 0f);
		displacementConfig.initiallength = 1.7f;
		displacementConfig.maxspeed = 0f;
		displacementConfig.totallength = 60f;
		SetDisplacementConfig(displacementConfig);
	}

	private void Update()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)Rigidbody))
		{
			Rigidbody.useGravity = false;
			if (Rigidbody.velocity != Vector3.zero)
			{
				Rigidbody rigidbody = Rigidbody;
				rigidbody.velocity *= 0.2f;
			}
		}
		if (DisplacementConfig == null)
		{
			return;
		}
		t_counter = Time.time - t_ref;
		if (t_counter <= DisplacementConfig.initiallength)
		{
			float num = t_counter / DisplacementConfig.initiallength;
			float num2 = num - 1f;
			float num3 = 1f - 0.5f * Mathf.Pow(num2, 2f) - 0.5f * Mathf.Pow(num2, 4f);
			Vector3 localPosition = Vector3.Lerp(DisplacementConfig.StartPosition, DisplacementConfig.EndPosition, num3);
			DisplacementConfig.DisplacementObject.localPosition = localPosition;
			foreach (RingRotationConfig rotationConfig in RotationConfigs)
			{
				if (rotationConfig != null && (Object)(object)rotationConfig.Ring != (Object)null)
				{
					float num4 = Mathf.Lerp(0f, rotationConfig.Speed, num3);
					rotationConfig.Ring.Rotate(rotationConfig.Axis, num4 * Time.deltaTime);
				}
			}
		}
		if (!(t_counter > DisplacementConfig.initiallength))
		{
			return;
		}
		EnableLight();
		foreach (RingRotationConfig rotationConfig2 in RotationConfigs)
		{
			if (rotationConfig2 != null && (Object)(object)rotationConfig2.Ring != (Object)null)
			{
				rotationConfig2.Ring.Rotate(rotationConfig2.Axis, rotationConfig2.Speed * Time.deltaTime);
			}
		}
	}

	public void SetDisplacementConfig(DisplacementConfig displacementConfig)
	{
		DisplacementConfig = displacementConfig;
	}
}