mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
在 `DefaultAutoFightConfig.cs` 中,将 `JsonSerializer.Deserialize` 替换为 `Newtonsoft.Json.JsonConvert.DeserializeObject` 来反序列化 `combat_avatar.json` 文件。 在 `ActionFactory.cs` 中,添加了 `BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model` 的引用,并在 `ActionFactory` 类中添加了新的元素采集处理器(`hydro_collect`、`electro_collect`、`anemo_collect`)。 在 `HotKeyPageViewModel.cs` 中,添加了 `BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model` 的引用,并修改了 `Test1Hotkey` 的处理逻辑,使用 `ElementalCollectHandler` 进行元素采集。 新增了 `ElementalCollectHandler.cs` 文件,定义了 `ElementalCollectHandler` 类,用于处理元素采集逻辑。该类根据元素类型筛选角色,并执行相应的攻击或技能操作。同时定义了 `ElementalCollectAvatar` 和 `ElementalCollectAvatarConfigs` 类,用于配置和管理不同元素类型的角色。
42 lines
1.5 KiB
C#
42 lines
1.5 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),
|
|
_ => throw new ArgumentException("未知的后置 action 类型")
|
|
};
|
|
});
|
|
}
|
|
|
|
public static IActionHandler GetBeforeHandler(string handlerType)
|
|
{
|
|
return _handlers.GetOrAdd(handlerType, (key) =>
|
|
{
|
|
return key switch
|
|
{
|
|
"up_down_grab_leaf" => new UpDownGrabLeaf(),
|
|
_ => throw new ArgumentException("未知的前置 action 类型")
|
|
};
|
|
});
|
|
}
|
|
}
|