diff --git a/Core/Goals/ApproachTargetGoal.cs b/Core/Goals/ApproachTargetGoal.cs index 18c44a52..304cb92f 100644 --- a/Core/Goals/ApproachTargetGoal.cs +++ b/Core/Goals/ApproachTargetGoal.cs @@ -45,7 +45,7 @@ public ApproachTargetGoal(ILogger logger, ConfigurableInput input, Wait wait, PlayerReader playerReader, AddonBits addonBits, StopMoving stopMoving, CombatUtil combatUtil, - [FromKeyedServices("target")] IBlacklist blacklist, + IBlacklist blacklist, IMountHandler mountHandler) : base(nameof(ApproachTargetGoal)) { diff --git a/Core/Goals/BlacklistTargetGoal.cs b/Core/Goals/BlacklistTargetGoal.cs index 4d4a4b46..b948c019 100644 --- a/Core/Goals/BlacklistTargetGoal.cs +++ b/Core/Goals/BlacklistTargetGoal.cs @@ -15,7 +15,7 @@ public sealed class BlacklistTargetGoal : GoapGoal public BlacklistTargetGoal(PlayerReader playerReader, AddonBits bits, ConfigurableInput input, - [FromKeyedServices("target")] IBlacklist blacklist, + IBlacklist blacklist, Wait wait) : base(nameof(BlacklistTargetGoal)) { diff --git a/Core/Goals/FollowRouteGoal.cs b/Core/Goals/FollowRouteGoal.cs index 95fed2e9..5df3322b 100644 --- a/Core/Goals/FollowRouteGoal.cs +++ b/Core/Goals/FollowRouteGoal.cs @@ -86,7 +86,7 @@ public FollowRouteGoal( ClassConfiguration classConfig, Navigation navigation, IMountHandler mountHandler, TargetFinder targetFinder, - [FromKeyedServices("target")] IBlacklist targetBlacklist) + IBlacklist targetBlacklist) : base("Follow " + System.IO.Path.GetFileNameWithoutExtension(pathSettings.FileName)) { this.cost = cost; diff --git a/Core/Goals/PullTargetGoal.cs b/Core/Goals/PullTargetGoal.cs index 2ba23146..7142e985 100644 --- a/Core/Goals/PullTargetGoal.cs +++ b/Core/Goals/PullTargetGoal.cs @@ -42,7 +42,7 @@ public sealed class PullTargetGoal : GoapGoal, IGoapEventListener public PullTargetGoal(ILogger logger, ConfigurableInput input, Wait wait, CombatLog combatlog, PlayerReader playerReader, AddonBits bits, - [FromKeyedServices("target")] IBlacklist targetBlacklist, + IBlacklist targetBlacklist, StopMoving stopMoving, CastingHandler castingHandler, IMountHandler mountHandler, NpcNameTargeting npcNameTargeting, StuckDetector stuckDetector, CombatUtil combatUtil, diff --git a/Core/GoalsComponent/Blacklist/BlaclistSource/BlacklistMouseOver.cs b/Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistMouseOver.cs similarity index 100% rename from Core/GoalsComponent/Blacklist/BlaclistSource/BlacklistMouseOver.cs rename to Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistMouseOver.cs diff --git a/Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistSourceType.cs b/Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistSourceType.cs new file mode 100644 index 00000000..0ea006aa --- /dev/null +++ b/Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistSourceType.cs @@ -0,0 +1,7 @@ +namespace Core; + +public static class BlacklistSourceType +{ + public const string MOUSE_OVER = "mouseOver"; + public const string TARGET = "target"; +} \ No newline at end of file diff --git a/Core/GoalsComponent/Blacklist/BlaclistSource/BlacklistTarget.cs b/Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistTarget.cs similarity index 100% rename from Core/GoalsComponent/Blacklist/BlaclistSource/BlacklistTarget.cs rename to Core/GoalsComponent/Blacklist/BlacklistSource/BlacklistTarget.cs diff --git a/Core/GoalsComponent/Blacklist/BlaclistSource/IBlacklistSource.cs b/Core/GoalsComponent/Blacklist/BlacklistSource/IBlacklistSource.cs similarity index 100% rename from Core/GoalsComponent/Blacklist/BlaclistSource/IBlacklistSource.cs rename to Core/GoalsComponent/Blacklist/BlacklistSource/IBlacklistSource.cs diff --git a/Core/GoalsComponent/MountHandler.cs b/Core/GoalsComponent/MountHandler.cs index 2836bdd2..30404b84 100644 --- a/Core/GoalsComponent/MountHandler.cs +++ b/Core/GoalsComponent/MountHandler.cs @@ -31,7 +31,7 @@ public MountHandler(ILogger logger, ConfigurableInput input, PlayerReader playerReader, ActionBarBits usableAction, ActionBarCooldownReader cooldownReader, StopMoving stopMoving, - [FromKeyedServices("target")] IBlacklist targetBlacklist) + IBlacklist targetBlacklist) { this.logger = logger; this.classConfig = classConfig; diff --git a/Core/GoalsComponent/NpcNameTargeting.cs b/Core/GoalsComponent/NpcNameTargeting.cs index 49615789..488c7ab7 100644 --- a/Core/GoalsComponent/NpcNameTargeting.cs +++ b/Core/GoalsComponent/NpcNameTargeting.cs @@ -9,6 +9,8 @@ using System.Runtime.CompilerServices; using Microsoft.Extensions.DependencyInjection; +using static Core.BlacklistSourceType; + namespace Core.Goals; public sealed partial class NpcNameTargeting : IDisposable @@ -44,7 +46,7 @@ public NpcNameTargeting(ILogger logger, NpcNameTargetingLocations locations, IMouseInput input, IMouseOverReader mouseOverReader, - [FromKeyedServices("mouseOver")] IBlacklist mouseOverBlacklist, + [FromKeyedServices(MOUSE_OVER)] IBlacklist mouseOverBlacklist, Wait wait, IGameMenuWindowShown gmws) { diff --git a/Core/GoalsFactory/GoalFactory.cs b/Core/GoalsFactory/GoalFactory.cs index 32911363..2af92da0 100644 --- a/Core/GoalsFactory/GoalFactory.cs +++ b/Core/GoalsFactory/GoalFactory.cs @@ -12,6 +12,8 @@ using SharedLib; using Core.Database; +using static Core.BlacklistSourceType; + namespace Core; public static class GoalFactory @@ -40,8 +42,8 @@ public static IServiceProvider Create( { services.AddScoped(); - services.AddKeyedScoped("target"); - services.AddKeyedScoped("mouseOver"); + services.AddKeyedScoped(TARGET); + services.AddKeyedScoped(MOUSE_OVER); } else { @@ -51,8 +53,10 @@ public static IServiceProvider Create( services.AddScoped(); services.AddScoped(); - services.AddKeyedScoped>("mouseOver"); - services.AddKeyedScoped>("target"); + services.AddKeyedScoped>(MOUSE_OVER); + services.AddKeyedScoped>(TARGET); + + services.AddScoped(x => x.GetRequiredKeyedService(TARGET)); services.AddScoped(); } @@ -298,7 +302,7 @@ public static void ResolveFollowRouteGoal(IServiceCollection services, x.GetRequiredService(), x.GetRequiredService(), x.GetRequiredService(), - x.GetRequiredKeyedService("target") + x.GetRequiredService() )); } }