Decompiled source of RespawnableUniques v1.0.0

plugins/RespawnableUniques.dll

Decompiled a month ago
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 HarmonyLib;
using UnityEngine;

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

[BepInPlugin("johbenji.respawnableUniques", "Respawnable Uniques", "1.0.0")]
public class RespawnableUniquesPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(EnvironmentSave), "ApplyData")]
	private class resetParameters
	{
		private static void Postfix(ref bool __result, string ___AreaName)
		{
			if ((Object)(object)manager == (Object)null)
			{
				manager = QuestEventManager.Instance;
			}
			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);
					resetUniqueQuestEvent();
				}
			}
		}
	}

	public const string GUID = "johbenji.respawnableUniques";

	public const string NAME = "Respawnable Uniques";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

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

	public static QuestEventManager manager;

	private List<string> uniqueDEEnemies = new List<string>
	{
		"AccursedWendigoDeath", "AnnoyingTroglodyteDeath", "ArmoredThugDeath", "ArmyOfTheAncestorsDeath", "BlackStekosaurDeath", "BurningSandroseHorrorDeath", "ChromaticElementalDeath", "CrackedGargoyleDeath", "DesertCrusherDeath", "ExecutionerBugDeath",
		"GlacialTuanosaurDeath", "GoldenMatriarchDeath", "GrandmotherMedyseDeath", "GreaterGrotesqueDeath", "KaziteCaptainDeath", "LightningBladeDancerDeath", "LiquidCooledGolemDeath", "PrototypeLightningGolemDeath", "QuartzElementalDeath", "RustedGolemDeath",
		"SheWhoSpeaksDeath", "TheLastAcolyteDeath", "TroglodyteArchmageDeath", "VileIlluminatorDeath", "VirulentHivemanDeath", "VolcanicSlugDeath", "General_RoyalHunter", "SideQuests_GreenLord", "SideQuests_RedLichWendigoKilled", "SideQuests_BossGolemGarden"
	};

	internal void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		new Harmony("johbenji.respawnableUniques").PatchAll();
		foreach (string uniqueDEEnemy in uniqueDEEnemies)
		{
			questEvents.Add(uniqueDEEnemy, null);
		}
	}

	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 static void displayQEDictionary()
	{
		if (questEvents == null)
		{
			return;
		}
		foreach (string key in questEvents.Keys)
		{
			Log.LogMessage((object)("QuestName=" + key + ", Quest UID=" + questEvents[key]));
		}
	}

	public static void resetUniqueQuestEvent()
	{
		foreach (KeyValuePair<string, string> questEvent in questEvents)
		{
			if (questEvent.Value != null && !(questEvent.Value == ""))
			{
				string value = questEvent.Value;
				int eventCurrentStack = manager.GetEventCurrentStack(value);
				if (eventCurrentStack != 0)
				{
					manager.ReduceEventStack(value, eventCurrentStack, true);
				}
			}
		}
	}
}