Files
better-genshin-impact/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs
秋云 22fe431880 feat: add action_params(StopFlyingWaitTime) to stop_flying (#1277)
* feat: add action_params(StopFlyingWaitTime) to stop_flying;
fix: ensure next step only proceeds after stop_flying.

* add StopFlyingHandler

* use int.TryParse

---------

Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
2025-03-14 00:15:17 +08:00

47 lines
1.8 KiB
C#

using System;
using System.Collections.Concurrent;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
public class ActionFactory
{
private static readonly ConcurrentDictionary<string, IActionHandler> _handlers = new();
public static IActionHandler GetAfterHandler(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(),
"hydro_collect" => new ElementalCollectHandler(ElementalType.Hydro),
"electro_collect" => new ElementalCollectHandler(ElementalType.Electro),
"anemo_collect" => new ElementalCollectHandler(ElementalType.Anemo),
"pyro_collect" => new ElementalCollectHandler(ElementalType.Pyro),
"combat_script" => new CombatScriptHandler(),
"mining" => new MiningHandler(),
"fishing" => new FishingHandler(),
_ => throw new ArgumentException("未知的后置 action 类型")
};
});
}
public static IActionHandler GetBeforeHandler(string handlerType)
{
return _handlers.GetOrAdd(handlerType, (key) =>
{
return key switch
{
"up_down_grab_leaf" => new UpDownGrabLeaf(),
"stop_flying" => new StopFlyingHandler(),
_ => throw new ArgumentException("未知的前置 action 类型")
};
});
}
}