Decompiled source of Summoned Ghost Configuration v1.0.1

plugins/Summoned Ghost Configuration.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using SideLoader;
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("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 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 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
		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]));
	}
}
[BepInPlugin("johbenji.summonedghostconfiguration", "Summoned Ghost Configuration", "1.0.0")]
public class ConjurationExtendedPlugin : BaseUnityPlugin
{
	public const string GUID = "johbenji.summonedghostconfiguration";

	public const string NAME = "Summoned Ghost Configuration";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	internal void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"Loading config");
		ConfigElements.Init(((BaseUnityPlugin)this).Config);
		new Harmony("johbenji.summonedghostconfiguration").PatchAll();
		SL.OnPacksLoaded += SL_OnPacksLoaded;
	}

	public void SL_OnPacksLoaded()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		//IL_007c: 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_008c: 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_0095: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00c9: Expected O, but got Unknown
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Expected O, but got Unknown
		int num = ConfigElements.ghostHealth.Value - 110;
		SL_StatusEffect val = new SL_StatusEffect();
		val.TargetStatusIdentifier = "Health Recovery 5";
		val.NewStatusID = -800000;
		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 = num,
			IsModifier = false,
			Duration = -1f
		} };
		array[1] = val2;
		val.Effects = (SL_EffectTransform[])(object)array;
		SL_StatusEffect val3 = val;
		((ContentTemplate)val3).ApplyTemplate();
	}
}
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)
	{
		ConjurationExtendedPlugin.Log.Log((LogLevel)8, (object)"SE Applying Ghost Health Recovery");
		if (!((Object)(object)_affectedCharacter == (Object)null) && !((Object)(object)_affectedCharacter.CurrentSummon == (Object)null))
		{
			ConjurationExtendedPlugin.Log.Log((LogLevel)8, (object)"Looking for ghost");
			Character currentSummon = _affectedCharacter.CurrentSummon;
			float value = ConfigElements.ghostHealthRegen.Value;
			if ((Object)(object)currentSummon != (Object)null)
			{
				ConjurationExtendedPlugin.Log.Log((LogLevel)8, (object)"Found ghost");
				currentSummon.StatusEffectMngr.AddStatusEffect("Ghost Health Recovery");
				ConjurationExtendedPlugin.Log.Log((LogLevel)8, (object)"Added Status Effect");
			}
		}
	}
}
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;
			}
		}
	}
}