mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-26 09:39:49 +08:00
- 移除了不必要的 `using` 语句,添加了新的 `using` 语句。 - 将 `Waypoints` 属性重命名为 `Positions`。 - 更新了 `BuildFromFilePath` 方法中的 `JsonOptions` 引用。 - 将 `Waypoint` 类移到单独的文件中,并添加了相关属性和注释。 - 添加了 `SaveToFile` 方法,用于将 `PathingTask` 对象保存到文件。 - 更新了 `PathExecutor` 中的 `TaskControl` 引用,简化了代码。 - 更新了 `PathRecorder` 的属性和方法,使用私有字段 `_pathingTask`。 - 更新了 `MapPathingPage.xaml` 的命令绑定。 - 更新了 `HotKeyPageViewModel` 和 `MapPathingViewModel` 的逻辑。 - 添加了新的 `PathingTaskConfig` 类,用于配置路径任务。
27 lines
791 B
C#
27 lines
791 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
|
|
namespace BetterGenshinImpact.GameTask.AutoPathing.Model;
|
|
|
|
[Serializable]
|
|
public class PathingTask
|
|
{
|
|
public PathingTaskInfo Info { get; set; } = new();
|
|
public List<Waypoint> Positions { get; set; } = [];
|
|
|
|
public static PathingTask BuildFromFilePath(string filePath)
|
|
{
|
|
var json = File.ReadAllText(filePath);
|
|
return JsonSerializer.Deserialize<PathingTask>(json, PathRecorder.JsonOptions) ?? throw new Exception("Failed to deserialize PathingTask");
|
|
}
|
|
|
|
public void SaveToFile(string filePath)
|
|
{
|
|
var json = JsonSerializer.Serialize(this, PathRecorder.JsonOptions);
|
|
File.WriteAllText(filePath, json, Encoding.UTF8);
|
|
}
|
|
}
|