Decompiled source of Demons and Devils v1.0.0

DemonsAndDevils.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HoremvoreAssembly;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using SpawnThat.Spawners;
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("DemonsAndDevils")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DemonsAndDevils")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("96cbeb5e-2558-4811-8151-44c3e0801f56")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DemonsAndDevils;

[BepInPlugin("horemvore.DemonsAndDevils", "Demons and Devils", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class demonsAndDevils : BaseUnityPlugin
{
	public const string PluginGUID = "horemvore.DemonsAndDevils";

	public const string PluginName = "Demons and Devils";

	public const string PluginVersion = "1.0.0";

	public AssetBundle bundleDemonDevil;

	public CustomLocalization LocalDemonDevil;

	public ConfigEntry<bool> ModEnable;

	public ConfigEntry<bool> LoggingEnable;

	public ConfigEntry<bool> SpawnsEnable;

	internal static ManualLogSource Log;

	public string[] itemList = new string[25]
	{
		"Item_DemonBlood_DD", "Attack_Gelugon_Right_DD", "Attack_Gelugon_Left_DD", "Attack_Gelugon_Chop_DD", "Attack_Gelugon_Head_DD", "Attack_Abishai_Right_DD", "Attack_Abishai_Left_DD", "Attack_Abishai_Chop_DD", "Attack_Abishai_Head_DD", "Attack_Lemure_Right_DD",
		"Attack_Lemure_Left_DD", "Attack_Lemure_Chop_DD", "Attack_Lemure_Head_DD", "Attack_BabauMinion_Kick_DD", "Attack_BabauMinion_Left_DD", "Attack_BabauMinion_Right_DD", "Attack_MahataaMinion_Kick_DD", "Attack_MahataaMinion_Left_DD", "Attack_MahataaMinion_Right_DD", "Attack_ManeMinion_Kick_DD",
		"Attack_ManeMinion_Left_DD", "Attack_ManeMinion_Right_DD", "Attack_MaurezhiMinion_Kick_DD", "Attack_MaurezhiMinion_Left_DD", "Attack_MaurezhiMinion_Right_DD"
	};

	public string[] prefabList = new string[9] { "VFX_BleedActive_DD", "VFX_DemonBloodActive_DD", "Ragdoll_Lemure_DD", "Ragdoll_Gelugon_DD", "Ragdoll_Abishai_DD", "Ragdoll_BabauMinion_DD", "Ragdoll_MahataaMinion_DD", "Ragdoll_ManeMinion_DD", "Ragdoll_MaurezhiMinion_DD" };

	public string[] sfxList = new string[18]
	{
		"SFX_Devil_Taunt_DD", "SFX_Devil_Alert_DD", "SFX_Devil_Attack_DD", "SFX_Devil_Death_DD", "SFX_Devil_GotHit_DD", "SFX_Devil_Idle_DD", "SFX_Devil_Footstep_DD", "SFX_Devil_Swoosh_DD", "SFX_Devil_Jump_DD", "SFX_Devil_Dodge_DD",
		"SFX_Demon_Alert_DD", "SFX_Demon_Attack_DD", "SFX_Demon_Death_DD", "SFX_Demon_Footstep_DD", "SFX_Demon_GotHit_DD", "SFX_Demon_Idle_DD", "SFX_Demon_Swoosh_DD", "SFX_Demon_Taunt_DD"
	};

	public string[] monsterList = new string[7] { "Lemure_DD", "Gelugon_DD", "Abishai_DD", "BabauMinion_DD", "MahataaMinion_DD", "ManeMinion_DD", "MaurezhiMinion_DD" };

	public string[] seDoTList = new string[5] { "SE_DemonHemorrage_DD", "SE_DemonLacerate_DD", "SE_DemonRend_DD", "SE_DevilMaim_DD", "SE_DevilRupture_DD" };

	public string[] seStatsList = new string[1] { "SE_DemonBlood_DD" };

	public void CreateConfigurationValues()
	{
		//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_003c: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//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_00b6: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
		ModEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("1 Demons and Devils", "Enable", true, new ConfigDescription("Admin only, Enables this mod", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		SpawnsEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("2 Spawning", "Enable", true, new ConfigDescription("Enables default spawning of Demons and Devils. Set to false if you want to setup your own spawns via a 3rd party mod.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		LoggingEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("69 Logging", "Enable", true, new ConfigDescription("Admin only, Enables logging", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
		{
			if (attr.InitialSynchronization)
			{
				Logger.LogMessage((object)"Initial Config sync event received for X_Mod");
			}
			else
			{
				Logger.LogMessage((object)"Config sync event received for X_Mod");
			}
		};
		SynchronizationManager.OnAdminStatusChanged += delegate
		{
			Logger.LogMessage((object)("Admin status sync event received, X_Mod: " + (SynchronizationManager.Instance.PlayerIsAdmin ? "You're admin now" : "Downvoted, boy")));
		};
	}

	private void DoSync()
	{
		try
		{
			SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
			{
				if (attr.InitialSynchronization)
				{
					Logger.LogMessage((object)"Initial Config sync event received for X_Mod");
				}
				else
				{
					Logger.LogMessage((object)"Config sync event received for X_Mod");
				}
			};
			SynchronizationManager.OnAdminStatusChanged += delegate
			{
				Logger.LogMessage((object)("Admin status sync event received, X_Mod: " + (SynchronizationManager.Instance.PlayerIsAdmin ? "You're admin now" : "Downvoted, boy")));
			};
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while doing Server Synchronization: {arg}");
		}
		finally
		{
			PrefabManager.OnPrefabsRegistered -= DoSync;
		}
	}

	private void Awake()
	{
		try
		{
			CreateConfigurationValues();
			Log = ((BaseUnityPlugin)this).Logger;
			if (LoggingEnable.Value)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Logging is enabled in the config.");
			}
			if (ModEnable.Value)
			{
				AddLocalization();
				LoadBundle();
				AddSFX();
				AddPrefabs();
				AddItems();
				AddMonsters();
				PrefabManager.OnPrefabsRegistered -= DoSync;
			}
			if (SpawnsEnable.Value)
			{
				SpawnerConfigurationManager.OnConfigure += ConfigureWorldSpawners;
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while initalizing plugin: {arg}");
		}
	}

	public void AddLocalization()
	{
		try
		{
			LocalDemonDevil = LocalizationManager.Instance.GetLocalization();
			CustomLocalization localDemonDevil = LocalDemonDevil;
			string text = "English";
			localDemonDevil.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_demonblood_dd", "Demonic Blood" },
				{ "item_demonblood_desc_dd", "If your brave enough, drink it." },
				{ "enemy_gelugon_dd", "Gelugon" },
				{ "enemy_abishai_dd", "Abishai" },
				{ "enemy_lemure_dd", "Lemure" },
				{ "enemy_babauminion_dd", "Babau" },
				{ "enemy_mahataaminion_dd", "Mahataam" },
				{ "enemy_maneminion_dd", "Mane" },
				{ "enemy_maurezhiminion_dd", "Maurezhi" },
				{ "effect_immunity_dd", "<color=#ffd833>Immune</color>" },
				{ "effect_bleeds_tooltip_dd", "You are taking periodic damage due to an injury." },
				{ "effect_rend_dd", "Rend" },
				{ "effect_lacerate_dd", "Laceration" },
				{ "effect_rupture_dd", "Ruptured" },
				{ "effect_hemorrage_dd", "Hemorrage" },
				{ "effect_maim_dd", "Maimed" }
			});
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding Localication: {arg}");
		}
	}

	public void LoadBundle()
	{
		try
		{
			bundleDemonDevil = AssetUtils.LoadAssetBundleFromResources("demonanddevil", Assembly.GetExecutingAssembly());
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while loading Bundle: {arg}");
		}
	}

	private void AddPrefabs()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = prefabList;
			foreach (string text in array)
			{
				GameObject val = bundleDemonDevil.LoadAsset<GameObject>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomPrefab val2 = new CustomPrefab(val, false);
					PrefabManager.Instance.AddPrefab(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added: " + text + " to the Object database"));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding Prefabs: {arg}");
		}
	}

	private void AddSFX()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = sfxList;
			foreach (string text in array)
			{
				GameObject val = bundleDemonDevil.LoadAsset<GameObject>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomPrefab val2 = new CustomPrefab(val, false);
					PrefabManager.Instance.AddPrefab(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added: " + text + " to the Object database"));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding sfx prefabs: {arg}");
		}
	}

	private void AddItems()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = itemList;
			foreach (string text in array)
			{
				GameObject val = bundleDemonDevil.LoadAsset<GameObject>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomItem val2 = new CustomItem(val, true);
					ItemManager.Instance.AddItem(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added: " + text + " to the Item database"));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding item prefabs: {arg}");
		}
	}

	public void AddDoTEffects()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = seDoTList;
			foreach (string text in array)
			{
				SE_DoT_HS val = bundleDemonDevil.LoadAsset<SE_DoT_HS>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomStatusEffect val2 = new CustomStatusEffect((StatusEffect)(object)val, true);
					ItemManager.Instance.AddStatusEffect(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added: " + text + " to the Status Effect database"));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding DoT Effects: {arg}");
		}
	}

	public void AddSEStatsEffects()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = seDoTList;
			foreach (string text in array)
			{
				SE_Stats val = bundleDemonDevil.LoadAsset<SE_Stats>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomStatusEffect val2 = new CustomStatusEffect((StatusEffect)(object)val, true);
					ItemManager.Instance.AddStatusEffect(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added: " + text + " to the Status Effect database"));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding DoT Effects: {arg}");
		}
	}

	private void AddMonsters()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		try
		{
			string[] array = monsterList;
			foreach (string text in array)
			{
				GameObject val = bundleDemonDevil.LoadAsset<GameObject>(text);
				if ((Object)(object)val != (Object)null)
				{
					CustomCreature val2 = new CustomCreature(val, true);
					CreatureManager.Instance.AddCreature(val2);
					if (LoggingEnable.Value)
					{
						((BaseUnityPlugin)this).Logger.LogMessage((object)("Added monster: " + text));
					}
				}
			}
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding monsters: {arg}");
		}
	}

	private void FixSFX()
	{
		try
		{
			AudioSource prefab = Cache.GetPrefab<AudioSource>("sfx_arrow_hit");
			string[] array = sfxList;
			foreach (string text in array)
			{
				GameObject prefab2 = Cache.GetPrefab<GameObject>(text);
				prefab2.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = prefab.outputAudioMixerGroup;
				if (LoggingEnable.Value)
				{
					((BaseUnityPlugin)this).Logger.LogMessage((object)("Audio Mixer, SFX, set on: " + text));
				}
			}
		}
		catch
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"SFX Fix Failed");
		}
	}

	private static void ConfigureWorldSpawners(ISpawnerConfigurationCollection config)
	{
		try
		{
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23001u).SetPrefabName("BabauMinion_DD").SetTemplateName("Babau")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)32 })
				.SetSpawnChance(20f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23002u).SetPrefabName("ManeMinion_DD").SetTemplateName("Mane")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)32 })
				.SetSpawnChance(10f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23003u).SetPrefabName("MaurezhiMinion_DD").SetTemplateName("Maurezhi")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)32 })
				.SetSpawnChance(15f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23004u).SetPrefabName("Lemure_DD").SetTemplateName("Lemure")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)32 })
				.SetSpawnChance(20f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23005u).SetPrefabName("Gelugon_DD").SetTemplateName("Gelugon")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)32 })
				.SetSpawnChance(10f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23006u).SetPrefabName("Abishai_DD").SetTemplateName("Abishai")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)64 })
				.SetSpawnChance(20f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f);
			ISpawnerConfigurationCollectionWorldSpawnerExtensions.ConfigureWorldSpawner(config, 23007u).SetPrefabName("MahataaMinion_DD").SetTemplateName("Mahataa")
				.SetConditionBiomes((Biome[])(object)new Biome[1] { (Biome)2 })
				.SetSpawnChance(10f)
				.SetSpawnInterval(TimeSpan.FromSeconds(360.0))
				.SetPackSizeMin(1u)
				.SetPackSizeMax(2u)
				.SetMaxSpawned(1u)
				.SetSpawnAtDistanceToPlayerMin(60f)
				.SetSpawnAtDistanceToPlayerMax(100f)
				.SetMinDistanceToOther(75f)
				.SetConditionAltitudeMin(0.1f)
				.SetConditionRequiredGlobalKey("defeated_fader");
		}
		catch (Exception ex)
		{
			Log.LogError((object)ex);
		}
	}
}