Use NRT where appropriate

This commit is contained in:
Oliver Booth 2022-11-30 18:43:59 +00:00
parent 267c450677
commit 8bbbf170e3
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
3 changed files with 17 additions and 13 deletions

View File

@ -197,8 +197,7 @@ public sealed partial class VirtualParadiseClient
} }
VirtualParadiseAvatar? avatar = GetAvatar(session); VirtualParadiseAvatar? avatar = GetAvatar(session);
VirtualParadiseObject? cachedObject = null;
VirtualParadiseObject cachedObject = null;
if (_objects.TryGetValue(objectId, out VirtualParadiseObject? virtualParadiseObject)) if (_objects.TryGetValue(objectId, out VirtualParadiseObject? virtualParadiseObject))
{ {
@ -207,7 +206,12 @@ public sealed partial class VirtualParadiseClient
virtualParadiseObject.ExtractFromInstance(sender); // update existing instance virtualParadiseObject.ExtractFromInstance(sender); // update existing instance
} }
else
{
virtualParadiseObject = await GetObjectAsync(objectId).ConfigureAwait(false);
}
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (virtualParadiseObject is not null) if (virtualParadiseObject is not null)
{ {
AddOrUpdateObject(virtualParadiseObject); AddOrUpdateObject(virtualParadiseObject);
@ -316,7 +320,7 @@ public sealed partial class VirtualParadiseClient
userId = vp_int(sender, IntegerAttribute.FriendUserId); userId = vp_int(sender, IntegerAttribute.FriendUserId);
} }
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false); VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false);
_friends.AddOrUpdate(userId, user, (_, _) => user); _friends.AddOrUpdate(userId, user, (_, _) => user);
} }
@ -519,7 +523,7 @@ public sealed partial class VirtualParadiseClient
name = vp_string(NativeInstanceHandle, StringAttribute.JoinName); name = vp_string(NativeInstanceHandle, StringAttribute.JoinName);
} }
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false); VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false);
var joinRequest = new JoinRequest(this, requestId, name, user); var joinRequest = new JoinRequest(this, requestId, name, user);
var args = new JoinRequestReceivedEventArgs(joinRequest); var args = new JoinRequestReceivedEventArgs(joinRequest);
RaiseEvent(JoinRequestReceived, args); RaiseEvent(JoinRequestReceived, args);
@ -554,7 +558,7 @@ public sealed partial class VirtualParadiseClient
} }
VirtualParadiseWorld? world = await GetWorldAsync(worldName).ConfigureAwait(false); VirtualParadiseWorld? world = await GetWorldAsync(worldName).ConfigureAwait(false);
VirtualParadiseUser? user = await GetUserAsync(userId).ConfigureAwait(false); VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false);
var location = new Location(world, position, rotation); var location = new Location(world, position, rotation);
var request = new InviteRequest(this, requestId, avatarName, user, location); var request = new InviteRequest(this, requestId, avatarName, user, location);

View File

@ -39,7 +39,7 @@ public sealed partial class VirtualParadiseClient
user = await taskCompletionSource.Task.ConfigureAwait(false); user = await taskCompletionSource.Task.ConfigureAwait(false);
user = AddOrUpdateUser(user); user = AddOrUpdateUser(user);
_usersCompletionSources.TryRemove(userId, out TaskCompletionSource<VirtualParadiseUser>? _); _usersCompletionSources.TryRemove(userId, out TaskCompletionSource<VirtualParadiseUser> _);
return user; return user;
} }

View File

@ -208,14 +208,14 @@ public sealed class WorldSettingsBuilder
/// </summary> /// </summary>
/// <value>The texture for the first sky cloud layer.</value> /// <value>The texture for the first sky cloud layer.</value>
[SerializationKey("sky_clouds1")] [SerializationKey("sky_clouds1")]
public string SkyClouds1Texture { get; set; } public string? SkyClouds1Texture { get; set; }
/// <summary> /// <summary>
/// Gets or sets the texture for the second sky cloud layer. /// Gets or sets the texture for the second sky cloud layer.
/// </summary> /// </summary>
/// <value>The texture for the second sky cloud layer.</value> /// <value>The texture for the second sky cloud layer.</value>
[SerializationKey("sky_clouds2")] [SerializationKey("sky_clouds2")]
public string SkyClouds2Texture { get; set; } public string? SkyClouds2Texture { get; set; }
/// <summary> /// <summary>
/// Gets or sets the velocity for the first sky cloud layer. /// Gets or sets the velocity for the first sky cloud layer.
@ -278,14 +278,14 @@ public sealed class WorldSettingsBuilder
/// </summary> /// </summary>
/// <value>The skybox texture.</value> /// <value>The skybox texture.</value>
[SerializationKey("skybox")] [SerializationKey("skybox")]
public string Skybox { get; set; } public string? Skybox { get; set; }
/// <summary> /// <summary>
/// Gets or sets the file extension for skybox textures. /// Gets or sets the file extension for skybox textures.
/// </summary> /// </summary>
/// <value>The file extension for skybox textures.</value> /// <value>The file extension for skybox textures.</value>
[SerializationKey("skybox_extension")] [SerializationKey("skybox_extension")]
public string SkyboxExtension { get; set; } public string? SkyboxExtension { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the X axis of skybox textures should be swapped. /// Gets or sets a value indicating whether the X axis of skybox textures should be swapped.
@ -330,14 +330,14 @@ public sealed class WorldSettingsBuilder
/// </summary> /// </summary>
/// <value>The URL of the in-world web overlay.</value> /// <value>The URL of the in-world web overlay.</value>
[SerializationKey("web_overlay")] [SerializationKey("web_overlay")]
public string WebOverlay { get; set; } public string? WebOverlay { get; set; }
/// <summary> /// <summary>
/// Gets or sets the welcome message. /// Gets or sets the welcome message.
/// </summary> /// </summary>
/// <value>The welcome message.</value> /// <value>The welcome message.</value>
[SerializationKey("welcome")] [SerializationKey("welcome")]
public string WelcomeMessage { get; set; } public string? WelcomeMessage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the ambient light color of the world. /// Gets or sets the ambient light color of the world.
@ -376,7 +376,7 @@ public sealed class WorldSettingsBuilder
/// </summary> /// </summary>
/// <value>The name of the world.</value> /// <value>The name of the world.</value>
[SerializationKey("worldname")] [SerializationKey("worldname")]
public string WorldName { get; set; } public string? WorldName { get; set; }
internal void SendChanges() internal void SendChanges()
{ {