Skip to content

Commit

Permalink
Fix: Core: folder typo
Browse files Browse the repository at this point in the history
Core: BlacklistSourceType added to keep track of references

Core: GoalFactory: Add default IBlacklist implementation to be a fallback to TARGET based.
  • Loading branch information
Xian55 committed Jan 12, 2025
1 parent 631b1ab commit 5e622bd
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Core/Goals/ApproachTargetGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ApproachTargetGoal(ILogger<ApproachTargetGoal> logger,
ConfigurableInput input, Wait wait,
PlayerReader playerReader, AddonBits addonBits,
StopMoving stopMoving, CombatUtil combatUtil,
[FromKeyedServices("target")] IBlacklist blacklist,
IBlacklist blacklist,
IMountHandler mountHandler)
: base(nameof(ApproachTargetGoal))
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Goals/BlacklistTargetGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Goals/FollowRouteGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Core/Goals/PullTargetGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class PullTargetGoal : GoapGoal, IGoapEventListener
public PullTargetGoal(ILogger<PullTargetGoal> 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Core;

public static class BlacklistSourceType
{
public const string MOUSE_OVER = "mouseOver";
public const string TARGET = "target";
}
2 changes: 1 addition & 1 deletion Core/GoalsComponent/MountHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public MountHandler(ILogger<MountHandler> logger, ConfigurableInput input,
PlayerReader playerReader, ActionBarBits<IUsableAction> usableAction,
ActionBarCooldownReader cooldownReader,
StopMoving stopMoving,
[FromKeyedServices("target")] IBlacklist targetBlacklist)
IBlacklist targetBlacklist)
{
this.logger = logger;
this.classConfig = classConfig;
Expand Down
4 changes: 3 additions & 1 deletion Core/GoalsComponent/NpcNameTargeting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,7 +46,7 @@ public NpcNameTargeting(ILogger<NpcNameTargeting> logger,
NpcNameTargetingLocations locations,
IMouseInput input,
IMouseOverReader mouseOverReader,
[FromKeyedServices("mouseOver")] IBlacklist mouseOverBlacklist,
[FromKeyedServices(MOUSE_OVER)] IBlacklist mouseOverBlacklist,
Wait wait,
IGameMenuWindowShown gmws)
{
Expand Down
14 changes: 9 additions & 5 deletions Core/GoalsFactory/GoalFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using SharedLib;
using Core.Database;

using static Core.BlacklistSourceType;

namespace Core;

public static class GoalFactory
Expand Down Expand Up @@ -40,8 +42,8 @@ public static IServiceProvider Create(
{
services.AddScoped<IBlacklist, NoBlacklist>();

services.AddKeyedScoped<IBlacklist, NoBlacklist>("target");
services.AddKeyedScoped<IBlacklist, NoBlacklist>("mouseOver");
services.AddKeyedScoped<IBlacklist, NoBlacklist>(TARGET);
services.AddKeyedScoped<IBlacklist, NoBlacklist>(MOUSE_OVER);
}
else
{
Expand All @@ -51,8 +53,10 @@ public static IServiceProvider Create(
services.AddScoped<BlacklistMouseOver>();
services.AddScoped<BlacklistTarget>();

services.AddKeyedScoped<IBlacklist, Blacklist<BlacklistMouseOver>>("mouseOver");
services.AddKeyedScoped<IBlacklist, Blacklist<BlacklistTarget>>("target");
services.AddKeyedScoped<IBlacklist, Blacklist<BlacklistMouseOver>>(MOUSE_OVER);
services.AddKeyedScoped<IBlacklist, Blacklist<BlacklistTarget>>(TARGET);

services.AddScoped<IBlacklist>(x => x.GetRequiredKeyedService<IBlacklist>(TARGET));

services.AddScoped<GoapGoal, BlacklistTargetGoal>();
}
Expand Down Expand Up @@ -298,7 +302,7 @@ public static void ResolveFollowRouteGoal(IServiceCollection services,
x.GetRequiredService<Navigation>(),
x.GetRequiredService<IMountHandler>(),
x.GetRequiredService<TargetFinder>(),
x.GetRequiredKeyedService<IBlacklist>("target")
x.GetRequiredService<IBlacklist>()
));
}
}
Expand Down

0 comments on commit 5e622bd

Please sign in to comment.