using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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 = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("goldenSlendermen1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1")]
[assembly: AssemblyProduct("TunedThreats")]
[assembly: AssemblyTitle("TunedThreats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.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 TunedThreats
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
TunedThreats.Logger.LogDebug($"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
TunedThreats.Logger.LogDebug($"{__instance} Start Postfix");
}
}
public enum ConfigCategory
{
Huntsman,
Banger,
Robe,
Debug
}
public enum HuntsmanConfig
{
DefaultDamage,
DamageRange
}
public enum BangerConfig
{
ExplosionSize,
ExplosionDelay
}
public enum DebugConfig
{
ExtraLogging
}
public enum RobeConfig
{
AttackWhenStuck
}
[BepInPlugin("goldenSlendermen1.TunedThreats", "TunedThreats", "0.3.1")]
public class TunedThreats : BaseUnityPlugin
{
internal static class Logger
{
private static bool initialized;
private static ManualLogSource Source;
public static void Initialize(ManualLogSource source)
{
if (!initialized)
{
Source = source;
initialized = true;
if (ConfigManager.ExtraLogging)
{
Debug.Log((object)"TurnedThreats Logger Initialized as source \"TunedTh...\"");
}
}
}
public static void LogDebug(object data, bool extra = false)
{
Log((LogLevel)32, data, extra);
}
public static void LogInfo(object data, bool extra = false)
{
Log((LogLevel)16, data, extra);
}
public static void LogWarning(object data, bool extra = false)
{
Log((LogLevel)4, data, extra);
}
public static void LogError(object data, bool extra = false)
{
Log((LogLevel)2, data, extra);
}
private static void Log(LogLevel level, object data, bool extra = false)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
if (!extra || ConfigManager.ExtraLogging)
{
Source.Log(level, data);
}
}
}
internal static TunedThreats Instance { get; private set; }
internal Harmony? Harmony { get; set; }
private void Awake()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Instance = this;
Logger.Initialize(Logger.CreateLogSource("TunedTh..."));
ConfigManager.Initialize(new ConfigFile(Utility.CombinePaths(new string[2]
{
Paths.ConfigPath,
"TunedThreats.cfg"
}), false, MetadataHelper.GetMetadata((object)this)));
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Bang.Initialize(Harmony);
Robe.Initialize(Harmony);
Logger.LogInfo($"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
internal static class ConfigManager
{
private static Dictionary<ConfigCategory, Dictionary<Enum, object>> Config;
public static bool ExtraLogging;
public static bool initialized { get; private set; }
public static ConfigFile File { get; private set; }
public static void Initialize(ConfigFile file)
{
if (!initialized)
{
File = file;
Bind();
initialized = true;
TunedThreats.Logger.LogInfo("Config Initialized", extra: true);
}
}
public static T GetConfig<T, TKey>(ConfigCategory category, TKey key) where TKey : Enum
{
if (!initialized)
{
throw new InvalidOperationException("ConfigManager is not initialized!");
}
Config.TryGetValue(category, out Dictionary<Enum, object> value);
value.TryGetValue(key, out var value2);
ConfigEntry<T> val = value2 as ConfigEntry<T>;
return val.Value;
}
private static void Bind()
{
Config = new Dictionary<ConfigCategory, Dictionary<Enum, object>>
{
{
ConfigCategory.Huntsman,
new Dictionary<Enum, object>
{
{
HuntsmanConfig.DefaultDamage,
File.Bind<int>("Huntsman", "DefaultDamage", 100, "Base damage, applied after the final damage range.")
},
{
HuntsmanConfig.DamageRange,
File.Bind<string>("Huntsman", "DamageRange", "1-2=20 | 3-4=25 | 5-6=35 | 7-8=50", "List of damage applied for each level range.")
}
}
},
{
ConfigCategory.Banger,
new Dictionary<Enum, object>
{
{
BangerConfig.ExplosionSize,
File.Bind<float>("Banger", "ExplosionSize", 2f, "Size of explosion when banger explodes.")
},
{
BangerConfig.ExplosionDelay,
File.Bind<float>("Banger", "ExplosionDelay", 6.5f, "Seconds before explosion.")
}
}
},
{
ConfigCategory.Robe,
new Dictionary<Enum, object> {
{
RobeConfig.AttackWhenStuck,
File.Bind<bool>("Robe", "AttackWhenStuck", false, "If true, robe will attack the nearest object when stuck.")
} }
},
{
ConfigCategory.Debug,
new Dictionary<Enum, object> {
{
DebugConfig.ExtraLogging,
File.Bind<bool>("Debug", "ExtraLogging", false, "If true, displays extra logs.")
} }
}
};
ExtraLogging = (Config[ConfigCategory.Debug][DebugConfig.ExtraLogging] as ConfigEntry<bool>).Value;
}
}
[HarmonyPatch(typeof(EnemyHunter), "Awake")]
public static class Hunter
{
[HarmonyPostfix]
private static void AwakePatch(EnemyHunter __instance)
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
string config = ConfigManager.GetConfig<string, HuntsmanConfig>(ConfigCategory.Huntsman, HuntsmanConfig.DamageRange);
int num = StatsManager.instance.runStats["level"] + 1;
int result = ConfigManager.GetConfig<int, HuntsmanConfig>(ConfigCategory.Huntsman, HuntsmanConfig.DefaultDamage);
string[] array = config.Split("|");
foreach (string text in array)
{
string[] array2 = text.Split("=");
if (array2.Length != 2)
{
TunedThreats.Logger.LogWarning("Config Huntsman_DamageRange is of an invalid format!");
__instance.hurtCollider.playerDamage = result;
return;
}
string text2 = array2[0];
string s = array2[1];
if (text2.Contains(num.ToString()))
{
if (int.TryParse(s, out result))
{
break;
}
TunedThreats.Logger.LogWarning("Range \"" + text2 + "\" does not have a valid damage value!");
}
}
__instance.hurtCollider.playerDamage = result;
if (ConfigManager.ExtraLogging)
{
TunedThreats.Logger.LogInfo($"Huntsman damage changed from 100 to {__instance.hurtCollider.playerDamage}", extra: true);
}
}
}
public static class Bang
{
private static readonly bool Initialized;
private static float ExplosionSizeConfig;
private static float ExplosionDelayConfig;
public static void Initialize(Harmony harmony)
{
if (!Initialized)
{
ExplosionSizeConfig = ConfigManager.GetConfig<float, BangerConfig>(ConfigCategory.Banger, BangerConfig.ExplosionSize);
ExplosionDelayConfig = ConfigManager.GetConfig<float, BangerConfig>(ConfigCategory.Banger, BangerConfig.ExplosionDelay);
Patch(harmony);
}
}
private static void Patch(Harmony harmony)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(EnemyBang), "ExplodeRPC", (Type[])null, (Type[])null);
HarmonyMethod val = new HarmonyMethod(typeof(Bang).GetMethod("ExplodeRPCPatch", BindingFlags.Static | BindingFlags.NonPublic));
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
methodInfo = AccessTools.Method(typeof(EnemyBang), "FuseLogic", (Type[])null, (Type[])null);
val = new HarmonyMethod(typeof(Bang).GetMethod("FuseLogicOverride", BindingFlags.Static | BindingFlags.NonPublic));
harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static void ExplodeRPCPatch(EnemyBang __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
object value = AccessTools.Field(typeof(EnemyBang), "explosionScript").GetValue(__instance);
if (value == null)
{
Debug.LogWarning((object)"Couldn't get ExplosionScript for enemy Bang!");
return;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(ParticlePrefabExplosion), "explosionSize");
fieldInfo.SetValue(value, ExplosionSizeConfig);
}
}
private static bool FuseLogicOverride(EnemyBang __instance)
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return true;
}
if (__instance.fuseActive)
{
if (!EnemyBangDirector.instance.debugNoFuseProgress)
{
__instance.fuseLerp += Time.deltaTime / ExplosionDelayConfig;
}
__instance.fuseLerp = Mathf.Clamp01(__instance.fuseLerp);
if (SemiFunc.IsMasterClientOrSingleplayer() && __instance.fuseLerp >= 1f)
{
if (SemiFunc.IsMultiplayer())
{
__instance.photonView.RPC("ExplodeRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
__instance.ExplodeRPC();
}
__instance.UpdateState((State)11);
__instance.stateImpulse = false;
__instance.enemy.EnemyParent.Despawn();
}
}
return false;
}
}
public static class Robe
{
private static readonly bool Initialized = false;
private static bool StuckAttackStateEnabled = true;
public static void Initialize(Harmony harmony)
{
if (!Initialized)
{
StuckAttackStateEnabled = ConfigManager.GetConfig<bool, RobeConfig>(ConfigCategory.Robe, RobeConfig.AttackWhenStuck);
Patch(harmony);
}
}
private static void Patch(Harmony harmony)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(EnemyRobe), "UpdateState", (Type[])null, (Type[])null);
HarmonyMethod val = new HarmonyMethod(typeof(Robe).GetMethod("UpdateStateOverride", BindingFlags.Static | BindingFlags.NonPublic));
harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static bool UpdateStateOverride(EnemyRobe __instance, State _state)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Invalid comparison between Unknown and I4
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return false;
}
if ((int)_state != 11)
{
return true;
}
if (StuckAttackStateEnabled || true)
{
TunedThreats.Logger.LogInfo("Denied state \"StuckAttack\"", extra: true);
if (__instance.currentState == _state)
{
return false;
}
TunedThreats.Logger.LogInfo("Denied state \"StuckAttack\", state changed to \"Roam\"", extra: true);
__instance.currentState = (State)2;
__instance.stateTimer = 0f;
if (GameManager.Multiplayer())
{
__instance.photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { __instance.currentState });
return false;
}
__instance.UpdateStateRPC(__instance.currentState);
}
return true;
}
}
}