Skip to content

Commit 6e8331b

Browse files
committed
feat: support optional arguments
f27386e 9c5bc0e
1 parent d9bdeda commit 6e8331b

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/MaaFramework.Binding.Native/MaaAgentClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ public static MaaAgentClient Create(string identifier, MaaTasker maa)
106106
return client;
107107
}
108108

109+
/// <inheritdoc cref="CreateTcp(ushort, MaaResource)"/>
110+
public static MaaAgentClient CreateTcp(MaaResource resource)
111+
=> CreateTcp(0, resource);
112+
113+
/// <inheritdoc cref="CreateTcp(ushort, MaaTasker)"/>
114+
public static MaaAgentClient CreateTcp(MaaTasker maa)
115+
=> CreateTcp(0, maa);
116+
109117
/// <summary>
110118
/// Creates a <see cref="MaaAgentClient"/> instance with TCP connection.
111119
/// <para>The callback (from resource) will be forwarded to the agent server.</para>

src/MaaFramework.Binding.Native/MaaContext.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,26 +159,23 @@ public MaaContext(MaaContextHandle contextHandle, MaaTasker tasker)
159159
}
160160

161161
/// <inheritdoc/>
162-
public bool WaitFreezes(TimeSpan time, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
163-
=> WaitFreezes((MaaSize)time.TotalMilliseconds, (MaaRectBuffer)recognitionBox, waitFreezesParam);
162+
public bool WaitFreezes(TimeSpan time = default, IMaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}")
163+
=> WaitFreezes((MaaSize)time.TotalMilliseconds, (MaaRectBuffer?)recognitionBox, waitFreezesParam);
164164

165165
/// <inheritdoc cref="IMaaContext.WaitFreezes(TimeSpan, IMaaRectBuffer, string)"/>
166-
public bool WaitFreezes(TimeSpan time, MaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
166+
public bool WaitFreezes(TimeSpan time = default, MaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}")
167167
=> WaitFreezes((MaaSize)time.TotalMilliseconds, recognitionBox, waitFreezesParam);
168168

169169
/// <inheritdoc/>
170-
public bool WaitFreezes(MaaSize millisecondsTime, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
171-
=> WaitFreezes(millisecondsTime, (MaaRectBuffer)recognitionBox, waitFreezesParam);
170+
public bool WaitFreezes(MaaSize millisecondsTime = 0, IMaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}")
171+
=> WaitFreezes(millisecondsTime, (MaaRectBuffer?)recognitionBox, waitFreezesParam);
172172

173173
/// <inheritdoc cref="IMaaContext.WaitFreezes(MaaSize, IMaaRectBuffer, string)"/>
174174
/// <remarks>
175175
/// Wrapper of <see cref="MaaContextWaitFreezes"/>.
176176
/// </remarks>
177-
public bool WaitFreezes(MaaSize millisecondsTime, MaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}")
178-
{
179-
ArgumentNullException.ThrowIfNull(recognitionBox);
180-
return MaaContextWaitFreezes(Handle, millisecondsTime, recognitionBox.Handle, waitFreezesParam);
181-
}
177+
public bool WaitFreezes(MaaSize millisecondsTime = 0, MaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}")
178+
=> MaaContextWaitFreezes(Handle, millisecondsTime, recognitionBox?.Handle ?? MaaRectHandle.Zero, waitFreezesParam);
182179

183180
/// <inheritdoc/>
184181
/// <remarks>

src/MaaFramework.Binding/IMaaContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public interface IMaaContext : ICloneable
8787
/// <paramref name="millisecondsTime"/> and <paramref name="waitFreezesParam"/>.time are mutually exclusive.
8888
/// </remarks>
8989
/// <exception cref="ArgumentNullException"/>
90-
bool WaitFreezes(MaaSize millisecondsTime, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}");
90+
bool WaitFreezes(MaaSize millisecondsTime = 0, IMaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}");
9191

9292
/// <param name="time">The wait time.</param>
9393
/// <param name="recognitionBox">The recognition hit box, used when target is Self to calculate ROI.</param>
@@ -97,7 +97,7 @@ public interface IMaaContext : ICloneable
9797
/// </remarks>
9898
/// <inheritdoc cref="WaitFreezes(ulong, IMaaRectBuffer, string)"/>
9999
/// <exception cref="ArgumentNullException"/>
100-
bool WaitFreezes(TimeSpan time, IMaaRectBuffer recognitionBox, [StringSyntax("Json")] string waitFreezesParam = "{}");
100+
bool WaitFreezes(TimeSpan time = default, IMaaRectBuffer? recognitionBox = default, [StringSyntax("Json")] string waitFreezesParam = "{}");
101101

102102
/// <summary>
103103
/// Overrides a pipeline.

0 commit comments

Comments
 (0)