Decompiled source of StageOneAncientWisp v1.0.0

StageOneAncientWisp/StageOneAncientWisp.dll

Decompiled 14 hours ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using AncientWisp;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.MoffeinAncientWispSkills;
using R2API;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("StageOneAncientWisp")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StageOneAncientWisp")]
[assembly: AssemblyTitle("StageOneAncientWisp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SecretsOfTheScug;

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class AutoConfigAttribute : Attribute
{
	public string name;

	public string desc;

	public object defaultValue;

	public AutoConfigAttribute(string name, object defaultValue)
	{
		Init(name, string.Empty, defaultValue);
	}

	public AutoConfigAttribute(string name, string desc, object defaultValue)
	{
		Init(name, desc, defaultValue);
	}

	public void Init(string name, string desc, object defaultValue)
	{
		this.name = name;
		this.desc = desc;
		this.defaultValue = defaultValue;
	}
}
public static class Config
{
	public static ConfigFile MyConfig;

	public static ConfigFile BackupConfig;

	public static void Init()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		MyConfig = new ConfigFile(Paths.ConfigPath + "\\RiskOfBrainrot.StageOneAncientWisp.cfg", true);
		BackupConfig = new ConfigFile(Paths.ConfigPath + "\\RiskOfBrainrot.StageOneAncientWisp.Backup.cfg", true);
		BackupConfig.Bind<string>(": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :");
	}

	public static ConfigEntry<bool> CharacterEnableConfig(string section, string characterName, string description = "", bool enabledByDefault = true)
	{
		if (string.IsNullOrEmpty(description))
		{
			description = "Set to false to disable this character and as much of its code and content as possible";
		}
		return BindAndOptions(section, "Enable " + characterName, enabledByDefault, description, restartRequired: true);
	}

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "", bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, 0f, 20f, description, restartRequired);
	}

	public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, float min, float max, string description = "", bool restartRequired = false)
	{
		if (string.IsNullOrEmpty(description))
		{
			description = name;
		}
		if (restartRequired)
		{
			description += " (restart required)";
		}
		ConfigEntry<T> val = MyConfig.Bind<T>(section, name, defaultValue, description);
		if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
		{
			TryRegisterOption<T>(val, min, max, restartRequired);
		}
		return val;
	}

	public static ConfigEntry<float> BindAndOptionsSlider(string section, string name, float defaultValue, string description, float min = 0f, float max = 20f, bool restartRequired = false)
	{
		return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired);
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired)
	{
	}

	public static bool GetKeyPressed(KeyboardShortcut entry)
	{
		//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_0019: 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)
		foreach (KeyCode modifier in ((KeyboardShortcut)(ref entry)).Modifiers)
		{
			if (!Input.GetKey(modifier))
			{
				return false;
			}
		}
		return Input.GetKeyDown(((KeyboardShortcut)(ref entry)).MainKey);
	}
}
public class ConfigManager
{
	internal static bool ConfigChanged;

	internal static bool VersionChanged;

	public static void HandleConfigAttributes(Type type, string section, ConfigFile config)
	{
		TypeInfo typeInfo = type.GetTypeInfo();
		FieldInfo[] fields = typeInfo.GetFields();
		foreach (FieldInfo fieldInfo in fields)
		{
			if (fieldInfo.IsStatic)
			{
				Type fieldType = fieldInfo.FieldType;
				AutoConfigAttribute customAttribute = fieldInfo.GetCustomAttribute<AutoConfigAttribute>();
				if (customAttribute != null)
				{
					string name = customAttribute.name;
					object defaultValue = customAttribute.defaultValue;
					string desc = customAttribute.desc;
					fieldInfo.SetValue(null, DualBindToConfig(fieldType, section, config, name, defaultValue, desc));
				}
			}
		}
	}

