using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 HG.Reflection; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2BepInExPack.GameAssetPathsBetter; using RobItems.Content; using UnityEngine; using UnityEngine.AddressableAssets; [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("ScarfTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+be65bd4e7c4b09433780c78fdd7e9af6c1afd351")] [assembly: AssemblyProduct("ScarfTweaks")] [assembly: AssemblyTitle("ScarfTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 ScarfTweaks { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("kina.ScarfTweaks", "ScarfTweaks", "1.0.0")] public class ChipTier : BaseUnityPlugin { private enum tier { common, uncommon, legendary, lunar } [HarmonyPatch] public class ChipChanges { private static ConfigEntry cooldown = Utils.SliderConfig(0f, 400f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar cooldown", 30f, "")); [HarmonyPatch(typeof(FriendHandler), "HandleSize")] [HarmonyPostfix] public static void HandleSizePostFix(FriendHandler __instance) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Transform modelTransform = __instance.characterBody.modelLocator.modelTransform; modelTransform.localScale *= Utils.SliderConfig(0f, 10f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip size multiplier", 2f, "")).Value; } [HarmonyPatch(typeof(FriendHandler), "Roar")] [HarmonyILManipulator] public static void RoarIL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.SearchTarget = (SearchTarget)2; try { if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 300f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "radius") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldc_R4, Utils.SliderConfig(0f, 800f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar far attack radius", 400f, "base 300")).Value); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("radius")); } if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "procCoefficient") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldc_R4, Utils.SliderConfig(0f, 10f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar far attack proc", 1f, "base 0")).Value); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("procCoefficient")); } if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "baseDamage") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)((FriendHandler friend) => friend.characterBody.damage * Utils.SliderConfig(0f, 40f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar far attack damage", 15f, "")).Value)); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("baseDamage")); } val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchPop(x) }); if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 50f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "radius") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldc_R4, Utils.SliderConfig(0f, 400f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar close attack radius", 100f, "base 50")).Value); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("radius")); } if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "procCoefficient") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldc_R4, Utils.SliderConfig(0f, 10f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar close attack proc", 1f, "base 0")).Value); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("procCoefficient")); } if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "baseDamage") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)((FriendHandler friend) => friend.characterBody.damage * Utils.SliderConfig(0f, 40f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar damage from close attack", 30f, "")).Value)); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("baseDamage")); } if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 2000f), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "baseForce") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldc_R4, Utils.SliderConfig(0f, 8000f, ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "chip roar close attack force", 4000f, "base 2000")).Value); val.Emit(OpCodes.Stfld, typeof(BlastAttack).GetField("baseForce")); } } catch (Exception data) { Log.Error("error while il patching roar !!!"); Log.Error(data); } } [HarmonyPatch(typeof(FriendHandler), "FixedUpdate")] [HarmonyPostfix] public static void FixedUpdatePostfix(FriendHandler __instance) { if (__instance.roarStopwatch > cooldown.Value) { __instance.roarStopwatch = cooldown.Value; } } } private const string PluginGUID = "kina.ScarfTweaks"; private const string PluginAuthor = "kina"; private const string PluginName = "ScarfTweaks"; private const string PluginVersion = "1.0.0"; private static ChipTier instance; private static AssetBundle assetbundle; private static bool UHRInstalled => Chainloader.PluginInfos.ContainsKey("iDeathHD.UnityHotReload"); public void Awake() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) Log.Init(((BaseUnityPlugin)this).Logger); instance = this; assetbundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "chipbundle")); new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).CreateClassProcessor(typeof(ChipChanges)).Patch(); ((ResourceAvailability)(ref ItemCatalog.availability)).onAvailable += UpgradeChip; } private void UpgradeChip() { //IL_00bd: 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) ConfigEntry val = ((BaseUnityPlugin)instance).Config.Bind("ScarfTweaks", "scarf tier", tier.legendary, ""); string text = val.Value switch { tier.common => RoR2_Base_Common.Tier1Def_asset, tier.uncommon => RoR2_Base_Common.Tier2Def_asset, tier.legendary => RoR2_Base_Common.Tier3Def_asset, tier.lunar => RoR2_Base_Common.LunarTierDef_asset, _ => "", }; string text2 = val.Value switch { tier.common => "tier1", tier.uncommon => "tier2", tier.legendary => "tier3", tier.lunar => "lunar", _ => "", }; ((ItemBase)ItemBase.instance).ItemDef._itemTierDef = Addressables.LoadAssetAsync((object)text).WaitForCompletion(); ((ItemBase)ItemBase.instance).ItemDef.pickupIconSprite = assetbundle.LoadAsset(text2); } private void Update() { } } public static class Utils { private static List addedConfigs = new List(); public static ConfigEntry SliderConfig(float min, float max, ConfigEntry config) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown if (addedConfigs.Contains(((ConfigEntryBase)config).Definition.Key)) { return config; } addedConfigs.Add(((ConfigEntryBase)config).Definition.Key); StepSliderConfig val = new StepSliderConfig { max = max, min = min, FormatString = "{0:0}" }; ModSettingsManager.AddOption((BaseOption)new StepSliderOption(config, val)); return config; } public static ConfigEntry SliderConfig(ConfigEntry config) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (addedConfigs.Contains(((ConfigEntryBase)config).Definition.Key)) { return config; } addedConfigs.Add(((ConfigEntryBase)config).Definition.Key); StepSliderConfig val = new StepSliderConfig { max = (float)((ConfigEntryBase)config).DefaultValue * 2f, min = 0f, FormatString = "{0:0}" }; ModSettingsManager.AddOption((BaseOption)new StepSliderOption(config, val)); return config; } public static void SliderConfig(int min, int max, ConfigEntry config) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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 IntSliderConfig val = new IntSliderConfig { max = max, min = min, formatString = "{0:0}" }; ModSettingsManager.AddOption((BaseOption)new IntSliderOption(config, val)); } public static void CheckboxConfig(ConfigEntry config, bool restartRequired = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown CheckBoxConfig val = new CheckBoxConfig(); ((BaseOptionConfig)val).restartRequired = restartRequired; ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(config, val)); } public static void StringConfig(ConfigEntry config) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown InputFieldConfig val = new InputFieldConfig(); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(config, val)); } public static void KeyboardConfig(ConfigEntry config) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown KeyBindConfig val = new KeyBindConfig(); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(config, val)); } } }