Decompiled source of Summoned Ghost Configuration v2.0.0

plugins/Summoned Ghost Configuration.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Conjuration_Extended;
using HarmonyLib;
using SideLoader;
using SideLoader.Model;
using Summoned_Ghost_Configuration;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Conjuration Extended")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Conjuration Extended")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ff65a53d-0b52-41b0-8c46-6a77becc659c")]
[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 Summoned_Ghost_Configuration
{
	public class InvokeHelper : MonoBehaviour
	{
		private static InvokeHelper instance;

		private Action pendingAction;

		public static InvokeHelper Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)instance == (Object)null)
				{
					GameObject val = new GameObject("InvokeHelper");
					instance = val.AddComponent<InvokeHelper>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				return instance;
			}
		}

		public void InvokeDelayed(float delay, Action action)
		{
			((MonoBehaviour)this).Invoke("ExecuteAction", delay);
			pendingAction = action;
		}

		private void ExecuteAction()
		{
			pendingAction?.Invoke();
		}
	}
	public class SummonedGhostManager
	{
		private Dictionary<Character, Character> summonSummonerDictionary = new Dictionary<Character, Character>();

		private int WindAltarActivated;

		private int ghostCount;

		public void TeleportAllGhosts()
		{
			//IL_004f: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Character, Character> item in summonSummonerDictionary)
			{
				Character key = item.Key;
				Character value = item.Value;
				if ((Object)(object)key != (Object)null && (Object)(object)value != (Object)null)
				{
					((Component)key).transform.position = ((Component)value).transform.position + DisplacementPositionVector();
					((Component)key).transform.eulerAngles = ((Component)value).transform.eulerAngles;
				}
			}
		}

		public void TeleportGhost(Character ghost)
		{
			//IL_0026: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			Character val = summonSummonerDictionary[ghost];
			if ((Object)(object)val != (Object)null)
			{
				((Component)ghost).transform.position = ((Component)val).transform.position + DisplacementPositionVector();
				((Component)ghost).transform.rotation = ((Component)val).transform.rotation;
			}
		}

		public void AddGhost(Character ghost, Character summoner)
		{
			summonSummonerDictionary.Add(ghost, summoner);
			if (ConfigElements.ghostImpact.Value)
			{
				InvokeHelper.Instance.InvokeDelayed(1f, SetStatsDelayed);
			}
		}

		public void clearAllGhosts()
		{
			summonSummonerDictionary.Clear();
		}

		public void removeAllGhosts()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Character[] array = summonSummonerDictionary.Keys.ToArray();
			foreach (Character val in array)
			{
				val.Stats.SetHealth(0f);
				val.Die(new Vector3(0f, 0f, 0f), false);
			}
		}

		public void CheckRemoveGhost(Character ghost)
		{
			if (summonSummonerDictionary.ContainsKey(ghost))
			{
				summonSummonerDictionary.Remove(ghost);
				if (ConfigElements.ghostImpact.Value)
				{
					InvokeHelper.Instance.InvokeDelayed(1f, SetStatsDelayed);
				}
			}
		}

		private void SetStatsDelayed()
		{
			setImpactDamage();
		}

		public int GetGhostCount()
		{
			return ghostCount = summonSummonerDictionary.Count;
		}

		public int GetGhostCount(Character summoner)
		{
			int num = 0;
			foreach (KeyValuePair<Character, Character> item in summonSummonerDictionary)
			{
				Character key = item.Key;
				Character value = item.Value;
				if ((Object)(object)summoner == (Object)(object)value)
				{
					num++;
				}
			}
			ghostCount = num;
			return num;
		}

		public Vector3 DisplacementPositionVector()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			return new Vector3(Random.Range(-1f, 1f), Random.Range(2f, 2.1f), Random.Range(-1f, 1f));
		}

		private void setImpactDamage()
		{
			Dictionary<Character, int> dictionary = new Dictionary<Character, int>();
			foreach (KeyValuePair<Character, Character> item in summonSummonerDictionary)
			{
				Character key = item.Key;
				Character value = item.Value;
				if (!dictionary.ContainsKey(value))
				{
					dictionary[value] = 0;
				}
				dictionary[value]++;
			}
			foreach (KeyValuePair<Character, int> item2 in dictionary)
			{
				Character summoner = item2.Key;
				int value2 = item2.Value;
				foreach (Character item3 in from x in summonSummonerDictionary
					where (Object)(object)x.Value == (Object)(object)summoner
					select x.Key)
				{
					setImpactDamageGhost(item3, value2);
				}
			}
		}

		private void setImpactDamageGhost(Character ghostCharacter, int summonedCount)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (summonedCount == 0)
			{
				return;
			}
			MeleeWeapon val = (MeleeWeapon)ghostCharacter.CurrentWeapon;
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			WeaponStats val2 = (WeaponStats)((Item)val).m_stats;
			if (!((Object)(object)val2 != (Object)null))
			{
				return;
			}
			AttackData[] attacks = val2.Attacks;
			if (attacks != null)
			{
				AttackData[] array = attacks;
				foreach (AttackData val3 in array)
				{
					val3.Knockback = 37f * Mathf.Pow((float)summonedCount, -0.95f);
				}
			}
		}

		public void setWindAltarCount(int windAltarCount)
		{
			WindAltarActivated = windAltarCount;
		}
	}
}
namespace Conjuration_Extended
{
	public static class ConfigElements
	{
		public static ConfigEntry<int> ghostHealth;

