From 83c265d8e0a505669fb8dcaf35867592d64ec8ec Mon Sep 17 00:00:00 2001 From: Helloworld <1326521+LYZhelloworld@users.noreply.github.com> Date: Sun, 31 Jul 2022 16:13:26 +0800 Subject: [PATCH] docs: AsstProxy --- src/MeoAsstGui/Helper/AsstProxy.cs | 248 +++++++++++++++++++++++++++-- 1 file changed, 234 insertions(+), 14 deletions(-) diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 72667bec30..9e1667d6f1 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -30,6 +30,9 @@ namespace MeoAsstGui #pragma warning restore SA1135 // Using directives should be qualified #pragma warning disable SA1121 // Use built-in type alias + /// + /// MeoAssistant 代理类。 + /// public class AsstProxy { private delegate void CallbackDelegate(int msg, IntPtr json_buffer, IntPtr custom_arg); @@ -86,6 +89,10 @@ namespace MeoAsstGui [DllImport("MeoAssistant.dll")] private static extern void AsstLog(byte[] level, byte[] message); + /// + /// 记录日志。 + /// + /// 日志内容。 public static void AsstLog(string message) { AsstLog(Encoding.UTF8.GetBytes("GUI"), Encoding.UTF8.GetBytes(message)); @@ -93,6 +100,11 @@ namespace MeoAsstGui private readonly CallbackDelegate _callback; + /// + /// Initializes a new instance of the class. + /// + /// IoC 容器。 + /// 当前窗口。 public AsstProxy(IContainer container, IWindowManager windowManager) { _container = container; @@ -100,6 +112,9 @@ namespace MeoAsstGui _callback = CallbackFunction; } + /// + /// Finalizes an instance of the class. + /// ~AsstProxy() { if (_handle != IntPtr.Zero) @@ -110,6 +125,10 @@ namespace MeoAsstGui private string _curResource = "_Unloaded"; + /// + /// 加载全局资源。 + /// + /// 是否成功。 public bool LoadGlobalResource() { var settingsModel = _container.Get(); @@ -159,6 +178,9 @@ namespace MeoAsstGui return loaded; } + /// + /// 初始化。 + /// public void Init() { bool loaded = LoadGlobalResource(); @@ -191,10 +213,16 @@ namespace MeoAsstGui }); } + /// + /// Determines the length of the specified string (not including the terminating null character). + /// + /// The null-terminated string to be checked. + /// + /// The function returns the length of the string, in characters. + /// If is , the function returns 0. + /// [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)] -#pragma warning disable SA1300 // Element should begin with upper-case letter internal static extern int lstrlenA(IntPtr ptr); -#pragma warning restore SA1300 // Element should begin with upper-case letter private static string PtrToStringCustom(IntPtr ptr, Encoding enc) { @@ -856,6 +884,12 @@ namespace MeoAsstGui } } + /// + /// 连接模拟器。 + /// + /// 具体的连接错误。 + /// 是否为第一次尝试。 + /// 是否成功。 public bool AsstConnect(ref string error, bool firsttry = false) { if (!LoadGlobalResource()) @@ -969,6 +1003,16 @@ namespace MeoAsstGui return task_params; } + /// + /// 刷理智。 + /// + /// 关卡名。 + /// 最大使用理智药数量。 + /// 最大吃石头数量。 + /// 指定次数。 + /// 指定掉落 ID。 + /// 指定掉落数量。 + /// 是否成功。 public bool AsstAppendFight(string stage, int max_medicine, int max_stone, int max_times, string drops_item_id, int drops_item_quantity) { var task_params = SerializeFightTaskParams(stage, max_medicine, max_stone, max_times, drops_item_id, drops_item_quantity); @@ -977,12 +1021,26 @@ namespace MeoAsstGui return id != 0; } + /// + /// 设置刷理智任务参数。 + /// + /// 关卡名。 + /// 最大使用理智药数量。 + /// 最大吃石头数量。 + /// 指定次数。 + /// 指定掉落 ID。 + /// 指定掉落数量。 + /// 是否成功。 public bool AsstSetFightTaskParams(string stage, int max_medicine, int max_stone, int max_times, string drops_item_id, int drops_item_quantity) { var task_params = SerializeFightTaskParams(stage, max_medicine, max_stone, max_times, drops_item_id, drops_item_quantity); return AsstSetTaskParamsWithEncoding(_latestTaskId.TryGetValue(TaskType.Fight, out var task_id) ? task_id : 0, task_params); } + /// + /// 领取日常奖励。 + /// + /// 是否成功。 public bool AsstAppendAward() { TaskId id = AsstAppendTaskWithEncoding("Award"); @@ -990,6 +1048,12 @@ namespace MeoAsstGui return id != 0; } + /// + /// 开始唤醒。 + /// + /// 客户端版本。 + /// 是否自动启动客户端。 + /// 是否成功。 public bool AsstAppendStartUp(string client_type, bool enable) { var task_params = new JObject(); @@ -1000,6 +1064,10 @@ namespace MeoAsstGui return id != 0; } + /// + /// CloseDown 任务。 + /// + /// 是否成功。 public bool AsstStartCloseDown() { AsstStop(); @@ -1008,6 +1076,10 @@ namespace MeoAsstGui return id != 0 && AsstStart(); } + /// + /// 访问好友。 + /// + /// 是否成功。 public bool AsstAppendVisit() { TaskId id = AsstAppendTaskWithEncoding("Visit"); @@ -1015,6 +1087,13 @@ namespace MeoAsstGui return id != 0; } + /// + /// 领取信用及商店购物。 + /// + /// 是否购物。 + /// 优先购买列表。 + /// 黑名单列表。 + /// 是否成功。 public bool AsstAppendMall(bool with_shopping, string[] firstlist, string[] blacklist) { var task_params = new JObject(); @@ -1026,6 +1105,18 @@ namespace MeoAsstGui return id != 0; } + /// + /// 公开招募。 + /// + /// 加急次数,仅在 时有效。 + /// 会去点击标签的 Tag 等级。 + /// 不使用。 + /// 会去点击确认的 Tag 等级。若仅公招计算,可设置为空数组。 + /// 不使用。 + /// 是否刷新三星 Tags。 + /// 是否使用加急许可。 + /// 是否在识别到小车词条时跳过。 + /// 是否成功。 public bool AsstAppendRecruit(int max_times, int[] select_level, int required_len, int[] confirm_level, int confirm_len, bool need_refresh, bool use_expedited, bool skip_robot) { var task_params = new JObject(); @@ -1042,6 +1133,26 @@ namespace MeoAsstGui return id != 0; } + /// + /// 基建换班。 + /// + /// 不使用。 + /// 要换班的设施(有序)。 + /// 不使用。 + /// + /// 无人机用途。可用值包括: + /// + /// _NotUse + /// Money + /// SyntheticJade + /// CombatRecord + /// PureGold + /// OriginStone + /// Chip + /// + /// + /// 宿舍进驻心情阈值。 + /// 是否成功。 public bool AsstAppendInfrast(int work_mode, string[] order, int order_len, string uses_of_drones, double dorm_threshold) { var task_params = new JObject(); @@ -1056,6 +1167,37 @@ namespace MeoAsstGui return id != 0; } + /// + /// 无限刷肉鸽。 + /// + /// + /// 模式。可用值包括: + /// + /// + /// 0 + /// 刷蜡烛,尽可能稳定的打更多层数。 + /// + /// + /// 1 + /// 刷源石锭,第一层投资完就退出。 + /// + /// + /// 2 + /// 【即将弃用】两者兼顾,投资过后再退出,没有投资就继续往后打。 + /// + /// + /// 3 + /// 【开发中】尝试通关,尽可能打的远。 + /// + /// + /// + /// 开始探索次数。 + /// 投资源石锭次数。 + /// 投资满了自动停止任务。 + /// TODO. + /// TODO. + /// TODO. + /// 是否成功。 public bool AsstAppendRoguelike(int mode, int starts, int invests, bool stop_when_full, string squad, string roles, string core_char) { @@ -1084,6 +1226,13 @@ namespace MeoAsstGui return id != 0; } + /// + /// 公招识别。 + /// + /// 会去点击标签的 Tag 等级。 + /// 不使用。 + /// 是否设置 9 小时。 + /// 是否成功。 public bool AsstStartRecruitCalc(int[] select_level, int required_len, bool set_time) { var task_params = new JObject(); @@ -1099,6 +1248,13 @@ namespace MeoAsstGui return id != 0 && AsstStart(); } + /// + /// 自动抄作业。 + /// + /// 关卡名,需要与作业 JSON 中的 stage_name 字段相同。 + /// 作业 JSON 的文件路径,绝对、相对路径均可。 + /// 是否进行 “快捷编队”。 + /// 是否成功。 public bool AsstStartCopilot(string stage_name, string filename, bool formation) { var task_params = new JObject(); @@ -1110,11 +1266,19 @@ namespace MeoAsstGui return id != 0 && AsstStart(); } + /// + /// 启动。 + /// + /// 是否成功。 public bool AsstStart() { return AsstStart(_handle); } + /// + /// 停止。 + /// + /// 是否成功。 public bool AsstStop() { bool ret = AsstStop(_handle); @@ -1122,29 +1286,85 @@ namespace MeoAsstGui return ret; } + /// + /// 销毁。 + /// public void AsstDestroy() { AsstDestroy(_handle); } } + /// + /// MeoAssistant 消息。 + /// public enum AsstMsg { /* Global Info */ - InternalError = 0, // 内部错误 - InitFailed, // 初始化失败 - ConnectionInfo, // 连接相关错误 - AllTasksCompleted, // 全部任务完成 + + /// + /// 内部错误。 + /// + InternalError = 0, + + /// + /// 初始化失败。 + /// + InitFailed, + + /// + /// 连接相关错误。 + /// + ConnectionInfo, + + /// + /// 全部任务完成。 + /// + AllTasksCompleted, + /* TaskChain Info */ - TaskChainError = 10000, // 任务链执行/识别错误 - TaskChainStart, // 任务链开始 - TaskChainCompleted, // 任务链完成 - TaskChainExtraInfo, // 任务链额外信息 + + /// + /// 任务链执行/识别错误。 + /// + TaskChainError = 10000, + + /// + /// 任务链开始。 + /// + TaskChainStart, + + /// + /// 任务链完成。 + /// + TaskChainCompleted, + + /// + /// 任务链额外信息。 + /// + TaskChainExtraInfo, + /* SubTask Info */ - SubTaskError = 20000, // 原子任务执行/识别错误 - SubTaskStart, // 原子任务开始 - SubTaskCompleted, // 原子任务完成 - SubTaskExtraInfo, // 原子任务额外信息 + + /// + /// 原子任务执行/识别错误。 + /// + SubTaskError = 20000, + + /// + /// 原子任务开始。 + /// + SubTaskStart, + + /// + /// 原子任务完成。 + /// + SubTaskCompleted, + + /// + /// 原子任务额外信息。 + /// + SubTaskExtraInfo, } } #pragma warning restore SA1121 // Use built-in type alias