1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 04:55:41 +00:00

Order members alphabetically

This commit is contained in:
Oliver Booth 2022-11-30 18:14:33 +00:00
parent 02b4907c95
commit cfc73cfb62
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
4 changed files with 43 additions and 43 deletions

View File

@ -93,6 +93,44 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
return !Equals(left, right); return !Equals(left, right);
} }
/// <summary>
/// Clicks this avatar.
/// </summary>
/// <param name="clickPoint">The position at which the avatar should be clicked.</param>
/// <exception cref="InvalidOperationException">
/// <para>The action cannot be performed on the client's current avatar.</para>
/// -or-
/// <para>An attempt was made to click an avatar outside of a world.</para>
/// </exception>
public Task ClickAsync(Vector3d? clickPoint = null)
{
// ReSharper disable once InconsistentlySynchronizedField
if (this == _client.CurrentAvatar)
{
return Task.FromException(ThrowHelper.CannotUseSelfException());
}
clickPoint ??= Location.Position;
(double x, double y, double z) = clickPoint.Value;
lock (_client.Lock)
{
nint handle = _client.NativeInstanceHandle;
_ = vp_double_set(handle, FloatAttribute.ClickHitX, x);
_ = vp_double_set(handle, FloatAttribute.ClickHitY, y);
_ = vp_double_set(handle, FloatAttribute.ClickHitZ, z);
var reason = (ReasonCode)vp_avatar_click(handle, Session);
if (reason == ReasonCode.NotInWorld)
{
return Task.FromException(ThrowHelper.NotInWorldException());
}
}
return Task.CompletedTask;
}
/// <summary> /// <summary>
/// Determines if two <see cref="VirtualParadiseAvatar" /> instances are equal. /// Determines if two <see cref="VirtualParadiseAvatar" /> instances are equal.
/// </summary> /// </summary>
@ -129,44 +167,6 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
// ReSharper restore NonReadonlyMemberInGetHashCode // ReSharper restore NonReadonlyMemberInGetHashCode
} }
/// <summary>
/// Clicks this avatar.
/// </summary>
/// <param name="clickPoint">The position at which the avatar should be clicked.</param>
/// <exception cref="InvalidOperationException">
/// <para>The action cannot be performed on the client's current avatar.</para>
/// -or-
/// <para>An attempt was made to click an avatar outside of a world.</para>
/// </exception>
public Task ClickAsync(Vector3d? clickPoint = null)
{
// ReSharper disable once InconsistentlySynchronizedField
if (this == _client.CurrentAvatar)
{
return Task.FromException(ThrowHelper.CannotUseSelfException());
}
clickPoint ??= Location.Position;
(double x, double y, double z) = clickPoint.Value;
lock (_client.Lock)
{
nint handle = _client.NativeInstanceHandle;
vp_double_set(handle, FloatAttribute.ClickHitX, x);
vp_double_set(handle, FloatAttribute.ClickHitY, y);
vp_double_set(handle, FloatAttribute.ClickHitZ, z);
var reason = (ReasonCode)vp_avatar_click(handle, Session);
if (reason == ReasonCode.NotInWorld)
{
return Task.FromException(ThrowHelper.NotInWorldException());
}
}
return Task.CompletedTask;
}
/// <summary> /// <summary>
/// Sends a console message to the avatar with no name. /// Sends a console message to the avatar with no name.
/// </summary> /// </summary>

View File

@ -6,8 +6,8 @@ namespace VpSharp;
public sealed partial class VirtualParadiseClient public sealed partial class VirtualParadiseClient
{ {
private NetConfig _netConfig;
private GCHandle _instanceHandle; private GCHandle _instanceHandle;
private NetConfig _netConfig;
internal object Lock { get; } = new(); internal object Lock { get; } = new();

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Numerics; using System.Numerics;
using System.Threading.Channels; using System.Threading.Channels;
using VpSharp.Entities; using VpSharp.Entities;
@ -11,9 +11,9 @@ namespace VpSharp;
public sealed partial class VirtualParadiseClient public sealed partial class VirtualParadiseClient
{ {
private readonly ConcurrentDictionary<int, VirtualParadiseObject> _objects = new();
private readonly ConcurrentDictionary<int, TaskCompletionSource<(ReasonCode, VirtualParadiseObject?)>> private readonly ConcurrentDictionary<int, TaskCompletionSource<(ReasonCode, VirtualParadiseObject?)>>
_objectCompletionSources = new(); _objectCompletionSources = new();
private readonly ConcurrentDictionary<int, VirtualParadiseObject> _objects = new();
/// <summary> /// <summary>
/// Enumerates all objects within a specified cell. /// Enumerates all objects within a specified cell.

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Drawing; using System.Drawing;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
@ -21,9 +21,9 @@ public sealed partial class VirtualParadiseClient : IDisposable
{ {
private const string DefaultUniverseHost = "universe.virtualparadise.org"; private const string DefaultUniverseHost = "universe.virtualparadise.org";
private const int DefaultUniversePort = 57000; private const int DefaultUniversePort = 57000;
private readonly ConcurrentDictionary<Cell, Channel<VirtualParadiseObject>> _cellChannels = new();
private readonly VirtualParadiseConfiguration _configuration; private readonly VirtualParadiseConfiguration _configuration;
private readonly ConcurrentDictionary<Cell, Channel<VirtualParadiseObject>> _cellChannels = new();
private readonly ConcurrentDictionary<int, VirtualParadiseUser> _friends = new(); private readonly ConcurrentDictionary<int, VirtualParadiseUser> _friends = new();
private readonly Dictionary<int, TaskCompletionSource<ReasonCode>> _inviteCompletionSources = new(); private readonly Dictionary<int, TaskCompletionSource<ReasonCode>> _inviteCompletionSources = new();