using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using Dolso.RiskofOptions;
using EntityStates;
using EntityStates.Commando.CommandoWeapon;
using EntityStates.Huntress.HuntressWeapon;
using EntityStates.Toolbot;
using EntityStates.VoidSurvivor.Weapon;
using HG.GeneralSerializer;
using HG.Reflection;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Orbs;
using RoR2.Skills;
using RoR2BepInExPack.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UncapAttackSpeed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+176a781eb39a8f0c8440df836a367d277690c530")]
[assembly: AssemblyProduct("UncapAttackSpeed")]
[assembly: AssemblyTitle("UncapAttackSpeed")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
internal static void debug(object data)
{
logger.LogDebug(data);
}
internal static void info(object data)
{
logger.LogInfo(data);
}
internal static void message(object data)
{
logger.LogMessage(data);
}
internal static void warning(object data)
{
logger.LogWarning(data);
}
internal static void error(object data)
{
logger.LogError(data);
}
internal static void fatal(object data)
{
logger.LogFatal(data);
}
internal static void LogError(this ILCursor c, object data)
{
logger.LogError((object)string.Format($"ILCursor failure: {data}\n{c}"));
}
internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
{
logger.LogError((object)string.Format($"ILCursor failure in {callerName}: {data}\n{c}"));
}
}
internal static class HookManager
{
internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly List<IDetour> hooks = new List<IDetour>();
private static ILHookConfig ilHookConfig = new ILHookConfig
{
ManualApply = true
};
private static HookConfig onHookConfig = new HookConfig
{
ManualApply = true
};
internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
{
Hook(GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
return;
}
try
{
ILHook val = new ILHook(methodFrom, ilHook, ref ilHookConfig);
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
internal static void Hook(Delegate from, Manipulator ilHook)
{
Hook(from.Method, ilHook);
}
internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
{
Hook(((MethodCallExpression)from.Body).Method, ilHook);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
{
Hook(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook)
{
Hook(methodFrom, onHook, null);
}
internal static void Hook(MethodBase methodFrom, Delegate onHook)
{
Hook(methodFrom, onHook.Method, onHook.Target);
}
internal static void Hook(Delegate from, Delegate onHook)
{
Hook(from.Method, onHook.Method, onHook.Target);
}
internal static void Hook<T>(Expression<Action<T>> from, Delegate onHook)
{
Hook(((MethodCallExpression)from.Body).Method, onHook.Method, onHook.Target);
}
internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
{
Hook(GetMethod(typeFrom, methodFrom), onHook.Method, instance);
}
internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null methodFrom for hook: " + onHook.Name);
return;
}
try
{
Hook val = new Hook(methodFrom, onHook, target, ref onHookConfig);
val.Apply();
hooks.Add((IDetour)(object)val);
}
catch (Exception ex)
{
log.error($"Failed to apply onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
}
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig<T>(enabled, GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig<T>(enabled, methodFrom, ilHook);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.AddHookConfig<T>(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Delegate onHook)
{
configEntry.AddHookConfig<T>(enabled, methodFrom, onHook.Method, onHook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig<bool>(BoolConfigEnabled(configEntry), GetMethod(typeFrom, methodFrom), ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
{
configEntry.AddHookConfig<bool>(BoolConfigEnabled(configEntry), methodFrom, ilHook);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
{
configEntry.AddHookConfig<bool>(BoolConfigEnabled(configEntry), GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target);
}
internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
{
configEntry.AddHookConfig<bool>(BoolConfigEnabled(configEntry), methodFrom, onHook.Method, onHook.Target);
}
private static Func<bool> BoolConfigEnabled(ConfigEntry<bool> configEntry)
{
return () => configEntry.Value;
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Manipulator ilHook)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name);
return;
}
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to ilHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
}
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, MethodInfo onHook, object target)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (methodFrom == null)
{
log.error("null MethodFrom for hook: " + onHook.Name);
return;
}
try
{
configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig));
}
catch (Exception ex)
{
log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}");
}
}
private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, IDetour detour)
{
hooks.Add(detour);
configEntry.SettingChanged += delegate
{
UpdateHook(detour, enabled());
};
if (enabled())
{
detour.Apply();
}
}
private static void UpdateHook(IDetour hook, bool enabled)
{
if (enabled)
{
if (!hook.IsApplied)
{
hook.Apply();
}
}
else if (hook.IsApplied)
{
hook.Undo();
}
}
internal static void PriorityFirst()
{
ilHookConfig.Before = new string[1] { "*" };
onHookConfig.Before = new string[1] { "*" };
}
internal static void PriorityLast()
{
ilHookConfig.After = new string[1] { "*" };
onHookConfig.After = new string[1] { "*" };
}
internal static void PriorityNormal()
{
ilHookConfig.Before = null;
onHookConfig.Before = null;
ilHookConfig.After = null;
onHookConfig.After = null;
}
internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
try
{
return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig);
}
catch (Exception ex)
{
log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
}
return null;
}
internal static MethodInfo GetMethod(Type typeFrom, string methodFrom)
{
IEnumerable<MethodInfo> source = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where predicate.Name == methodFrom
select predicate;
if (source.Count() == 1)
{
return source.First();
}
if (source.Count() == 0)
{
log.error($"Failed to find method: {typeFrom}.{methodFrom}");
}
if (source.Count() > 1)
{
log.error($"{source.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}");
}
return null;
}
}
internal static class Utilities
{
private static GameObject _prefabParent;
internal static GameObject CreatePrefab(GameObject gameObject)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)_prefabParent))
{
_prefabParent = new GameObject("DolsoPrefabs");
Object.DontDestroyOnLoad((Object)(object)_prefabParent);
((Object)_prefabParent).hideFlags = (HideFlags)61;
_prefabParent.SetActive(false);
}
return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
}
internal static GameObject CreatePrefab(GameObject gameObject, string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)_prefabParent))
{
_prefabParent = new GameObject("DolsoPrefabs");
Object.DontDestroyOnLoad((Object)(object)_prefabParent);
((Object)_prefabParent).hideFlags = (HideFlags)61;
_prefabParent.SetActive(false);
}
GameObject obj = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
((Object)obj).name = name;
return obj;
}
internal static MethodInfo MakeGenericMethod<T>(this Type type, string methodName, params Type[] parameters)
{
return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T));
}
internal static MethodInfo MakeGenericGetComponentG<T>() where T : Component
{
return typeof(GameObject).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
}
internal static MethodInfo MakeGenericGetComponentC<T>() where T : Component
{
return typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T));
}
internal static AssetBundle LoadAssetBundle(string bundlePathName)
{
AssetBundle result = null;
try
{
result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName));
}
catch (Exception ex)
{
log.error("Failed to load assetbundle\n" + ex);
}
return result;
}
internal static Obj GetAddressable<Obj>(string addressable) where Obj : Object
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<Obj>((object)addressable).WaitForCompletion();
}
internal static GameObject GetAddressable(string addressable)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Addressables.LoadAssetAsync<GameObject>((object)addressable).WaitForCompletion();
}
internal static void GetAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object
{
//IL_000e: 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)
AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<Obj> a)
{
callback(a.Result);
};
}
internal static void GetAddressable(string addressable, Action<GameObject> callback)
{
//IL_000e: 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)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
callback(a.Result);
};
}
internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
a.Result.AddComponent<Comp>();
};
}
internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : Component
{
//IL_000e: 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)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
callback(a.Result.AddComponent<Comp>());
};
}
internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
val.Completed += delegate(AsyncOperationHandle<GameObject> a)
{
if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
{
a.Result.AddComponent<Comp>();
}
};
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.stringValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue)
{
ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
for (int i = 0; i < serializedFields.Length; i++)
{
if (serializedFields[i].fieldName == fieldName)
{
serializedFields[i].fieldValue.objectValue = newValue;
return;
}
}
log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
}
}
}
namespace Dolso.RiskofOptions
{
internal static class RiskofOptions
{
internal const string rooGuid = "com.rune580.riskofoptions";
internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
internal static void SetSprite(Sprite sprite)
{
ModSettingsManager.SetModIcon(sprite);
}
internal static void SetSpriteDefaultIcon()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName);
Texture2D val = new Texture2D(256, 256);
if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png"))))
{
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
}
else
{
log.error("Failed to load icon.png");
}
}
internal static void AddBool(ConfigEntry<bool> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
category = categoryName,
name = name,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddBool(ConfigEntry<bool> entry, string categoryName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
{
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddColor(ConfigEntry<Color> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddKey(ConfigEntry<KeyboardShortcut> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig
{
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
{
min = min,
max = max,
formatString = format,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
}));
}
internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
{
min = min,
max = max,
formatString = format,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
}));
}
internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}")
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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
FloatFieldConfig val = new FloatFieldConfig();
((NumericFieldConfig<float>)val).Min = min;
((NumericFieldConfig<float>)val).Max = max;
((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format);
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val));
}
internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
IntFieldConfig val = new IntFieldConfig();
((NumericFieldConfig<int>)val).Min = min;
((NumericFieldConfig<int>)val).Max = max;
((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault();
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val));
}
internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max,
category = categoryName,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddString(ConfigEntry<string> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
{
submitOn = (SubmitEnum)6,
lineType = (LineType)0,
description = ((ConfigEntryBase)(object)entry).DescWithDefault()
}));
}
internal static void AddOption(ConfigEntry<bool> entry)
{
AddBool(entry);
}
internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name)
{
AddBool(entry, categoryName, name);
}
internal static void AddOption(ConfigEntry<bool> entry, string categoryName)
{
AddBool(entry, categoryName);
}
internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
{
AddEnum<T>(entry);
}
internal static void AddOption(ConfigEntry<Color> entry)
{
AddColor(entry);
}
internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
{
AddKey(entry);
}
internal static void AddOption(ConfigEntry<int> entry)
{
AddInt(entry);
}
internal static void AddOption(ConfigEntry<string> entry)
{
AddString(entry);
}
private static string DescWithDefault(this ConfigEntryBase entry)
{
return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
}
private static string DescWithDefault(this ConfigEntryBase entry, string format)
{
return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description);
}
}
}
namespace UncapAttackSpeed
{
internal class AttackFraction
{
internal static FixedConditionalWeakTable<BaseSkillInstanceData, AttackFraction> skillInstanceToAttackFraction = new FixedConditionalWeakTable<BaseSkillInstanceData, AttackFraction>();
public float attackFraction;
public static AttackFraction Constructor(object _)
{
return new AttackFraction();
}
}
internal static class Commando
{
internal const string baseDuration = "0.1666";
private static bool interrupt;
internal static void DoSetup()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
HookManager.Hook(typeof(FirePistol2).GetMethod("FixedUpdate"), new Manipulator(IL_FirePistol2_FixedUpdate_ExtraAttacks));
HookManager.Hook((MethodBase)typeof(FirePistol2).GetMethod("GetMinimumInterruptPriority"), (Delegate)new Func<Func<FirePistol2, InterruptPriority>, FirePistol2, InterruptPriority>(On_FirePistol2_Priority_AfterDuration));
Utilities.GetAddressable<EntityStateConfiguration>("RoR2/Base/Commando/EntityStates.Commando.CommandoWeapon.FirePistol2.asset", (Action<EntityStateConfiguration>)delegate(EntityStateConfiguration a)
{
a.SetStateConfigIndex("baseDuration", "0.1666");
});
}
private static void IL_FirePistol2_FixedUpdate_ExtraAttacks(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (!val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<BaseSkillState>(a, "get_activatorSkillSlot"),
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<GenericSkill>(a, "get_stock")
}))
{
log.error("Failed: Commando FixedUpdate IL Hook");
return;
}
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Action<FirePistol2>>((Action<FirePistol2>)delegate(FirePistol2 self)
{
if (!((EntityState)self).inputBank.skill1.down)
{
((EntityState)self).outer.SetNextStateToMain();
}
else
{
BaseSkillInstanceData skillInstanceData = ((BaseSkillState)self).activatorSkillSlot.skillInstanceData;
InstanceData val2 = (InstanceData)(object)((skillInstanceData is InstanceData) ? skillInstanceData : null);
if (val2 != null)
{
AttackFraction value = AttackFraction.skillInstanceToAttackFraction.GetValue((BaseSkillInstanceData)(object)val2, (Func<BaseSkillInstanceData, AttackFraction>)AttackFraction.Constructor);
float num;
for (num = (((EntityState)self).fixedAge - self.duration) / self.duration + value.attackFraction; num >= 1f; num -= 1f)
{
Main.extraAttacks = 1;
val2.step++;
if (val2.step >= 2)
{
val2.step = 0;
}
if (val2.step % 2 == 0)
{
((EntityState)self).PlayAnimation("Gesture Additive, Left", "FirePistol, Left");
self.FireBullet("MuzzleLeft");
}
else
{
((EntityState)self).PlayAnimation("Gesture Additive, Right", "FirePistol, Right");
self.FireBullet("MuzzleRight");
}
Main.extraAttacks = 0;
}
value.attackFraction = num;
interrupt = true;
((BaseSkillState)self).activatorSkillSlot.OnExecute();
interrupt = false;
}
}
});
val.Emit(OpCodes.Ret);
}
private static InterruptPriority On_FirePistol2_Priority_AfterDuration(Func<FirePistol2, InterruptPriority> orig, FirePistol2 self)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (!interrupt)
{
return orig(self);
}
return (InterruptPriority)0;
}
}
internal static class Config
{
private static ConfigFile configFile;
public static ConfigEntry<bool> nailgunFinalBurst;
internal static void DoConfig(ConfigFile bepConfigFile)
{
configFile = bepConfigFile;
nailgunFinalBurst = configFile.Bind<bool>("", "Nailgun Final Burst", false, "If should force Nailgun to always fire its final burst exactly once.");
if (RiskofOptions.enabled)
{
DoRiskOfOptions();
}
}
internal static void DoRiskOfOptions()
{
RiskofOptions.SetSpriteDefaultIcon();
RiskofOptions.AddBool(nailgunFinalBurst);
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void ReloadConfig(ConCommandArgs args)
{
configFile.Reload();
Debug.Log((object)"UncapAttackSpeed config reloaded");
}
}
internal static class Huntress
{
internal const string sbaseDuration = "0.5166";
internal const string fbaseDuration = "1.3333";
private static bool interrupt;
internal static void DoSetup()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
HookManager.Hook(typeof(FireSeekingArrow), "FixedUpdate", new Manipulator(IL_FireSeekingArrow_FixedUpdate_Stuff));
HookManager.Hook(typeof(FireSeekingArrow), "GetMinimumInterruptPriority", (Delegate)new Func<Func<FireSeekingArrow, InterruptPriority>, FireSeekingArrow, InterruptPriority>(On_FireSeekingArrow_Priority_AfterDuration));
HookManager.Hook(typeof(FireSeekingArrow), "OnExit", (Delegate)new Action<Action<FireSeekingArrow>, FireSeekingArrow>(On_FireSeekingArrow_OnExit_Excess));
HookManager.Hook(typeof(HuntressArrowOrb), "GetOrbEffect", (Delegate)(Func<Func<HuntressArrowOrb, GameObject>, HuntressArrowOrb, GameObject>)((Func<HuntressArrowOrb, GameObject> orig, HuntressArrowOrb self) => (Main.extraAttacks == 0) ? orig(self) : null));
HookManager.Hook(typeof(HuntressFlurryArrowOrb), "GetOrbEffect", (Delegate)(Func<Func<HuntressFlurryArrowOrb, GameObject>, HuntressFlurryArrowOrb, GameObject>)((Func<HuntressFlurryArrowOrb, GameObject> orig, HuntressFlurryArrowOrb self) => (Main.extraAttacks == 0) ? orig(self) : null));
Utilities.GetAddressable<EntityStateConfiguration>("RoR2/Base/Huntress/EntityStates.Huntress.HuntressWeapon.FireSeekingArrow.asset", (Action<EntityStateConfiguration>)delegate(EntityStateConfiguration a)
{
a.SetStateConfigIndex("baseDuration", "0.5166");
});
Utilities.GetAddressable<EntityStateConfiguration>("RoR2/Base/Huntress/EntityStates.Huntress.HuntressWeapon.FireFlurrySeekingArrow.asset", (Action<EntityStateConfiguration>)delegate(EntityStateConfiguration a)
{
a.SetStateConfigIndex("baseDuration", "1.3333");
});
}
private static void IL_FireSeekingArrow_FixedUpdate_Stuff(ILContext context)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(context);
ILCursor[] array = default(ILCursor[]);
if (val.TryGotoNext(new Func<Instruction, bool>[2]
{
(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchLdfld(a, typeof(FireSeekingArrow), "animator")
}) && val.TryFindNext(ref array, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCall(a, typeof(FireSeekingArrow), "FireOrbArrow")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<FireSeekingArrow, bool>>((Func<FireSeekingArrow, bool>)((FireSeekingArrow self) => ((EntityState)self).fixedAge >= self.duration / 2f));
ILCursor val2 = array[0];
if (val2.TryGotoPrev(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0)
}))
{
val.Emit(OpCodes.Brtrue, (object)val2.MarkLabel());
if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCall(a, typeof(FireSeekingArrow), "FireOrbArrow")
}))
{
val.Emit(OpCodes.Br, (object)val2.MarkLabel());
goto IL_015e;
}
}
}
log.error($"Failed to find IL FireSeekingArrow_FixedUpdate duration\n{val}");
goto IL_015e;
IL_015e:
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(EntityStateMachine), "SetNextStateToMain")
}) && val.TryGotoPrev(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0)
}))
{
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<FireSeekingArrow, bool>>((Func<FireSeekingArrow, bool>)delegate(FireSeekingArrow self)
{
if (!((EntityState)self).inputBank.skill1.down || !Object.op_Implicit((Object)(object)self.huntressTracker) || !Object.op_Implicit((Object)(object)self.huntressTracker.GetTrackingTarget()))
{
return false;
}
interrupt = true;
((EntityState)self).skillLocator.primary.OnExecute();
interrupt = false;
return true;
});
val.Emit(OpCodes.Brfalse, val.Next);
val.Emit(OpCodes.Ret);
}
else
{
log.error($"Failed to find IL FireSeekingArrow_FixedUpdate nextState\n{val}");
}
}
private static void On_FireSeekingArrow_OnExit_Excess(Action<FireSeekingArrow> orig, FireSeekingArrow self)
{
orig(self);
if (!NetworkServer.active)
{
return;
}
while (self.firedArrowCount < self.maxArrowCount)
{
FireExcess(self);
}
BaseSkillInstanceData skillInstanceData = ((EntityState)self).skillLocator.primary.skillInstanceData;
if (skillInstanceData == null)
{
return;
}
AttackFraction value = AttackFraction.skillInstanceToAttackFraction.GetValue(skillInstanceData, (Func<BaseSkillInstanceData, AttackFraction>)AttackFraction.Constructor);
float num;
for (num = (((EntityState)self).fixedAge - self.duration) / self.duration + value.attackFraction; num >= 1f; num -= 1f)
{
for (int i = 0; i < self.maxArrowCount; i++)
{
self.firedArrowCount--;
FireExcess(self);
}
}
value.attackFraction = num;
}
private static void FireExcess(FireSeekingArrow self)
{
self.arrowReloadTimer = 0f;
Main.extraAttacks = 1;
self.FireOrbArrow();
Main.extraAttacks = 0;
}
private static InterruptPriority On_FireSeekingArrow_Priority_AfterDuration(Func<FireSeekingArrow, InterruptPriority> orig, FireSeekingArrow self)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (!interrupt)
{
return orig(self);
}
return (InterruptPriority)0;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.uncapattackspeed", "UncapAttackSpeed", "2.0.3")]
public class Main : BaseUnityPlugin
{
public static int extraAttacks;
private void Awake()
{
log.start(((BaseUnityPlugin)this).Logger);
Config.DoConfig(((BaseUnityPlugin)this).Config);
Commando.DoSetup();
Nailgun.DoSetup();
VoidFiend.DoSetup();
Huntress.DoSetup();
HookManager.Hook(typeof(BulletAttack), "FireSingle", (Delegate)new Action<Action<BulletAttack, Vector3, int>, BulletAttack, Vector3, int>(On_BulletAttack_FireSingle_RemoveTracer));
HookManager.Hook(typeof(BaseState), "AddRecoil", (Delegate)new Action<Action<BaseState, float, float, float, float>, BaseState, float, float, float, float>(On_BaseState_AddRecoil_RemoveRecoil));
}
private static void On_BulletAttack_FireSingle_RemoveTracer(Action<BulletAttack, Vector3, int> orig, BulletAttack self, Vector3 normal, int muzzleIndex)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (extraAttacks > 0)
{
extraAttacks--;
GameObject tracerEffectPrefab = self.tracerEffectPrefab;
GameObject hitEffectPrefab = self.hitEffectPrefab;
self.tracerEffectPrefab = null;
self.hitEffectPrefab = null;
orig(self, normal, muzzleIndex);
self.tracerEffectPrefab = tracerEffectPrefab;
self.hitEffectPrefab = hitEffectPrefab;
}
else
{
orig(self, normal, muzzleIndex);
}
}
private static void On_BaseState_AddRecoil_RemoveRecoil(Action<BaseState, float, float, float, float> orig, BaseState self, float verticalMin, float verticalMax, float horizontalMin, float horizontalMax)
{
if (extraAttacks == 0)
{
orig(self, verticalMin, verticalMax, horizontalMin, horizontalMax);
}
}
}
internal static class Nailgun
{
private static List<FireNailgun> nailgunInstances = new List<FireNailgun>();
internal static void DoSetup()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
HookManager.Hook(typeof(FireNailgun).GetMethod("FixedUpdate"), new Manipulator(IL_FireNailgun_FixedUpdate_ExtraAttacks));
HookManager.Hook((MethodBase)typeof(FireNailgun).GetMethod("OnExit"), (Delegate)new Action<Action<FireNailgun>, FireNailgun>(On_FireNailgun_OnExit_ForceBurst));
HookManager.Hook((MethodBase)typeof(FireNailgun).GetMethod("OnEnter"), (Delegate)new Action<Action<FireNailgun>, FireNailgun>(On_FireNailgun_OnEnter_Track));
}
private static void IL_FireNailgun_FixedUpdate_ExtraAttacks(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
int num2 = default(int);
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<BaseNailgunState>(a, "FireBullet")
}) && val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, ref num2)
}))
{
val.Emit(OpCodes.Ldarg, 0);
val.EmitDelegate<Func<FireNailgun, int>>((Func<FireNailgun, int>)delegate(FireNailgun self)
{
int num = Mathf.FloorToInt(self.refireStopwatch / ((BaseNailgunState)self).duration);
if (num > 0)
{
self.refireStopwatch -= (float)num * ((BaseNailgunState)self).duration;
Main.extraAttacks = num;
return num;
}
return 0;
});
val.Emit(OpCodes.Add);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<BaseNailgunState>(a, "FireBullet")
}))
{
val.Emit(OpCodes.Ldc_I4, 0);
val.Emit(OpCodes.Stsfld, typeof(Main).GetField("extraAttacks"));
}
else
{
log.error($"Failed to find BaseNailgunState.FireBullet\n{val}");
}
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityStateMachine>(a, "SetNextState")
}))
{
val.Emit(OpCodes.Ldsfld, typeof(Nailgun).GetField("nailgunInstances", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
val.Emit(OpCodes.Ldarg, 0);
val.Emit<List<FireNailgun>>(OpCodes.Call, "Remove");
val.Emit(OpCodes.Pop);
return;
}
}
log.error($"Failed IL hook Nailgun\n{val}");
}
private static void On_FireNailgun_OnEnter_Track(Action<FireNailgun> orig, FireNailgun self)
{
orig(self);
nailgunInstances.Add(self);
}
private static void On_FireNailgun_OnExit_ForceBurst(Action<FireNailgun> orig, FireNailgun self)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
orig(self);
if (!nailgunInstances.Contains(self))
{
return;
}
nailgunInstances.Remove(self);
if (Config.nailgunFinalBurst.Value)
{
Util.PlayAttackSpeedSound(NailgunSpinDown.spinDownSound, ((EntityState)self).gameObject, ((BaseState)self).attackSpeedStat);
((EntityState)self).characterBody.SetSpreadBloom(1f, false);
Ray aimRay = ((BaseState)self).GetAimRay();
((BaseNailgunState)self).FireBullet(((BaseState)self).GetAimRay(), NailgunFinalBurst.finalBurstBulletCount, BaseNailgunState.spreadPitchScale, BaseNailgunState.spreadYawScale);
if (!((BaseToolbotPrimarySkillState)self).isInDualWield)
{
((EntityState)self).PlayAnimation("Gesture, Additive", "FireGrenadeLauncher", "FireGrenadeLauncher.playbackRate", 0.45f / ((BaseState)self).attackSpeedStat, 0f);
}
else
{
BaseToolbotPrimarySkillStateMethods.PlayGenericFireAnim<FireNailgun>(self, ((EntityState)self).gameObject, ((EntityState)self).skillLocator, 0.45f / ((BaseState)self).attackSpeedStat);
}
Util.PlaySound(NailgunFinalBurst.burstSound, ((EntityState)self).gameObject);
if (((EntityState)self).isAuthority)
{
float num = NailgunFinalBurst.selfForce * (((EntityState)self).characterMotor.isGrounded ? 0.5f : 1f) * ((EntityState)self).characterMotor.mass;
((EntityState)self).characterMotor.ApplyForce(((Ray)(ref aimRay)).direction * (0f - num), false, false);
}
Util.PlaySound(BaseNailgunState.fireSoundString, ((EntityState)self).gameObject);
Util.PlaySound(BaseNailgunState.fireSoundString, ((EntityState)self).gameObject);
Util.PlaySound(BaseNailgunState.fireSoundString, ((EntityState)self).gameObject);
}
}
}
internal static class VoidFiend
{
internal const string baseDuration = "7.5";
internal static void DoSetup()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
HookManager.Hook(typeof(FireCorruptHandBeam), "FixedUpdate", new Manipulator(IL_FireCorruptHandBeam_FixedUpdate_ExtraAttacks));
HookManager.Hook(typeof(FireCorruptHandBeam), "FireBullet", (Delegate)new Action<Action<FireCorruptHandBeam>, FireCorruptHandBeam>(On_FireCorruptHandBeam_FireBullet_RemoveEffects));
Utilities.GetAddressable<EntityStateConfiguration>("RoR2/DLC1/VoidSurvivor/EntityStates.VoidSurvivor.Weapon.FireCorruptHandBeam.asset", (Action<EntityStateConfiguration>)delegate(EntityStateConfiguration a)
{
a.SetStateConfigIndex("tickRate", "7.5");
});
}
private static void IL_FireCorruptHandBeam_FixedUpdate_ExtraAttacks(ILContext il)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
float num = default(float);
if (val.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0),
(Instruction a) => ILPatternMatchingExt.MatchLdfld(a, typeof(FireCorruptHandBeam), "fireCountdown"),
(Instruction a) => ILPatternMatchingExt.MatchLdcR4(a, ref num)
}))
{
ILLabel val2 = val.MarkLabel();
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchStfld(a, typeof(FireCorruptHandBeam), "fireCountdown")
}))
{
val.Emit(OpCodes.Ldarg_0);
val.Emit<FireCorruptHandBeam>(OpCodes.Ldfld, "fireCountdown");
val.Emit(OpCodes.Add);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(FireCorruptHandBeam), "FireBullet")
}))
{
val.Emit(OpCodes.Br, (object)val2);
return;
}
}
}
log.error($"Failed to find IL for IL_FireCorruptHandBeam_FixedUpdate_ExtraAttacks\n{val}");
}
private static void On_FireCorruptHandBeam_FireBullet_RemoveEffects(Action<FireCorruptHandBeam> orig, FireCorruptHandBeam self)
{
if (self.fireCountdown <= 0f)
{
Main.extraAttacks = 1;
orig(self);
Main.extraAttacks = 0;
}
else
{
orig(self);
}
}
}
}