		public static ConfigEntry<float> ghostHealthRegen;

		public static ConfigEntry<float> ghostLifeTime;

		public static ConfigEntry<float> ghostRed;

		public static ConfigEntry<float> ghostGreen;

		public static ConfigEntry<float> ghostBlue;

		public static ConfigEntry<float> ghostAlpha;

		public static ConfigEntry<bool> canSpawnMultiple;

		public static ConfigEntry<float> ghostShareDamage;

		public static ConfigEntry<bool> ghostImpact;

		public static void Init(ConfigFile config)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			ghostHealth = config.Bind<int>("Stats", "Health", 110, new ConfigDescription("The default health of the summoned ghost. (Vanilla = 110)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), new object[0]));
			ghostHealthRegen = config.Bind<float>("Stats", "Health Regen", 0f, new ConfigDescription("The health regeneration of the summoned ghost. (Vanilla = 0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[0]));
			ghostLifeTime = config.Bind<float>("Stats", "Lifetime", 280f, new ConfigDescription("The life span of the summoned ghost. (Vanilla = 280)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2400f), new object[0]));
			ghostRed = config.Bind<float>("Color (R,G,B,A)", "Red", 1.3235f, new ConfigDescription("The color of the summoned ghost. (Vanilla = 1.3235)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), new object[0]));
			ghostGreen = config.Bind<float>("Color (R,G,B,A)", "Green", 1.5635f, new ConfigDescription("The color of the summoned ghost. (Vanilla = 1.5635)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), new object[0]));
			ghostBlue = config.Bind<float>("Color (R,G,B,A)", "Blue", 4f, new ConfigDescription("The color of the summoned ghost. (Vanilla = 4)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), new object[0]));
			ghostAlpha = config.Bind<float>("Color (R,G,B,A)", "Alpha", 1.3235f, new ConfigDescription("The transparency of the summoned ghost. (Vanilla = 1)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), new object[0]));
			canSpawnMultiple = config.Bind<bool>("Multiple Ghosts", "Can Spawn Multiple?", false, new ConfigDescription("Allows additional ghosts to be summoned equal to the number of wind altars activated. If the player activates all 6 altars then they can summon as many as they wish. (Vanilla = Disabled)", (AcceptableValueBase)null, Array.Empty<object>()));
			ghostImpact = config.Bind<bool>("Multiple Ghosts", "Reduced Impact", false, new ConfigDescription("Ghosts deals reduced impact damage if there are multiple of them. (Vanilla = Disabled)", (AcceptableValueBase)null, Array.Empty<object>()));
			ghostShareDamage = config.Bind<float>("Multiple Ghosts", "Share Damage (%)", 0f, new ConfigDescription("A percentage of damage taken by the ghost is shared with the summoner. (Vanilla = 0%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0]));
		}
	}
	[BepInPlugin("johbenji.summonedghostconfiguration", "Summoned Ghost Configuration", "2.0.0")]
	public class ConjurationExtendedPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(QuestEventManager), "Awake")]
		private class addQEManager_Patch
		{
			private static void Postfix(QuestEventManager __instance)
			{
				if ((Object)(object)manager == (Object)null)
				{
					manager = __instance;
				}
			}
		}

		[HarmonyPatch(typeof(QuestEventManager), "LoadEventList")]
		private class updateOnLoadQEDictionary_Patch
		{
			private static void Postfix(QuestEventManager __instance)
			{
				if ((Object)(object)__instance != (Object)null && (Object)(object)manager != (Object)null && (Object)(object)__instance == (Object)(object)manager)
				{
					updateQEDictionarySearch();
				}
			}
		}

		[HarmonyPatch(typeof(QuestEventManager), "AddEvent", new Type[]
		{
			typeof(string),
			typeof(int),
			typeof(bool)
		})]
		private class updateOnAddQEDictionary_Patch
		{
			private static void Postfix(QuestEventManager __instance)
			{
				if ((Object)(object)__instance != (Object)null && (Object)(object)manager != (Object)null && (Object)(object)__instance == (Object)(object)manager)
				{
					updateQEDictionarySearch();
				}
			}
		}

		[HarmonyPatch(typeof(Character), "SetIntantiationData")]
		public class MultipleGhost_Patch
		{
			private static bool Prefix(Character __instance, object[] _data)
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: 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_0099: Invalid comparison between Unknown and I4
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				if (ConfigElements.canSpawnMultiple.Value && ((int)_data[0] == 3 || (int)_data[0] == 4))
				{
					__instance.m_instantiationType = (CharacterInstantiationTypes)(int)_data[0];
					__instance.m_prefabPath = (string)_data[1];
					__instance.m_uid = UID.op_Implicit((string)_data[2]);
					CharacterManager.Instance.AddCharacter(__instance);
					Character character = CharacterManager.Instance.GetCharacter((string)_data[3]);
					if (Object.op_Implicit((Object)(object)character))
					{
						if ((int)__instance.SummonType != 2)
						{
							if (PhotonNetwork.isMasterClient)
							{
								int windAltarCount = Instance.getWindAltarCount();
								int ghostCount = SummonedGhostManager.GetGhostCount(character);
								if (ghostCount >= windAltarCount && windAltarCount <= 6)
								{
									Log.LogMessage((object)"Test log: Summoned Ghost Configuration");
									SummonedGhostManager.CheckRemoveGhost(character.CurrentSummon);
									character.DestroyCurrentSummon();
								}
							}
							character.SetCurrentSummon(__instance);
						}
						else
						{
							character.SetCurrentBloodSpirit(__instance);
						}
						__instance.m_summonerUID = UID.op_Implicit(character.UID);
					}
					else if (!NetworkLevelLoader.Instance.IsOverallLoadingDone && PhotonNetwork.isNonMasterClientInRoom)
					{
						__instance.m_summonerUID = (string)_data[3];
						__instance.m_summonLateInitRequired = true;
					}
					StartingEquipment component = ((Component)__instance).GetComponent<StartingEquipment>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.InitWanted();
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Character), "OnReceiveHit")]
		public class ShareDamage_Patch
		{
			private static void Postfix(Character __instance, Weapon _weapon, float _damage, DamageList _damageList, Vector3 _hitDir, Vector3 _hitPoint, float _angle, float _angleDir, Character _dealerChar, float _knockBack)
			{
				//IL_004e: 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)
				float value = ConfigElements.ghostShareDamage.Value;
				if (value != 0f && __instance.SummonerUID != null)
				{
					Character character = CharacterManager.Instance.GetCharacter(__instance.m_summonerUID);
					if ((Object)(object)character != (Object)null)
					{
						character.ReceiveHit(_weapon, value * _damage, _hitDir, _hitPoint, _angle, _angleDir, _dealerChar, 0f * _knockBack);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "SetCurrentSummon")]
		public class SetCurrentSummon_Patch
		{
			private static void Postfix(Character __instance, Character _char)
			{
				SummonedGhostManager.AddGhost(_char, __instance);
				SummonedGhostManager.GetGhostCount();
			}
		}

		[HarmonyPatch(typeof(Character), "Die")]
		public class DieSummon_Patch
		{
			private static void Postfix(Character __instance)
			{
				SummonedGhostManager.CheckRemoveGhost(__instance);
				SummonedGhostManager.GetGhostCount();
			}
		}

		[HarmonyPatch(typeof(SaveManager), "LoadWorld")]
		public class clearManager_Patch
		{
			private static void Postfix()
			{
				SummonedGhostManager.clearAllGhosts();
			}
		}

		public const string GUID = "johbenji.summonedghostconfiguration";

		public const string NAME = "Summoned Ghost Configuration";

		public const string VERSION = "2.0.0";

		internal static ManualLogSource Log;

		public static QuestEventManager manager;

		public static Dictionary<string, string> questEvents = new Dictionary<string, string>();

		private List<string> questEventNames = new List<string> { "Caldera_WindAltar_Activated", "Cierzo_WindAltar_Activated", "Enmerkar_WindAltar_Activated", "Harmattan_WindAltar_Activated", "Levant_WindAltar_Activated", "Monsoon_WindAltar_Activated" };

		public static ConjurationExtendedPlugin Instance { get; private set; }

		public static SummonedGhostManager SummonedGhostManager { get; private set; }

		internal void Awake()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			SummonedGhostManager = new SummonedGhostManager();
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigElements.Init(((BaseUnityPlugin)this).Config);
			SL.OnPacksLoaded += SL_OnPacksLoaded;
			SceneManager.sceneLoaded += SceneManager_sceneLoaded;
			foreach (string questEventName in questEventNames)
			{
				questEvents.Add(questEventName, null);
			}
			new Harmony("johbenji.summonedghostconfiguration").PatchAll();
		}

		internal void SceneManager_sceneLoaded(Scene Scene, LoadSceneMode LoadMode)
		{
			((MonoBehaviour)Instance).StartCoroutine(TeleportSummonedGhosts());
			if (((Scene)(ref Scene)).name == "Chersonese_Dungeon6")
			{
				((MonoBehaviour)Instance).StartCoroutine(FixQuestionsAndCorruption());
			}
		}

		public IEnumerator TeleportSummonedGhosts()
		{
			yield return (object)new WaitForSeconds(5f);
			if (ConfigElements.canSpawnMultiple.Value)
			{
				SummonedGhostManager.TeleportAllGhosts();
			}
		}

		public IEnumerator FixQuestionsAndCorruption()
		{
			bool repeat = true;
			while (repeat)
			{
				yield return (object)new WaitForSeconds(5f);
				Scene scene = SceneManager.GetActiveScene();
				bool inDungeon = true;
				if (((Scene)(ref scene)).name != "Chersonese_Dungeon6")
				{
					inDungeon = false;
				}
				bool olieleActive = false;
				GameObject Oliele = GameObject.Find("UNPC_OlieleA");
				if ((Object)(object)Oliele != (Object)null)
				{
					olieleActive = Oliele.activeSelf;
				}
				if (!inDungeon)
				{
					repeat = false;
				}
				if (olieleActive)
				{
					repeat = false;
					SummonedGhostManager.removeAllGhosts();
					Character[] playerCharacters = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
					Character[] array = playerCharacters;
					foreach (Character player in array)
					{
						if (player.IsLocalPlayer)
						{
							player.CharacterUI.NotificationPanel.ShowNotification("Summoned ghosts won't work with this part of the quest. Please refrain from using them against the next fight inside this dungeon.", 10f);
						}
					}
				}
				scene = default(Scene);
			}
		}

		public void SL_OnPacksLoaded()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			SL_StatusEffect val = new SL_StatusEffect();
			val.TargetStatusIdentifier = "Health Recovery 5";
			val.NewStatusID = -65100;
			val.StatusIdentifier = "Ghost Health Recovery";
			val.Description = "WIP";
			val.Lifespan = 2400f;
			val.EffectBehaviour = (EditBehaviours)2;
			SL_EffectTransform[] array = new SL_EffectTransform[2];
			SL_EffectTransform val2 = new SL_EffectTransform();
			val2.TransformName = "Normal";
			val2.Effects = (SL_Effect[])(object)new SL_Effect[1] { (SL_Effect)new SL_AffectHealth
			{
				Delay = 0f,
				SyncType = (SyncTypes)0,
				OverrideCategory = (EffectCategories)0,
				AffectQuantity = ConfigElements.ghostHealthRegen.Value,
				AffectQuantityAI = ConfigElements.ghostHealthRegen.Value,
				IsModifier = false,
				InformSourceCharacter = false
			} };
			array[0] = val2;
			val2 = new SL_EffectTransform();
			val2.TransformName = "Passive";
			val2.Effects = (SL_Effect[])(object)new SL_Effect[1] { (SL_Effect)new SL_AffectStat
			{
				Delay = 0f,
				SyncType = (SyncTypes)0,
				OverrideCategory = (EffectCategories)0,
				Stat_Tag = "MaxHealth",
				AffectQuantity = (float)ConfigElements.ghostHealth.Value - 110f,
				IsModifier = false,
				Duration = -1f
			} };
			array[1] = val2;
			val.Effects = (SL_EffectTransform[])(object)array;
			SL_StatusEffect val3 = val;
			((ContentTemplate)val3).ApplyTemplate();
		}

		private static void updateQEDictionarySearch()
		{
			Character[] array = CharacterManager.Instance.Characters.ValuesArray.Where((Character x) => x.IsLocalPlayer).ToArray();
			Character[] array2 = array;
			foreach (Character val in array2)
			{
				if (val.IsLocalPlayer)
				{
					updateQEDictionary(manager);
				}
			}
		}

		private static void updateQEDictionary(QuestEventManager questEventManager)
		{
			IList<QuestEventData> currentQuestEvents = questEventManager.CurrentQuestEvents;
			foreach (QuestEventData item in currentQuestEvents)
			{
				if (questEvents.ContainsKey(item.Name))
				{
					questEvents[item.Name] = item.m_signatureUID;
				}
			}
		}

		public int getWindAltarCount()
		{
			int num = 1;
			if ((Object)(object)manager != (Object)null)
			{
				foreach (KeyValuePair<string, string> questEvent in questEvents)
				{
					if (questEvent.Value != null && !(questEvent.Value == ""))
					{
						string value = questEvent.Value;
						if (manager.GetEventCurrentStack(value) != 0)
						{
							num++;
						}
					}
				}
			}
			SummonedGhostManager.setWindAltarCount(num);
			return num;
		}
	}
	public class SL_GhostColor : SL_Effect, ICustomModel
	{
		public Type SLTemplateModel => typeof(SL_GhostColor);

		public Type GameModel => typeof(GhostColor);

		public override void ApplyToComponent<T>(T component)
		{
			GhostColor ghostColor = component as GhostColor;
		}

		public override void SerializeEffect<T>(T effect)
		{
			GhostColor ghostColor = effect as GhostColor;
		}
	}
	public class GhostColor : Effect
	{
		public string StatusEffect = "Ghost Health Recovery";

		public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
		{
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			float value = ConfigElements.ghostRed.Value;
			float value2 = ConfigElements.ghostGreen.Value;
			float value3 = ConfigElements.ghostBlue.Value;
			float value4 = ConfigElements.ghostAlpha.Value;
			Color val = default(Color);
			((Color)(ref val))..ctor(value, value2, value3, value4);
			if ((Object)(object)_affectedCharacter == (Object)null || (Object)(object)_affectedCharacter.CurrentSummon == (Object)null)
			{
				return;
			}
			Character currentSummon = _affectedCharacter.CurrentSummon;
			float value5 = ConfigElements.ghostHealthRegen.Value;
			if (!((Object)(object)currentSummon != (Object)null))
			{
				return;
			}
			GameObject gameObject = ((Component)currentSummon).gameObject;
			Transform val2 = gameObject.transform.Find("NewGhostOneHandedAlly_v/mdl_cha_GhostTwoHanded");
			if ((Object)(object)val2 != (Object)null)
			{
				SkinnedMeshRenderer component = ((Component)val2).GetComponent<SkinnedMeshRenderer>();
				if ((Object)(object)component != (Object)null)
				{
					Material material = ((Renderer)component).material;
					if ((Object)(object)material != (Object)null)
					{
						material.SetColor("_Color", val);
					}
				}
			}
			Transform val3 = gameObject.transform.Find("NewGhostOneHandedAlly_v/SkinnedGhostParticleTest");
			ParticleSystem component2 = ((Component)val3).GetComponent<ParticleSystem>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.startColor = ColorEvaluator(val, component2.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: particleTest = null");
			}
			Transform val4 = gameObject.transform.Find("NewGhostOneHandedAlly_v/BurningMan_arma.001/pelvis/spine/Torso/neck/head/GhostEyesEmbers");
			ParticleSystem component3 = ((Component)val4).GetComponent<ParticleSystem>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.startColor = ColorEvaluator(val, component3.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: particleEyesEmbers = null");
			}
			Transform val5 = gameObject.transform.Find("NewGhostOneHandedAlly_v/BurningMan_arma.001/pelvis/spine/Torso/Clavicle_R/topArm_right/Arm2_right/hand_right/SkinnedGhostParticleTestSmoke (1)");
			ParticleSystem component4 = ((Component)val5).GetComponent<ParticleSystem>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.startColor = ColorEvaluator(val, component4.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: particleEyesEmbers = null");
			}
			Transform val6 = gameObject.transform.Find("NewGhostOneHandedAlly_v/VFXDeathGhost (1)/PlayParticles/DeadParticles");
			ParticleSystem component5 = ((Component)val6).GetComponent<ParticleSystem>();
			if ((Object)(object)component5 != (Object)null)
			{
				component5.startColor = ColorEvaluator(val, component5.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: deadParticle = null");
			}
			Transform val7 = gameObject.transform.Find("NewGhostOneHandedAlly_v/VFXDeathGhost (1)/PlayParticles/DeadParticles/Embers");
			ParticleSystem component6 = ((Component)val7).GetComponent<ParticleSystem>();
			if ((Object)(object)component6 != (Object)null)
			{
				component6.startColor = ColorEvaluator(val, component6.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: emberParticle = null");
			}
			Transform val8 = gameObject.transform.Find("NewGhostOneHandedAlly_v/VFXDeathGhost (1)/PlayParticles/DeadParticles/SkinnedGhostParticles");
			ParticleSystem component7 = ((Component)val8).GetComponent<ParticleSystem>();
			if ((Object)(object)component7 != (Object)null)
			{
				component7.startColor = ColorEvaluator(val, component7.startColor);
			}
			else
			{
				ConjurationExtendedPlugin.Log.LogMessage((object)"JohBenjiConjurationExtended: skinnedGhostParticles = null");
			}
			static Color ColorEvaluator(Color inputColor, Color referenceColor)
			{
				//IL_009a: 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)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				float num = ((Color)(ref inputColor))[0];
				float num2 = ((Color)(ref inputColor))[1];
				float num3 = ((Color)(ref inputColor))[2];
				float num4 = (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3);
				float num5 = ((Color)(ref inputColor))[0];
				float num6 = ((Color)(ref inputColor))[1];
				float num7 = ((Color)(ref inputColor))[2];
				float num8 = ((Color)(ref inputColor))[3];
				float num9 = (float)Math.Sqrt(num5 * num5 + num6 * num6 + num7 * num7);
				float num10 = num * num9 / num4;
				float num11 = num2 * num9 / num4;
				float num12 = num3 * num9 / num4;
				Color result = default(Color);
				((Color)(ref result))..ctor(num10, num11, num12, num8);
				return result;
			}
		}
	}
	public class SL_GhostRegen : SL_Effect, ICustomModel
	{
		public Type SLTemplateModel => typeof(SL_GhostRegen);

		public Type GameModel => typeof(GhostRegen);

		public override void ApplyToComponent<T>(T component)
		{
			GhostRegen ghostRegen = component as GhostRegen;
		}

		public override void SerializeEffect<T>(T effect)
		{
			GhostRegen ghostRegen = effect as GhostRegen;
		}
	}
	public class GhostRegen : Effect
	{
		public string StatusEffect = "Ghost Health Recovery";

		public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
		{
			if (!((Object)(object)_affectedCharacter == (Object)null) && !((Object)(object)_affectedCharacter.CurrentSummon == (Object)null))
			{
				Character currentSummon = _affectedCharacter.CurrentSummon;
				float value = ConfigElements.ghostHealthRegen.Value;
				if ((Object)(object)currentSummon != (Object)null)
				{
					currentSummon.StatusEffectMngr.AddStatusEffect("Ghost Health Recovery");
				}
			}
		}
	}
	public class SL_GhostInfiniteLifeSpan : SL_Effect, ICustomModel
	{
		public Type SLTemplateModel => typeof(SL_GhostInfiniteLifeSpan);

		public Type GameModel => typeof(GhostInfiniteLifeSpan);

		public override void ApplyToComponent<T>(T component)
		{
			GhostInfiniteLifeSpan ghostInfiniteLifeSpan = component as GhostInfiniteLifeSpan;
		}

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

		public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
		{
			if (!((Object)(object)_affectedCharacter == (Object)null) && !((Object)(object)_affectedCharacter.CurrentSummon == (Object)null))
			{
				Character currentSummon = _affectedCharacter.CurrentSummon;
				LifeSpan = ConfigElements.ghostLifeTime.Value;
				if (currentSummon.Lifetime != -1f)
				{
					currentSummon.Lifetime = LifeSpan;
					currentSummon.m_remainingLifespan = LifeSpan;
				}
			}
		}
	}
}