Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterShurikenHoming v1.0.1
BetterShurikenHoming.dll
Decompiled 2 years agousing System; 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.Configuration; using BepInEx.Logging; using IL.RoR2.Projectile; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Projectile; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("BetterShurikenHoming")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ec50488b3db4eb8e5f6859460109803c6bec2ac0")] [assembly: AssemblyProduct("BetterShurikenHoming")] [assembly: AssemblyTitle("BetterShurikenHoming")] [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 BetterShurikenHoming { [BepInPlugin("SSM24.BetterShurikenHoming", "BetterShurikenHoming", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BetterShurikenHoming : BaseUnityPlugin { public const string PluginGUID = "SSM24.BetterShurikenHoming"; public const string PluginAuthor = "SSM24"; public const string PluginName = "BetterShurikenHoming"; public const string PluginVersion = "1.0.0"; public static ConfigEntry<bool> IgnoreEnemyDistance; public static ConfigEntry<float> MaxAngle; public static ConfigEntry<float> MaxDistance; private const float default_MaxAngle = 4f; private const float default_MaxDistance = 150f; public void Awake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0087: 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) //IL_0097: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) //IL_0143: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) Log.Init(((BaseUnityPlugin)this).Logger); IgnoreEnemyDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "Always Prioritize Aim", true, "Always target enemy nearest to the crosshair, instead of sometimes prioritizing enemies closer to the player.\n\nVanilla default is false"); MaxAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Config", "Max Angle", 4f, "The width of the targeting cone in degrees. Higher values tend to make shurikens chase enemies they can't hit.\n\nVanilla default is 90"); MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Config", "Max Distance", 150f, "The maximum distance a shuriken can detect enemies, in meters.\n\nVanilla default is 100"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(IgnoreEnemyDistance)); ModSettingsManager.AddOption((BaseOption)new SliderOption(MaxAngle, new SliderConfig { min = 0f, max = 180f, formatString = "{0:F1}°", description = ((ConfigEntryBase)MaxAngle).Description.Description + $"\nRecommended value is {4f}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(MaxDistance, new SliderConfig { min = 0f, max = 500f, formatString = "{0:F0}m", description = ((ConfigEntryBase)MaxDistance).Description.Description + $"\nRecommended value is {150f}" })); try { using Stream stream = File.OpenRead(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "icon.png")); Texture2D val = new Texture2D(0, 0); byte[] array = new byte[stream.Length]; stream.Read(array, 0, (int)stream.Length); if (ImageConversion.LoadImage(val, array)) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f))); } } catch (FileNotFoundException) { } ProjectileDirectionalTargetFinder.SearchForTarget += new Manipulator(IL_ProjectileDirectionalTargetFinder_SearchForTarget); } private void IL_ProjectileDirectionalTargetFinder_SearchForTarget(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction instr) => ILPatternMatchingExt.MatchCallvirt<BullseyeSearch>(instr, "set_maxAngleFilter") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<ProjectileDirectionalTargetFinder>>((Action<ProjectileDirectionalTargetFinder>)ModifyBullseyeSearch); } else { Log.Error("could not hook ProjectileDirectionalTargetFinder.SearchForTarget"); } } private static void ModifyBullseyeSearch(ProjectileDirectionalTargetFinder self) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)self).gameObject).name.Contains("ShurikenProjectile")) { if (IgnoreEnemyDistance.Value) { self.bullseyeSearch.sortMode = (SortMode)2; } self.bullseyeSearch.maxAngleFilter = MaxAngle.Value; self.bullseyeSearch.maxDistanceFilter = MaxDistance.Value; } } } 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); } } }