Files
better-genshin-impact/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs
2024-10-16 00:54:56 +08:00

26 lines
830 B
C#

using System;
using System.Collections.Concurrent;
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
public class ActionFactory
{
private static readonly ConcurrentDictionary<string, IActionHandler> _handlers = new();
public static IActionHandler GetHandler(string handlerType)
{
return _handlers.GetOrAdd(handlerType, (key) =>
{
return key switch
{
"nahida_collect" => new NahidaCollectHandler(),
"pick_around" => new PickAroundHandler(),
"fight" => new AutoFightHandler(),
"normal_attack" => new NormalAttackHandler(),
"elemental_skill" => new ElementalSkillHandler(),
_ => throw new ArgumentException("未知的 action 类型")
};
});
}
}