using System;
using System.Collections.Generic;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Toolbot;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.EntityStates.Toolbot;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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: AssemblyCompany("HIFUMultTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HIFUMultTweaks")]
[assembly: AssemblyTitle("HIFUMultTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace HIFUMultTweaks
{
public class ConfigManager
{
internal static bool ConfigChanged;
internal static bool VersionChanged;
public static T HandleConfig<T>(ConfigEntryBase entry, ConfigFile config, string name)
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
where x.Name == "Bind"
select x).First();
methodInfo = methodInfo.MakeGenericMethod(typeof(T));
object[] parameters = new object[3]
{
(object)new ConfigDefinition(Regex.Replace(config.ConfigFilePath, "\\W", "") + " : " + entry.Definition.Section, name),
entry.DefaultValue,
(object)new ConfigDescription(entry.Description.Description, (AcceptableValueBase)null, Array.Empty<object>())
};
ConfigEntryBase val = (ConfigEntryBase)methodInfo.Invoke(config, parameters);
if (Main._preVersioning)
{
entry.BoxedValue = entry.DefaultValue;
}
if (!ConfigEqual(val.DefaultValue, val.BoxedValue) && VersionChanged)
{
entry.BoxedValue = entry.DefaultValue;
val.BoxedValue = val.DefaultValue;
}
return default(T);
}
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;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("HIFU.HIFUMultTweaks", "HIFUMultTweaks", "1.0.7")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "HIFU.HIFUMultTweaks";
public const string PluginAuthor = "HIFU";
public const string PluginName = "HIFUMultTweaks";
public const string PluginVersion = "1.0.7";
public static ConfigFile HMTConfig;
public static ConfigFile HMTBackupConfig;
public static ManualLogSource HMTLogger;
public static bool _preVersioning;
public static ConfigEntry<bool> enableAutoConfig { get; set; }
public static ConfigEntry<string> latestVersion { get; set; }
public void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
HMTLogger = ((BaseUnityPlugin)this).Logger;
HMTConfig = ((BaseUnityPlugin)this).Config;
HMTBackupConfig = new ConfigFile(Paths.ConfigPath + "\\HIFU.HIFUMultTweaks.Backup.cfg", true);
HMTBackupConfig.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 :");
enableAutoConfig = HMTConfig.Bind<bool>("Config", "Enable Auto Config Sync", true, "Disabling this would stop HIFMultTweaks from syncing config whenever a new version is found.");
_preVersioning = !((Dictionary<ConfigDefinition, string>)AccessTools.DeclaredPropertyGetter(typeof(ConfigFile), "OrphanedEntries").Invoke(HMTConfig, null)).Keys.Any((ConfigDefinition x) => x.Key == "Latest Version");
latestVersion = HMTConfig.Bind<string>("Config", "Latest Version", "1.0.7", "DO NOT CHANGE THIS");
if (enableAutoConfig.Value && (_preVersioning || latestVersion.Value != "1.0.7"))
{
latestVersion.Value = "1.0.7";
ConfigManager.VersionChanged = true;
HMTLogger.LogInfo((object)"Config Autosync Enabled.");
}
IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(TweakBase))
select type;
HMTLogger.LogInfo((object)"==+----------------==TWEAKS==----------------+==");
foreach (Type item in enumerable)
{
TweakBase tweakBase = (TweakBase)Activator.CreateInstance(item);
if (ValidateTweak(tweakBase))
{
tweakBase.Init();
}
}
IEnumerable<Type> enumerable2 = from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(MiscBase))
select type;
HMTLogger.LogInfo((object)"==+----------------==MISC==----------------+==");
foreach (Type item2 in enumerable2)
{
MiscBase miscBase = (MiscBase)Activator.CreateInstance(item2);
if (ValidateMisc(miscBase))
{
miscBase.Init();
}
}
}
public bool ValidateTweak(TweakBase tb)
{
if (tb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(tb.Name, "Enable?", true, "Vanilla is false").Value)
{
return true;
}
return false;
}
public bool ValidateMisc(MiscBase mb)
{
if (mb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(mb.Name, "Enable?", true, "Vanilla is false").Value)
{
return true;
}
return false;
}
private void UnprocessedIsActuallyMyFavoriteBandNowSorryGuys()
{
}
}
public abstract class MiscBase
{
public abstract string Name { get; }
public virtual bool isEnabled { get; } = true;
public T ConfigOption<T>(T value, string name, string description)
{
ConfigEntry<T> val = Main.HMTConfig.Bind<T>(Name, name, value, description);
ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HMTBackupConfig, name);
return val.Value;
}
public abstract void Hooks();
public string d(float f)
{
return f * 100f + "%";
}
public virtual void Init()
{
Hooks();
Main.HMTLogger.LogInfo((object)("Added " + Name));
}
}
public abstract class MiscBase<T> : MiscBase where T : MiscBase<T>
{
public static T instance { get; set; }
public MiscBase()
{
if (instance != null)
{
throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
}
instance = this as T;
}
}
public class BlastCanister : TweakBase<BlastCanister>
{
public static bool Ignite;
public override string Name => "Secondary : Blast Canister";
public override string SkillToken => "secondary";
public override string DescText => "<style=cIsDamage>Stunning</style>. " + (Ignite ? "<style=cIsDamage>Ignite</style>." : "") + " Launch a canister for <style=cIsDamage>220% damage</style>. Drops <style=cIsDamage>stun</style> bomblets for <style=cIsDamage>5x44% damage</style>.";
public override void Init()
{
Ignite = ConfigOption(value: true, "Ignite?", "Vanilla is false");
base.Init();
}
public override void Hooks()
{
Changes();
}
private void Changes()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (Ignite)
{
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/CryoCanisterProjectile.prefab").WaitForCompletion();
ProjectileDamage component = val.GetComponent<ProjectileDamage>();
component.damageType = DamageTypeCombo.op_Implicit((DamageType)160);
SkillDef val2 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Toolbot/ToolbotBodyStunDrone.asset").WaitForCompletion();
val2.keywordTokens = new string[2] { "KEYWORD_STUNNING", "KEYWORD_IGNITE" };
}
}
}
public class PowerMode : TweakBase<PowerMode>
{
public static BuffDef armorBuff;
public static BuffDef slowBuff;
public static float armor;
public static int count;
public static float speedReduc;
private static float countdown = 1f;
public override string Name => "Special :: Power Mode";
public override string SkillToken => "special_alt";
public override string DescText => "Enter a heavy stance, equipping both your <style=cIsDamage>primary attacks</style> at once. Gain <style=cIsUtility>" + 5f * armor + " decaying armor</style>, but lose <style=cIsHealth>-" + Mathf.Round((1f - 1f / (1f + speedReduc)) * 100f) + "% movement speed</style>.";
public override void Init()
{
armor = ConfigOption(20f, "Armor Buff", "Vanilla is 100");
count = ConfigOption(5, "How many armor stacks to get", "Vanilla is 1 BUT it will decay in a second with vanilla settings, as the decay is 1 stack of armor per second.");
speedReduc = ConfigOption(0.5f, "Slow Debuff", "Decimal. Vanilla is 0.5");
base.Init();
}
public override void Hooks()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
Changes();
ToolbotDualWieldBase.OnEnter += new hook_OnEnter(ToolbotDualWieldBase_OnEnter);
ToolbotDualWield.FixedUpdate += new hook_FixedUpdate(ToolbotDualWield_FixedUpdate);
ToolbotDualWieldBase.OnExit += new hook_OnExit(ToolbotDualWieldBase_OnExit);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void Changes()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
armorBuff = ScriptableObject.CreateInstance<BuffDef>();
armorBuff.isDebuff = false;
armorBuff.canStack = true;
armorBuff.isHidden = false;
((Object)armorBuff).name = "Power Mode Decaying Armor";
armorBuff.buffColor = Color32.op_Implicit(new Color32((byte)214, (byte)201, (byte)58, byte.MaxValue));
armorBuff.iconSprite = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdArmorBoost.asset").WaitForCompletion().iconSprite;
ContentAddition.AddBuffDef(armorBuff);
slowBuff = ScriptableObject.CreateInstance<BuffDef>();
slowBuff.isDebuff = true;
slowBuff.isCooldown = false;
slowBuff.isHidden = false;
slowBuff.buffColor = Color32.op_Implicit(new Color32((byte)234, (byte)104, (byte)107, byte.MaxValue));
((Object)slowBuff).name = "Power Mode Slow";
slowBuff.canStack = false;
slowBuff.iconSprite = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/SprintOutOfCombat/bdWhipBoost.asset").WaitForCompletion().iconSprite;
ContentAddition.AddBuffDef(slowBuff);
}
private void ToolbotDualWieldBase_OnExit(orig_OnExit orig, ToolbotDualWieldBase self)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (((EntityState)self).characterBody.GetBuffCount(armorBuff) > 0)
{
((EntityState)self).characterBody.SetBuffCount(armorBuff.buffIndex, 0);
}
orig.Invoke(self);
}
private void ToolbotDualWield_FixedUpdate(orig_FixedUpdate orig, ToolbotDualWield self)
{
orig.Invoke(self);
countdown -= Time.fixedDeltaTime;
if (countdown <= 0f)
{
if (((EntityState)self).characterBody.GetBuffCount(armorBuff) > 0)
{
((EntityState)self).characterBody.RemoveBuff(armorBuff);
}
countdown = 1f;
}
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
{
if (Object.op_Implicit((Object)(object)sender))
{
if (sender.HasBuff(slowBuff))
{
args.moveSpeedReductionMultAdd += speedReduc;
}
args.armorAdd += armor * (float)sender.GetBuffCount(armorBuff);
}
}
private void ToolbotDualWieldBase_OnEnter(orig_OnEnter orig, ToolbotDualWieldBase self)
{
self.applyBonusBuff = false;
ToolbotDualWieldBase.penaltyBuff = slowBuff;
for (int i = 0; i < count; i++)
{
((EntityState)self).characterBody.AddBuff(armorBuff);
}
orig.Invoke(self);
}
}
public abstract class TweakBase
{
public abstract string Name { get; }
public abstract string SkillToken { get; }
public abstract string DescText { get; }
public virtual bool isEnabled { get; } = true;
public T ConfigOption<T>(T value, string name, string description)
{
ConfigEntry<T> val = Main.HMTConfig.Bind<T>(Name, name, value, description);
ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HMTBackupConfig, name);
return val.Value;
}
public abstract void Hooks();
public string d(float f)
{
return f * 100f + "%";
}
public virtual void Init()
{
Hooks();
string text = "TOOLBOT_" + SkillToken.ToUpper() + "_DESCRIPTION";
LanguageAPI.Add(text, DescText);
Main.HMTLogger.LogInfo((object)("Added " + Name));
}
}
public abstract class TweakBase<T> : TweakBase where T : TweakBase<T>
{
public static T instance { get; set; }
public TweakBase()
{
if (instance != null)
{
throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
}
instance = this as T;
}
}
}
namespace HIFUMultTweaks.Misc
{
internal class HurtBox : MiscBase
{
public static float SizeMultiplier;
public override string Name => "Misc : Hurt Box";
public override void Init()
{
SizeMultiplier = ConfigOption(0.8f, "Size Multiplier", "Vanilla is 1");
base.Init();
}
public override void Hooks()
{
Changes();
}
private void Changes()
{
//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)
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/ToolbotBody.prefab").WaitForCompletion();
CapsuleCollider component = ((Component)val.transform.GetChild(0).GetChild(0).GetChild(0)
.GetChild(0)
.Find("tempHurtBox")).GetComponent<CapsuleCollider>();
component.radius = 3.74f * SizeMultiplier;
component.height = 12.04f * SizeMultiplier;
}
}
}