using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DanielSteginkUtils.Loggers;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WavLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DanielSteginkUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("This is a library of custom helpers and logic for Hollow Knight: Silksong mods.")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+2854e38bae5ccae271e6684f80f209539d5c3eb6")]
[assembly: AssemblyProduct("DanielSteginkUtils")]
[assembly: AssemblyTitle("DanielSteginkUtils")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/danielstegink/Silksong.DanielSteginkUtils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace DanielSteginkUtils
{
[BepInPlugin("io.github.danielstegink.danielsteginkutils", "DanielSteginkUtils", "2.0.0")]
public class DanielSteginkUtils : BaseUnityPlugin
{
public const string Id = "io.github.danielstegink.danielsteginkutils";
internal static DanielSteginkUtils Instance { get; private set; }
public static string Name => "DanielSteginkUtils";
public static string Version => "2.0.0";
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
new Harmony("io.github.danielstegink.danielsteginkutils").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.danielstegink.danielsteginkutils) has loaded!"));
}
internal void Log(string message)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)message);
}
}
}
namespace DanielSteginkUtils.Utilities
{
public static class Calculations
{
public static float GetSilkPerSoul()
{
float num = 99f;
return 9f / num;
}
}
public static class ClassIntegrations
{
public static O GetField<I, O>(I input, string fieldName, BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
{
return (O)typeof(I).GetField(fieldName, flags).GetValue(input);
}
public static void SetField<I>(I input, string fieldName, object value, BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
{
typeof(I).GetField(fieldName, flags).SetValue(input, value);
}
public static O GetProperty<I, O>(I input, string fieldName, BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
{
return (O)typeof(I).GetProperty(fieldName, flags).GetValue(input);
}
public static void SetProperty<I>(I input, string fieldName, object value, BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
{
typeof(I).GetProperty(fieldName, flags).SetValue(input, value);
}
public static O CallFunction<I, O>(I input, string fieldName, object[] parameters, BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
{
return (O)typeof(I).GetMethod(fieldName, flags).Invoke(input, parameters);
}
}
public static class Components
{
public static void RemoveComponent<T>(this GameObject gameObject) where T : Component
{
T component = gameObject.GetComponent<T>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
}
}
public static class NotchCosts
{
public static float NailDamagePerNotch()
{
return 0.5f / (float)UnbreakableCharmCost(3);
}
public static float SpellDamagePerNotch()
{
return 1f / 6f;
}
public static float SingleSpellDamagePerNotch()
{
return 3f * SpellDamagePerNotch();
}
public static float SpellDiscountPerNotch()
{
return 0f;
}
public static float PassiveHealTime()
{
return 10f * 4f;
}
public static float PassiveSilkTime()
{
return 0.5f * 5f / Calculations.GetSilkPerSoul();
}
public static int UnbreakableCharmCost(int baseCost)
{
return baseCost + 2;
}
}
}
namespace DanielSteginkUtils.Loggers
{
[HarmonyPatch(typeof(HealthManager), "TakeDamage")]
public static class EnemyDamageLogger
{
private static bool isActive;
[HarmonyPrefix]
internal static void Prefix(HealthManager __instance, HitInstance hitInstance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (isActive && (Object)(object)hitInstance.Source != (Object)null)
{
Logging.Log("EnemyDamageLogger", $"Enemy {((Object)((Component)__instance).gameObject).name} taking {hitInstance.DamageDealt} damage (Type {hitInstance.AttackType}) from {((Object)hitInstance.Source).name}");
}
}
public static void Toggle(bool isActive)
{
EnemyDamageLogger.isActive = isActive;
}
}
internal static class Logging
{
internal static void Log(string prefix, string message, bool performLogging = false)
{
if (performLogging)
{
DanielSteginkUtils.Instance.Log(prefix + " - " + message);
}
}
}
}
namespace DanielSteginkUtils.Helpers
{
public static class DamageEnemy
{
public static void DealDamage(HealthManager enemy, int amount, AttackTypes attackType, string attackName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(attackName);
DealDamage(enemy, amount, attackType, val);
Object.Destroy((Object)(object)val);
}
public static void DealDamage(HealthManager enemy, int amount, AttackTypes attackType, GameObject attacker)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
HitInstance val = default(HitInstance);
val.DamageDealt = amount;
val.AttackType = attackType;
val.IgnoreInvulnerable = true;
val.Source = attacker;
val.Multiplier = 1f;
HitInstance val2 = val;
enemy.Hit(val2);
}
}
public static class GetEnemy
{
public static List<GameObject> GetEnemies(float maxDistance)
{
GameObject[] array = (from x in Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0)
where x.activeSelf
select x).ToArray();
if (array.Length == 0)
{
return new List<GameObject>();
}
GameObject[] array2 = array.Where((GameObject x) => IsEnemy(x)).ToArray();
if (array2.Length == 0)
{
return new List<GameObject>();
}
Transform playerPosition = ((Component)HeroController.instance).gameObject.transform;
return array2.Where((GameObject x) => GetDistance(x.transform, playerPosition) <= maxDistance).ToList();
}
public static bool IsEnemy(GameObject gameObject)
{
bool result = false;
if ((gameObject.layer == 11 || gameObject.tag == "Boss") && (Object)(object)gameObject.GetComponent<HealthManager>() != (Object)null)
{
result = true;
}
return result;
}
public static float GetDistance(Transform enemy, Transform player)
{
float num = Math.Abs(Extensions.GetPositionX(enemy) - Extensions.GetPositionX(player));
float num2 = Math.Abs(Extensions.GetPositionY(enemy) - Extensions.GetPositionY(player));
return (float)Math.Sqrt(num * num + num2 * num2);
}
}
public static class GetTools
{
public static List<string> GetEquippedTools()
{
List<string> list = new List<string>();
foreach (ToolItem item in ToolItemManager.GetUnlockedTools().ToList())
{
if (((ToolBase)item).IsEquipped)
{
list.Add(item.name);
}
}
return list;
}
}
}
namespace DanielSteginkUtils.ExternalFiles
{
public static class GetAssetBundle
{
public static AssetBundle? GetBundle(string path, bool performLogging = false)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
string streamingAssetsPath = Application.streamingAssetsPath;
RuntimePlatform platform = Application.platform;
string text = (((int)platform == 1) ? "StandaloneOSX" : (((int)platform == 2) ? "StandaloneWindows64" : (((int)platform != 13) ? "" : "StandaloneLinux64")));
string path2 = text;
AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.Combine(streamingAssetsPath, "aa", path2), path));
if ((Object)(object)obj == (Object)null)
{
Logging.Log("GetBundle", "Error loading bundle " + path, performLogging);
}
return obj;
}
}
public static class GetAudioClip
{
public static AudioClip? GetAudioClipFromAssembly(string assemblyName, string fileName, bool performLogging = false)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
Logging.Log("GetAudioClipFromAssembly", "Getting " + fileName + " from assembly", performLogging);
Assembly assembly = GetAssembly(assemblyName);
if (assembly == null)
{
Logging.Log("GetAudioClipFromAssembly", "Assembly '" + assemblyName + "' not found");
return null;
}
using Stream stream = assembly.GetManifestResourceStream(fileName ?? "");
if (stream == null)
{
Logging.Log("GetAudioClipFromAssembly", "Embedded resource '" + fileName + "' not found", performLogging);
return null;
}
WavData val = new WavData();
if (!val.Parse(stream, (Action<string>)null))
{
Logging.Log("GetAudioClipFromAssembly", "Unable to parse '" + fileName + "' into WAV data", performLogging);
return null;
}
float[] samples = val.GetSamples();
int num = samples.Length / val.FormatChunk.NumChannels;
int numChannels = val.FormatChunk.NumChannels;
int sampleRate = (int)val.FormatChunk.SampleRate;
AudioClip obj = AudioClip.Create(fileName, num, numChannels, sampleRate, false);
obj.SetData(samples, 0);
Object.DontDestroyOnLoad((Object)(object)obj);
Logging.Log("GetAudioClipFromAssembly", "'" + fileName + "' converted to AudioClip", performLogging);
return obj;
}
private static Assembly GetAssembly(string assemblyName = "")
{
if (string.IsNullOrEmpty(assemblyName))
{
return Assembly.GetExecutingAssembly();
}
return Assembly.Load(assemblyName);
}
}
}