	private static object DualBindToConfig(Type t, string section, ConfigFile config, string configName, object defaultValue, string configDesc)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Expected O, but got Unknown
		if (string.IsNullOrWhiteSpace(section) || string.IsNullOrWhiteSpace(configName))
		{
			return defaultValue;
		}
		ConfigDescription val = new ConfigDescription(configDesc, (AcceptableValueBase)null, Array.Empty<object>());
		MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
			where x.Name == "Bind"
			select x).First();
		methodInfo = methodInfo.MakeGenericMethod(t);
		ConfigEntryBase val2 = (ConfigEntryBase)methodInfo.Invoke(config, new object[3]
		{
			(object)new ConfigDefinition(section, configName),
			defaultValue,
			val
		});
		ConfigEntryBase val3 = (ConfigEntryBase)methodInfo.Invoke(Config.BackupConfig, new object[3]
		{
			(object)new ConfigDefinition(Regex.Replace(config.ConfigFilePath, "\\W", "") + " : " + section, configName),
			defaultValue,
			val
		});
		if (!ConfigEqual(val3.DefaultValue, val3.BoxedValue))
		{
			bool flag = true;
			Log.Warning("Syncing config to new version");
			val2.BoxedValue = val2.DefaultValue;
			val3.BoxedValue = val3.DefaultValue;
		}
		if (!ConfigEqual(val2.DefaultValue, val2.BoxedValue))
		{
			ConfigChanged = true;
		}
		return val2.BoxedValue;
	}

	public static T DualBindToConfig<T>(string section, ConfigFile config, string configName, T defaultValue, string configDesc)
	{
		return (T)DualBindToConfig(typeof(T), section, config, configName, defaultValue, configDesc);
	}

	private static bool ConfigEqual(object a, object b)
	{
		if (a.Equals(b))
		{
			return true;
		}
		if (float.TryParse(a.ToString(), out var result) && float.TryParse(b.ToString(), out var result2) && (double)Mathf.Abs(result - result2) < 0.0001)
		{
			return true;
		}
		return false;
	}
}
internal static class Log
{
	private static ManualLogSource _logSource;

	internal static void Init(ManualLogSource logSource)
	{
		_logSource = logSource;
	}

	internal static void Debug(object data)
	{
		_logSource.LogDebug(data);
	}

	internal static void Error(object data)
	{
		_logSource.LogError(data);
	}

	internal static void Fatal(object data)
	{
		_logSource.LogFatal(data);
	}

	internal static void Info(object data)
	{
		_logSource.LogInfo(data);
	}

	internal static void Message(object data)
	{
		_logSource.LogMessage(data);
	}

	internal static void Warning(object data)
	{
		_logSource.LogWarning(data);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("RiskOfBrainrot.StageOneAncientWisp", "StageOneAncientWisp", "1.0.0")]
public class StageOneAncientWisp : BaseUnityPlugin
{
	public const string PluginGUID = "RiskOfBrainrot.StageOneAncientWisp";

	public const string PluginAuthor = "RiskOfBrainrot";

	public const string PluginName = "StageOneAncientWisp";

	public const string PluginVersion = "1.0.0";

	public void Awake()
	{
		Log.Init(((BaseUnityPlugin)this).Logger);
		ChangeSkills();
		StatChanges();
		SpawnCardChanges();
		AIChanges();
	}

	private void AIChanges()
	{
	}

	private void SpawnCardChanges()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_0030: Expected O, but got Unknown
		DirectorCard card = AWContent.AncientWispCard.Card;
		card.spawnCard.directorCreditCost = 600;
		DirectorCardHolder val = new DirectorCardHolder
		{
			Card = card,
			MonsterCategory = (MonsterCategory)4
		};
		Helpers.RemoveExistingMonster(((Object)card.spawnCard).name);
		Helpers.AddNewMonsterToStage(val, true, (Stage)67108864, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)1073741824, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)2147483648u, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)34359738368L, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)68719476736L, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)16, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)8, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)137438953472L, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)32, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)274877906944L, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)549755813888L, "");
		Helpers.AddNewMonsterToStage(val, true, (Stage)131072, "");
	}

	private void StatChanges()
	{
		GameObject ancientWispObject = AncientWispPlugin.AncientWispObject;
		CharacterBody val = ((ancientWispObject != null) ? ancientWispObject.GetComponent<CharacterBody>() : null);
		if ((Object)(object)val == (Object)null)
		{
			Log.Error("ancientwisp body null!");
		}
		val.baseMaxHealth = 2100f;
		val.levelMaxHealth = 630f;
		val.baseArmor = 0f;
	}

	private void ChangeSkills()
	{
		ChangeChargeBarrage();
		ChangeFireBarrage();
		ChangeEnrage();
		ChangeChannelRain();
	}

	private void ChangeChargeBarrage()
	{
		ChargeBarrage.baseDuration = 2f;
	}

	private void ChangeFireBarrage()
	{
		FireBarrage.bulletCount = 3;
		FireBarrage.baseDurationBetweenShots = 0.24f;
	}

	private void ChangeEnrage()
	{
		Enrage.baseDuration = 4f;
	}

	private void ChangeChannelRain()
	{
		ChannelRain.explosionCount = 15;
	}
}