Files
better-genshin-impact/BetterGenshinImpact/Service/GearTask/GearTaskServiceExtensions.cs
辉鸭蛋 7f7a34e9ba feat(gear-task): 引入事件驱动的任务执行与历史记录系统
- 新增 IGearTaskEventBus 接口及默认实现,用于解耦执行器与记录器、UI 投影等消费者
- 新增 IGearTaskResumable 接口,支持任务节点内部恢复(如 Pathing 任务可恢复至特定路径点)
- 重构任务执行流程,使用 GearTaskExecutionRunner 替代旧的 GearTaskExecutionManager
- 实现基于磁盘 JSON 的历史记录存储(IGearTaskHistoryStore),支持执行记录的保存、加载与清理
- 为 PathingGearTask 添加恢复能力,通过 PathingGearTaskResumeState 记录断点状态
- 在 PathExecutor 中集成运行时事件通知,支持路径点进入、完成、传送等事件的发布
- 统一执行事件模型(GearTaskExecutionEvent),包含任务定义、节点路径、时间戳等元数据
- 服务注册更新,使用新的执行器、事件总线、历史记录器等组件
2026-05-11 01:57:29 +08:00

30 lines
983 B
C#

using BetterGenshinImpact.Service.GearTask.Execution;
using Microsoft.Extensions.DependencyInjection;
namespace BetterGenshinImpact.Service.GearTask;
/// <summary>
/// 齿轮任务服务注册扩展方法
/// </summary>
public static class GearTaskServiceExtensions
{
/// <summary>
/// 注册齿轮任务相关服务
/// </summary>
public static IServiceCollection AddGearTaskServices(this IServiceCollection services)
{
services.AddSingleton<GearTaskStorageService>();
services.AddSingleton<GearTaskFactory>();
services.AddSingleton<GearTaskConverter>();
services.AddSingleton<IGearTaskEventBus, GearTaskEventBus>();
services.AddSingleton<IGearTaskHistoryStore, GearTaskHistoryStore>();
services.AddHostedService<GearTaskHistoryRecorder>();
services.AddSingleton<IGearTaskExecutionRunner, GearTaskExecutionRunner>();
services.AddSingleton<GearTaskExecutor>();
return services;
}
}