From 2669b5083d9c0acc65a7d390473289066280b12c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 30 May 2024 19:36:14 +0100 Subject: [PATCH] refactor!: revert to 397ec2bcf92e078e8e9d1ddf1f9e9bd967180c75 --- .../VpSharp.CSharp_Sample.csproj | 16 +- .../VpSharp.VB_Sample.vbproj | 18 +- .../RequireUserNameAttribute.cs | 2 +- VpSharp.Commands/CommandContext.cs | 13 +- VpSharp.Commands/CommandsExtension.cs | 4 +- VpSharp.IntegrationTests/src/Program.cs | 10 +- .../VirtualParadiseClientExtension.cs | 4 +- VpSharp/src/Entities/ConsoleMessage.cs | 30 --- VpSharp/src/Entities/IAvatar.cs | 184 ------------------ VpSharp/src/Entities/IConsoleMessage.cs | 21 -- VpSharp/src/Entities/IMessage.cs | 25 --- VpSharp/src/Entities/IUser.cs | 71 ------- VpSharp/src/Entities/IUserMessage.cs | 6 - VpSharp/src/Entities/Message.cs | 29 --- VpSharp/src/Entities/UserMessage.cs | 17 -- .../{Avatar.cs => VirtualParadiseAvatar.cs} | 55 +++--- .../src/Entities/VirtualParadiseMessage.cs | 67 +++++++ ...bject.cs => VirtualParadiseModelObject.cs} | 20 +- ...s => VirtualParadiseModelObjectBuilder.cs} | 8 +- VpSharp/src/Entities/VirtualParadiseObject.cs | 10 +- ...der.cs => VirtualParadiseObjectBuilder.cs} | 8 +- ...> VirtualParadiseParticleEmitterObject.cs} | 12 +- ...alParadiseParticleEmitterObjectBuilder.cs} | 56 +++--- .../{Path.cs => VirtualParadisePath.cs} | 8 +- ...Object.cs => VirtualParadisePathObject.cs} | 14 +- .../{User.cs => VirtualParadiseUser.cs} | 20 +- .../{World.cs => VirtualParadiseWorld.cs} | 20 +- .../src/EventData/AvatarClickedEventArgs.cs | 6 +- VpSharp/src/EventData/AvatarMovedEventArgs.cs | 4 +- .../EventData/AvatarTypeChangedEventArgs.cs | 4 +- VpSharp/src/EventData/ObjectBumpEventArgs.cs | 4 +- .../src/EventData/ObjectChangedEventArgs.cs | 4 +- .../src/EventData/ObjectClickedEventArgs.cs | 4 +- .../src/EventData/ObjectCreatedEventArgs.cs | 4 +- .../src/EventData/ObjectDeletedEventArgs.cs | 4 +- VpSharp/src/EventData/TeleportedEventArgs.cs | 4 +- VpSharp/src/EventData/UriReceivedEventArgs.cs | 4 +- VpSharp/src/InviteRequest.cs | 4 +- VpSharp/src/JoinRequest.cs | 4 +- VpSharp/src/Location.cs | 8 +- VpSharp/src/MessageType.cs | 17 ++ VpSharp/src/PathEasing.cs | 2 +- VpSharp/src/PathPoint.cs | 2 +- VpSharp/src/UriTarget.cs | 2 +- VpSharp/src/VirtualParadiseClient.Avatars.cs | 14 +- VpSharp/src/VirtualParadiseClient.Events.cs | 12 +- .../src/VirtualParadiseClient.NativeEvents.cs | 63 +++--- VpSharp/src/VirtualParadiseClient.Objects.cs | 6 +- VpSharp/src/VirtualParadiseClient.Users.cs | 18 +- VpSharp/src/VirtualParadiseClient.Worlds.cs | 24 +-- VpSharp/src/VirtualParadiseClient.cs | 71 +++---- 51 files changed, 368 insertions(+), 669 deletions(-) delete mode 100644 VpSharp/src/Entities/ConsoleMessage.cs delete mode 100644 VpSharp/src/Entities/IAvatar.cs delete mode 100644 VpSharp/src/Entities/IConsoleMessage.cs delete mode 100644 VpSharp/src/Entities/IMessage.cs delete mode 100644 VpSharp/src/Entities/IUser.cs delete mode 100644 VpSharp/src/Entities/IUserMessage.cs delete mode 100644 VpSharp/src/Entities/Message.cs delete mode 100644 VpSharp/src/Entities/UserMessage.cs rename VpSharp/src/Entities/{Avatar.cs => VirtualParadiseAvatar.cs} (89%) create mode 100644 VpSharp/src/Entities/VirtualParadiseMessage.cs rename VpSharp/src/Entities/{ModelObject.cs => VirtualParadiseModelObject.cs} (81%) rename VpSharp/src/Entities/{ModelObjectBuilder.cs => VirtualParadiseModelObjectBuilder.cs} (86%) rename VpSharp/src/Entities/{ObjectBuilder.cs => VirtualParadiseObjectBuilder.cs} (95%) rename VpSharp/src/Entities/{ParticleEmitterObject.cs => VirtualParadiseParticleEmitterObject.cs} (94%) rename VpSharp/src/Entities/{ParticleEmitterObjectBuilder.cs => VirtualParadiseParticleEmitterObjectBuilder.cs} (85%) rename VpSharp/src/Entities/{Path.cs => VirtualParadisePath.cs} (75%) rename VpSharp/src/Entities/{PathObject.cs => VirtualParadisePathObject.cs} (91%) rename VpSharp/src/Entities/{User.cs => VirtualParadiseUser.cs} (90%) rename VpSharp/src/Entities/{World.cs => VirtualParadiseWorld.cs} (81%) create mode 100644 VpSharp/src/MessageType.cs diff --git a/Samples/VpSharp.CSharp_Sample/VpSharp.CSharp_Sample.csproj b/Samples/VpSharp.CSharp_Sample/VpSharp.CSharp_Sample.csproj index d25277e..1d3086f 100644 --- a/Samples/VpSharp.CSharp_Sample/VpSharp.CSharp_Sample.csproj +++ b/Samples/VpSharp.CSharp_Sample/VpSharp.CSharp_Sample.csproj @@ -8,17 +8,17 @@ - - + + - - Always - - - Always - + + Always + + + Always + diff --git a/Samples/VpSharp.VB_Sample/VpSharp.VB_Sample.vbproj b/Samples/VpSharp.VB_Sample/VpSharp.VB_Sample.vbproj index 2467d8b..23db2fe 100644 --- a/Samples/VpSharp.VB_Sample/VpSharp.VB_Sample.vbproj +++ b/Samples/VpSharp.VB_Sample/VpSharp.VB_Sample.vbproj @@ -8,17 +8,17 @@ - - + + - - Always - - - Always - + + Always + + + Always + - \ No newline at end of file + diff --git a/VpSharp.Commands/Attributes/ExecutionChecks/RequireUserNameAttribute.cs b/VpSharp.Commands/Attributes/ExecutionChecks/RequireUserNameAttribute.cs index 7e78788..f008b13 100644 --- a/VpSharp.Commands/Attributes/ExecutionChecks/RequireUserNameAttribute.cs +++ b/VpSharp.Commands/Attributes/ExecutionChecks/RequireUserNameAttribute.cs @@ -54,7 +54,7 @@ public sealed class RequireUserNameAttribute : PreExecutionCheckAttribute throw new ArgumentNullException(nameof(context)); } - IUser user = await context.Avatar.GetUserAsync().ConfigureAwait(false); + VirtualParadiseUser user = await context.Avatar.GetUserAsync().ConfigureAwait(false); return Names.Contains(user.Name); } } diff --git a/VpSharp.Commands/CommandContext.cs b/VpSharp.Commands/CommandContext.cs index e6f4b84..ce2f9d9 100644 --- a/VpSharp.Commands/CommandContext.cs +++ b/VpSharp.Commands/CommandContext.cs @@ -9,7 +9,7 @@ namespace VpSharp.Commands; /// public sealed class CommandContext { - internal CommandContext(VirtualParadiseClient client, IAvatar avatar, string commandName, string alias, + internal CommandContext(VirtualParadiseClient client, VirtualParadiseAvatar avatar, string commandName, string alias, string rawArguments) { Client = client; @@ -36,8 +36,8 @@ public sealed class CommandContext /// Gets the avatar who executed the command. /// /// The executing avatar. - public IAvatar Avatar { get; } - + public VirtualParadiseAvatar Avatar { get; } + /// /// Gets the client which raised the event. /// @@ -65,11 +65,10 @@ public sealed class CommandContext /// regular chat message. /// /// The message which was sent. - public async Task RespondAsync(string message, bool ephemeral = false) + public Task RespondAsync(string message, bool ephemeral = false) { return ephemeral - ? await Avatar.SendMessageAsync(Client.CurrentAvatar?.Name, message, FontStyle.Regular, Color.Black) - .ConfigureAwait(false) - : await Client.SendMessageAsync(message).ConfigureAwait(false); + ? Avatar.SendMessageAsync(Client.CurrentAvatar?.Name, message, FontStyle.Regular, Color.Black) + : Client.SendMessageAsync(message); } } diff --git a/VpSharp.Commands/CommandsExtension.cs b/VpSharp.Commands/CommandsExtension.cs index 66def85..62d46e6 100644 --- a/VpSharp.Commands/CommandsExtension.cs +++ b/VpSharp.Commands/CommandsExtension.cs @@ -176,14 +176,14 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension } /// - protected internal override Task OnMessageReceived(IMessage message) + protected internal override Task OnMessageReceived(VirtualParadiseMessage message) { if (message is null) { throw new ArgumentNullException(nameof(message)); } - if (message is IUserMessage) + if (message.Type != MessageType.ChatMessage) { return base.OnMessageReceived(message); } diff --git a/VpSharp.IntegrationTests/src/Program.cs b/VpSharp.IntegrationTests/src/Program.cs index 8ebb547..c28e85e 100644 --- a/VpSharp.IntegrationTests/src/Program.cs +++ b/VpSharp.IntegrationTests/src/Program.cs @@ -1,8 +1,6 @@ -using System.Reactive.Linq; -using VpSharp; +using VpSharp; using VpSharp.Commands; using VpSharp.Entities; -using VpSharp.Extensions; using VpSharp.IntegrationTests.CommandModules; string? username = Environment.GetEnvironmentVariable("username"); @@ -30,8 +28,6 @@ var configuration = new VirtualParadiseConfiguration }; using var client = new VirtualParadiseClient(configuration); -client.AvatarJoined.Where(a => !a.IsBot).SubscribeAsync(async avatar => await client.SendMessageAsync($"Hello, {avatar.Name}")); - CommandsExtension commands = client.UseCommands(new CommandsExtensionConfiguration {Prefixes = new[] {"!"}}); commands.RegisterCommands(); @@ -42,10 +38,10 @@ Console.WriteLine(@"Logging in"); await client.LoginAsync(); Console.WriteLine(@"Entering world"); -World world = await client.EnterAsync("Mutation"); +VirtualParadiseWorld world = await client.EnterAsync("Mutation"); Console.WriteLine(@"Entered world!"); -IAvatar avatar = client.CurrentAvatar!; +VirtualParadiseAvatar avatar = client.CurrentAvatar!; Console.WriteLine($@"My name is {avatar.Name} and I am at {avatar.Location}"); Console.WriteLine($@"Entered {world.Name} with size {world.Size}"); diff --git a/VpSharp/src/ClientExtensions/VirtualParadiseClientExtension.cs b/VpSharp/src/ClientExtensions/VirtualParadiseClientExtension.cs index 874177f..54c4b66 100644 --- a/VpSharp/src/ClientExtensions/VirtualParadiseClientExtension.cs +++ b/VpSharp/src/ClientExtensions/VirtualParadiseClientExtension.cs @@ -26,8 +26,8 @@ public abstract class VirtualParadiseClientExtension /// /// Called when a chat message is received. /// - /// The message which was received. - protected internal virtual Task OnMessageReceived(IMessage message) + /// An object containing event data. + protected internal virtual Task OnMessageReceived(VirtualParadiseMessage message) { return Task.CompletedTask; } diff --git a/VpSharp/src/Entities/ConsoleMessage.cs b/VpSharp/src/Entities/ConsoleMessage.cs deleted file mode 100644 index f27949c..0000000 --- a/VpSharp/src/Entities/ConsoleMessage.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Drawing; - -namespace VpSharp.Entities; - -/// -/// Represents a chat message that was sent by a user. -/// -public sealed class ConsoleMessage : Message, IConsoleMessage -{ - /// - /// Initializes a new instance of the class. - /// - /// The author of the message. - /// The apparent sender's name of the message. - /// The content of the message. - /// A value representing the color of the message. - /// A value representing the font style of the message. - public ConsoleMessage(IAvatar author, string name, string content, Color color, FontStyle fontStyle) - : base(author, name, content) - { - Color = color; - Style = fontStyle; - } - - /// - public Color Color { get; } - - /// - public FontStyle Style { get; } -} diff --git a/VpSharp/src/Entities/IAvatar.cs b/VpSharp/src/Entities/IAvatar.cs deleted file mode 100644 index 4238798..0000000 --- a/VpSharp/src/Entities/IAvatar.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System.Drawing; - -namespace VpSharp.Entities; - -public interface IAvatar -{ - /// - /// Gets the details of the application this avatar is using. - /// - /// The avatar's application details. - Application Application { get; } - - /// - /// Gets a value indicating whether this avatar is a bot. - /// - /// if this avatar is a bot; otherwise, . - bool IsBot { get; } - - /// - /// Gets the location of this avatar. - /// - /// The location of this avatar. - Location Location { get; } - - /// - /// Gets the name of this avatar. - /// - /// The name of this avatar. - string Name { get; } - - /// - /// Gets the session ID of this avatar. - /// - /// The session ID. - int Session { get; } - - /// - /// Gets the type of this avatar. - /// - /// The type of this avatar. - int Type { get; } - - /// - /// Gets the user ID associated with this avatar. - /// - /// The user ID. - int UserId { get; } - - /// - /// Clicks this avatar. - /// - /// The position at which the avatar should be clicked. - /// - /// The action cannot be performed on the client's current avatar. - /// -or- - /// An attempt was made to click an avatar outside of a world. - /// - Task ClickAsync(Vector3d? clickPoint = null); - - /// - /// Determines if two instances are equal. - /// - /// The other instance. - /// - /// if this instance is equal to ; otherwise, . - /// - bool Equals(Avatar? other); - - /// - /// Gets the user associated with this avatar. - /// - /// The user. - Task GetUserAsync(); - - /// - /// Sends a console message to the avatar with no name. - /// - /// The message to send. - /// The font style of the message. - /// The text color of the message. - /// The message which was sent. - /// is . - /// - /// An attempt was made to send a message while not connected to a world. - /// -or- - /// An attempt was made to send a message to an avatar that is not in the world. - /// - /// - /// is empty, or consists of only whitespace. - /// -or- - /// is too long to send. - /// - Task SendMessageAsync(string message, FontStyle fontStyle, Color color); - - /// - /// Sends a console message to the avatar. - /// - /// The apparent author of the message. - /// The message to send. - /// The font style of the message. - /// The text color of the message. - /// The message which was sent. - /// is . - /// - /// An attempt was made to send a message while not connected to a world. - /// -or- - /// An attempt was made to send a message to an avatar that is not in the world. - /// - /// - /// is empty, or consists of only whitespace. - /// -or- - /// is too long to send. - /// - /// Passing to will hide the name from the recipient. - Task SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color); - - /// - /// Sends a URI to this avatar. - /// - /// The URI to send. - /// The URL target. See for more information. - /// The action cannot be performed on the client's current avatar. - /// is . - Task SendUriAsync(Uri uri, UriTarget target = UriTarget.Browser); - - /// - /// Modifies the world settings for this avatar. - /// - /// The builder which defines parameters to change. - /// is . - /// The client does not have permission to modify world settings. - Task SendWorldSettings(Action action); - - /// - /// Teleports the avatar to another world. - /// - /// The name of the world to which this avatar should be teleported. - /// The position to which this avatar should be teleported. - /// is . - Task TeleportAsync(World world, Vector3d position); - - /// - /// Teleports the avatar to another world. - /// - /// The name of the world to which this avatar should be teleported. - /// The position to which this avatar should be teleported. - /// The rotation to which this avatar should be teleported. - /// is . - Task TeleportAsync(World world, Vector3d position, Rotation rotation); - - /// - /// Teleports the avatar to another world. - /// - /// The name of the world to which this avatar should be teleported. - /// The position to which this avatar should be teleported. - Task TeleportAsync(string world, Vector3d position); - - /// - /// Teleports the avatar to another world. - /// - /// The name of the world to which this avatar should be teleported. - /// The position to which this avatar should be teleported. - /// The rotation to which this avatar should be teleported. - Task TeleportAsync(string world, Vector3d position, Rotation rotation); - - /// - /// Teleports the avatar to a new position within the current world. - /// - /// The position to which this avatar should be teleported. - Task TeleportAsync(Vector3d position); - - /// - /// Teleports the avatar to a new position and rotation within the current world. - /// - /// The position to which this avatar should be teleported. - /// The rotation to which this avatar should be teleported - Task TeleportAsync(Vector3d position, Rotation rotation); - - /// - /// Teleports this avatar to a new location, which may or may not be a new world. - /// - /// The location to which this avatar should be teleported. - Task TeleportAsync(Location location); -} diff --git a/VpSharp/src/Entities/IConsoleMessage.cs b/VpSharp/src/Entities/IConsoleMessage.cs deleted file mode 100644 index b00b90f..0000000 --- a/VpSharp/src/Entities/IConsoleMessage.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Drawing; - -namespace VpSharp.Entities; - -/// -/// Represents a console message. -/// -public interface IConsoleMessage : IMessage -{ - /// - /// Gets the color of the message. - /// - /// A value representing the color. - Color Color { get; } - - /// - /// Gets the font style of the message. - /// - /// A value representing the font style. - FontStyle Style { get; } -} diff --git a/VpSharp/src/Entities/IMessage.cs b/VpSharp/src/Entities/IMessage.cs deleted file mode 100644 index afd3f4a..0000000 --- a/VpSharp/src/Entities/IMessage.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace VpSharp.Entities; - -/// -/// Represents a message. -/// -public interface IMessage -{ - /// - /// Gets the author of the message. - /// - /// The avatar which authored the message. - IAvatar Author { get; } - - /// - /// Gets the content of the message. - /// - /// The content. - string Content { get; } - - /// - /// Gets the apparent sender's name of the message. - /// - /// The sender's name. - string Name { get; } -} diff --git a/VpSharp/src/Entities/IUser.cs b/VpSharp/src/Entities/IUser.cs deleted file mode 100644 index 083f109..0000000 --- a/VpSharp/src/Entities/IUser.cs +++ /dev/null @@ -1,71 +0,0 @@ -using VpSharp.Exceptions; - -namespace VpSharp.Entities; - -public interface IUser -{ - /// - /// Gets the email address of this user. - /// - /// The email address of this user. - string EmailAddress { get; } - - /// - /// Gets the ID of this user. - /// - /// The user's ID. - int Id { get; } - - /// - /// Gets the date and time at which this user was last online. - /// - /// A representing the date and time this user was last online. - DateTimeOffset LastLogin { get; } - - /// - /// Gets the name of this user. - /// - /// The user's name. - string Name { get; } - - /// - /// Gets the duration for which this user has been online. - /// - /// A representing the duration for which this user has been online. - TimeSpan OnlineTime { get; } - - /// - /// Gets the date and time at which this user was registered. - /// - /// A representing the date and time this user was registered. - DateTimeOffset RegistrationTime { get; } - - /// - /// Determines if two instances are equal. - /// - /// The other instance. - /// - /// if this instance is equal to ; otherwise, . - /// - bool Equals(User? other); - - /// - /// Invites this user to a specified location. - /// - /// - /// The invitation location. If , the client's current location is used. - /// - Task InviteAsync(Location? location = null); - - /// - /// Sends a to join request to the user. - /// - /// - /// If , the client's avatar will not teleport to the requested location automatically. - /// Be careful, there is no way to retrieve - /// - /// The result of the request. - /// This user is invalid and cannot be joined. - /// An unexpected error occurred trying to join the user. - Task JoinAsync(bool suppressTeleport = false); -} diff --git a/VpSharp/src/Entities/IUserMessage.cs b/VpSharp/src/Entities/IUserMessage.cs deleted file mode 100644 index 2a94279..0000000 --- a/VpSharp/src/Entities/IUserMessage.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace VpSharp.Entities; - -/// -/// Represents a chat message that was sent by a user. -/// -public interface IUserMessage : IMessage; diff --git a/VpSharp/src/Entities/Message.cs b/VpSharp/src/Entities/Message.cs deleted file mode 100644 index c30c653..0000000 --- a/VpSharp/src/Entities/Message.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace VpSharp.Entities; - -/// -/// Represents a message. -/// -public abstract class Message : IMessage -{ - /// - /// Initializes a new instance of the class. - /// - /// The author of the message. - /// The apparent sender's name of the message. - /// The content of the message. - protected Message(IAvatar author, string name, string content) - { - Author = author; - Content = content; - Name = name; - } - - /// - public IAvatar Author { get; } - - /// - public string Content { get; } - - /// - public string Name { get; } -} diff --git a/VpSharp/src/Entities/UserMessage.cs b/VpSharp/src/Entities/UserMessage.cs deleted file mode 100644 index 832e81f..0000000 --- a/VpSharp/src/Entities/UserMessage.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace VpSharp.Entities; - -/// -/// Represents a chat message that was sent by a user. -/// -public sealed class UserMessage : Message, IUserMessage -{ - /// - /// Initializes a new instance of the class. - /// - /// The author of the message. - /// The content of the message. - public UserMessage(IAvatar author, string content) - : base(author, author.Name, content) - { - } -} diff --git a/VpSharp/src/Entities/Avatar.cs b/VpSharp/src/Entities/VirtualParadiseAvatar.cs similarity index 89% rename from VpSharp/src/Entities/Avatar.cs rename to VpSharp/src/Entities/VirtualParadiseAvatar.cs index 2486e21..bd9dd3f 100644 --- a/VpSharp/src/Entities/Avatar.cs +++ b/VpSharp/src/Entities/VirtualParadiseAvatar.cs @@ -10,12 +10,12 @@ namespace VpSharp.Entities; /// /// Represents an avatar within a world. /// -public sealed class Avatar : IEquatable, IAvatar +public sealed class VirtualParadiseAvatar : IEquatable { private readonly VirtualParadiseClient _client; - private IUser? _user; + private VirtualParadiseUser? _user; - internal Avatar(VirtualParadiseClient client, int session) + internal VirtualParadiseAvatar(VirtualParadiseClient client, int session) { _client = client ?? throw new ArgumentNullException(nameof(client)); Session = session; @@ -33,7 +33,7 @@ public sealed class Avatar : IEquatable, IAvatar /// if this avatar is a bot; otherwise, . public bool IsBot { - get => Name is { Length: > 1 } name && name[0] == '[' && name[^1] == ']'; + get => Name is {Length: > 1} name && name[0] == '[' && name[^1] == ']'; } /// @@ -67,7 +67,7 @@ public sealed class Avatar : IEquatable, IAvatar public int UserId { get; internal set; } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The first instance. /// The second instance. @@ -75,13 +75,13 @@ public sealed class Avatar : IEquatable, IAvatar /// if is equal to ; otherwise, /// . /// - public static bool operator ==(Avatar? left, Avatar? right) + public static bool operator ==(VirtualParadiseAvatar? left, VirtualParadiseAvatar? right) { return Equals(left, right); } /// - /// Determines if two instances are not equal. + /// Determines if two instances are not equal. /// /// The first instance. /// The second instance. @@ -89,7 +89,7 @@ public sealed class Avatar : IEquatable, IAvatar /// if is not equal to ; otherwise, /// . /// - public static bool operator !=(Avatar? left, Avatar? right) + public static bool operator !=(VirtualParadiseAvatar? left, VirtualParadiseAvatar? right) { return !Equals(left, right); } @@ -133,13 +133,13 @@ public sealed class Avatar : IEquatable, IAvatar } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The other instance. /// /// if this instance is equal to ; otherwise, . /// - public bool Equals(Avatar? other) + public bool Equals(VirtualParadiseAvatar? other) { if (ReferenceEquals(null, other)) { @@ -157,7 +157,7 @@ public sealed class Avatar : IEquatable, IAvatar /// public override bool Equals(object? obj) { - return ReferenceEquals(this, obj) || (obj is Avatar other && Equals(other)); + return ReferenceEquals(this, obj) || (obj is VirtualParadiseAvatar other && Equals(other)); } /// @@ -172,7 +172,7 @@ public sealed class Avatar : IEquatable, IAvatar /// Gets the user associated with this avatar. /// /// The user. - public async Task GetUserAsync() + public async Task GetUserAsync() { _user ??= await _client.GetUserAsync(UserId).ConfigureAwait(false); return _user; @@ -196,8 +196,9 @@ public sealed class Avatar : IEquatable, IAvatar /// -or- /// is too long to send. /// - public Task SendMessageAsync(string message, FontStyle fontStyle, Color color) + public Task SendMessageAsync(string message, FontStyle fontStyle, Color color) { + // ReSharper disable once InconsistentlySynchronizedField return SendMessageAsync(null, message, fontStyle, color); } @@ -221,7 +222,7 @@ public sealed class Avatar : IEquatable, IAvatar /// is too long to send. /// /// Passing to will hide the name from the recipient. - public Task SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color) + public Task SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color) { if (message is null) { @@ -233,7 +234,7 @@ public sealed class Avatar : IEquatable, IAvatar throw new ArgumentException(ExceptionMessages.ValueCannotBeEmpty, nameof(message)); } - IAvatar avatar; + VirtualParadiseAvatar avatar; lock (_client.Lock) { @@ -248,7 +249,6 @@ public sealed class Avatar : IEquatable, IAvatar color.B ); - // TODO remove if statement if (reason != ReasonCode.Success) { switch (reason) @@ -267,12 +267,13 @@ public sealed class Avatar : IEquatable, IAvatar avatar = _client.CurrentAvatar!; } - return Task.FromResult((IConsoleMessage)new ConsoleMessage( - avatar, - avatar.Name, + return Task.FromResult(new VirtualParadiseMessage( + MessageType.ConsoleMessage, + name, message, - color, - fontStyle + avatar, + fontStyle, + color )); } @@ -330,7 +331,7 @@ public sealed class Avatar : IEquatable, IAvatar /// The name of the world to which this avatar should be teleported. /// The position to which this avatar should be teleported. /// is . - public Task TeleportAsync(World world, Vector3d position) + public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position) { if (world is null) { @@ -347,7 +348,7 @@ public sealed class Avatar : IEquatable, IAvatar /// The position to which this avatar should be teleported. /// The rotation to which this avatar should be teleported. /// is . - public Task TeleportAsync(World world, Vector3d position, Rotation rotation) + public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position, Rotation rotation) { if (world is null) { @@ -442,8 +443,8 @@ public sealed class Avatar : IEquatable, IAvatar } } - World? updatedWorld = isNewWorld ? await _client.GetWorldAsync(world) : Location.World; - updatedWorld ??= new World(_client, world); + VirtualParadiseWorld? updatedWorld = isNewWorld ? await _client.GetWorldAsync(world) : Location.World; + updatedWorld ??= new VirtualParadiseWorld(_client, world); Location = new Location(updatedWorld, position, rotation); // ReSharper restore InconsistentlySynchronizedField } @@ -454,7 +455,7 @@ public sealed class Avatar : IEquatable, IAvatar /// The position to which this avatar should be teleported. public Task TeleportAsync(Vector3d position) { - return TeleportAsync(Location with { Position = position }); + return TeleportAsync(Location with {Position = position}); } /// @@ -464,7 +465,7 @@ public sealed class Avatar : IEquatable, IAvatar /// The rotation to which this avatar should be teleported public Task TeleportAsync(Vector3d position, Rotation rotation) { - return TeleportAsync(Location with { Position = position, Rotation = rotation }); + return TeleportAsync(Location with {Position = position, Rotation = rotation}); } /// diff --git a/VpSharp/src/Entities/VirtualParadiseMessage.cs b/VpSharp/src/Entities/VirtualParadiseMessage.cs new file mode 100644 index 0000000..32dde98 --- /dev/null +++ b/VpSharp/src/Entities/VirtualParadiseMessage.cs @@ -0,0 +1,67 @@ +using System.Drawing; + +namespace VpSharp.Entities; + +/// +/// Represents a message. +/// +public sealed class VirtualParadiseMessage +{ + internal VirtualParadiseMessage( + MessageType type, + string? name, + string content, + VirtualParadiseAvatar author, + FontStyle style, + Color color) + { + Type = type; + Name = string.IsNullOrWhiteSpace(name) ? null : name; + Content = content; + Author = author; + Style = style; + Color = color; + } + + /// + /// Gets the message author. + /// + /// The message author. + public VirtualParadiseAvatar Author { get; } + + /// + /// Gets the message content. + /// + /// The message content. + public string Content { get; } + + /// + /// Gets the message name. + /// + /// The message name. This will always be equal to the name of the for chat messages. + public string? Name { get; } + + /// + /// Gets the message color. + /// + /// The message color. This will always be for chat messages. + public Color Color { get; } + + /// + /// Gets the message font style. + /// + /// The message font style. This will always be for chat messages. + public FontStyle Style { get; } + + /// + /// Gets the type of this message. + /// + /// The type of this message. + public MessageType Type { get; } + + /// + public override string ToString() + { + return $"Message {Author}; Type {Type}; Content {Content}"; + } +} diff --git a/VpSharp/src/Entities/ModelObject.cs b/VpSharp/src/Entities/VirtualParadiseModelObject.cs similarity index 81% rename from VpSharp/src/Entities/ModelObject.cs rename to VpSharp/src/Entities/VirtualParadiseModelObject.cs index 9b6d521..63bb547 100644 --- a/VpSharp/src/Entities/ModelObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseModelObject.cs @@ -9,15 +9,15 @@ namespace VpSharp.Entities; /// Represents an object which renders as a 3D model. A "model" object will contain a Model, Description /// and Action field. /// -public class ModelObject : VirtualParadiseObject +public class VirtualParadiseModelObject : VirtualParadiseObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The owning client. /// The object ID. /// is . - internal ModelObject(VirtualParadiseClient client, int id) + internal VirtualParadiseModelObject(VirtualParadiseClient client, int id) : base(client, id) { } @@ -46,11 +46,11 @@ public class ModelObject : VirtualParadiseObject /// The builder which defines parameters to change. /// is . /// - /// was assigned. + /// was assigned. /// -or- - /// was assigned. + /// was assigned. /// - public async Task ModifyAsync(Action action) + public async Task ModifyAsync(Action action) { if (action is null) { @@ -58,7 +58,7 @@ public class ModelObject : VirtualParadiseObject } var taskCompletionSource = new TaskCompletionSource(); - var builder = new ModelObjectBuilder(Client, this, ObjectBuilderMode.Modify); + var builder = new VirtualParadiseModelObjectBuilder(Client, this, ObjectBuilderMode.Modify); await Task.Run(() => action(builder)).ConfigureAwait(false); lock (Client.Lock) @@ -90,9 +90,9 @@ public class ModelObject : VirtualParadiseObject } /// - protected internal override void ExtractFromBuilder(ObjectBuilder builder) + protected internal override void ExtractFromBuilder(VirtualParadiseObjectBuilder builder) { - if (builder is not ModelObjectBuilder modelObjectBuilder) + if (builder is not VirtualParadiseModelObjectBuilder modelObjectBuilder) { return; } @@ -107,7 +107,7 @@ public class ModelObject : VirtualParadiseObject /// protected internal override void ExtractFromOther(VirtualParadiseObject virtualParadiseObject) { - if (virtualParadiseObject is not ModelObject model) + if (virtualParadiseObject is not VirtualParadiseModelObject model) { return; } diff --git a/VpSharp/src/Entities/ModelObjectBuilder.cs b/VpSharp/src/Entities/VirtualParadiseModelObjectBuilder.cs similarity index 86% rename from VpSharp/src/Entities/ModelObjectBuilder.cs rename to VpSharp/src/Entities/VirtualParadiseModelObjectBuilder.cs index e2f8784..e5087ec 100644 --- a/VpSharp/src/Entities/ModelObjectBuilder.cs +++ b/VpSharp/src/Entities/VirtualParadiseModelObjectBuilder.cs @@ -8,11 +8,11 @@ namespace VpSharp.Entities; /// /// Provides mutability for . /// -public sealed class ModelObjectBuilder : ObjectBuilder +public sealed class VirtualParadiseModelObjectBuilder : VirtualParadiseObjectBuilder { - internal ModelObjectBuilder( + internal VirtualParadiseModelObjectBuilder( VirtualParadiseClient client, - ModelObject targetObject, + VirtualParadiseModelObject targetObject, ObjectBuilderMode mode ) : base(client, targetObject, mode) @@ -42,7 +42,7 @@ public sealed class ModelObjectBuilder : ObjectBuilder base.ApplyChanges(); nint handle = Client.NativeInstanceHandle; - var targetObject = (ModelObject)TargetObject; + var targetObject = (VirtualParadiseModelObject)TargetObject; vp_string_set(handle, ObjectModel, Model.ValueOr(targetObject.Model)); vp_string_set(handle, ObjectDescription, Description.ValueOr(targetObject.Description)); vp_string_set(handle, ObjectAction, Action.ValueOr(targetObject.Action)); diff --git a/VpSharp/src/Entities/VirtualParadiseObject.cs b/VpSharp/src/Entities/VirtualParadiseObject.cs index 4566505..2d159d7 100644 --- a/VpSharp/src/Entities/VirtualParadiseObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseObject.cs @@ -51,7 +51,7 @@ public abstract class VirtualParadiseObject : IEquatable /// Gets the owner of this object. /// /// The owner of this object. - public IUser Owner { get; internal set; } = null!; + public VirtualParadiseUser Owner { get; internal set; } = null!; internal byte[] Data { get; set; } = Array.Empty(); @@ -90,7 +90,7 @@ public abstract class VirtualParadiseObject : IEquatable /// The target avatar to receive the event. If this value is , the bump will be broadcast to /// all avatars in the world. /// - public async Task BumpAsync(BumpPhase? phase = null, Avatar? target = null) + public async Task BumpAsync(BumpPhase? phase = null, VirtualParadiseAvatar? target = null) { int session = target?.Session ?? 0; @@ -139,7 +139,7 @@ public abstract class VirtualParadiseObject : IEquatable /// The target avatar which will receive the event, or to broadcast to every avatar. /// /// is the client's current avatar. - public Task ClickAsync(Vector3d? position = null, Avatar? target = null) + public Task ClickAsync(Vector3d? position = null, VirtualParadiseAvatar? target = null) { if (target == Client.CurrentAvatar) { @@ -236,10 +236,10 @@ public abstract class VirtualParadiseObject : IEquatable } /// - /// Updates the object by extracting the values provided by a specified . + /// Updates the object by extracting the values provided by a specified . /// /// The builder whose values to extract. - protected internal virtual void ExtractFromBuilder(ObjectBuilder builder) + protected internal virtual void ExtractFromBuilder(VirtualParadiseObjectBuilder builder) { if (builder is null) { diff --git a/VpSharp/src/Entities/ObjectBuilder.cs b/VpSharp/src/Entities/VirtualParadiseObjectBuilder.cs similarity index 95% rename from VpSharp/src/Entities/ObjectBuilder.cs rename to VpSharp/src/Entities/VirtualParadiseObjectBuilder.cs index 069c30d..538906d 100644 --- a/VpSharp/src/Entities/ObjectBuilder.cs +++ b/VpSharp/src/Entities/VirtualParadiseObjectBuilder.cs @@ -10,9 +10,9 @@ namespace VpSharp.Entities; /// /// Represents the base class for object builders. /// -public abstract class ObjectBuilder +public abstract class VirtualParadiseObjectBuilder { - private protected ObjectBuilder( + private protected VirtualParadiseObjectBuilder( VirtualParadiseClient client, VirtualParadiseObject targetObject, ObjectBuilderMode mode @@ -43,7 +43,7 @@ public abstract class ObjectBuilder /// This property may only be set during an object load, and will throw at /// any other point. /// - public Option Owner { get; set; } + public Option Owner { get; set; } /// /// Gets or sets the position of the object. @@ -90,7 +90,7 @@ public abstract class ObjectBuilder throw new InvalidOperationException("Owner can only be assigned during an object load."); } - IUser oldOwner = TargetObject.Owner; + VirtualParadiseUser oldOwner = TargetObject.Owner; _ = vp_int_set(handle, ObjectUserId, Owner.ValueOr(oldOwner).Id); } diff --git a/VpSharp/src/Entities/ParticleEmitterObject.cs b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs similarity index 94% rename from VpSharp/src/Entities/ParticleEmitterObject.cs rename to VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs index 0f69353..d2d2090 100644 --- a/VpSharp/src/Entities/ParticleEmitterObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObject.cs @@ -13,15 +13,15 @@ namespace VpSharp.Entities; /// /// Represents a particle emitter object. /// -public sealed class ParticleEmitterObject : VirtualParadiseObject +public sealed class VirtualParadiseParticleEmitterObject : VirtualParadiseObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The owning client. /// The object ID. /// is . - internal ParticleEmitterObject(VirtualParadiseClient client, int id) + internal VirtualParadiseParticleEmitterObject(VirtualParadiseClient client, int id) : base(client, id) { } @@ -217,13 +217,13 @@ public sealed class ParticleEmitterObject : VirtualParadiseObject /// protected internal override void ExtractFromOther(VirtualParadiseObject virtualParadiseObject) { - if (virtualParadiseObject is not ParticleEmitterObject emitter) + if (virtualParadiseObject is not VirtualParadiseParticleEmitterObject emitter) { return; } const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - PropertyInfo[] properties = typeof(ParticleEmitterObject).GetProperties(bindingFlags); + PropertyInfo[] properties = typeof(VirtualParadiseParticleEmitterObject).GetProperties(bindingFlags); foreach (PropertyInfo property in properties) { @@ -243,7 +243,7 @@ public sealed class ParticleEmitterObject : VirtualParadiseObject #pragma warning disable 612 const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; - PropertyInfo[] properties = typeof(ParticleEmitterObject).GetProperties(bindingFlags); + PropertyInfo[] properties = typeof(VirtualParadiseParticleEmitterObject).GetProperties(bindingFlags); var keymap = new Dictionary(); var converterMap = new Dictionary(); diff --git a/VpSharp/src/Entities/ParticleEmitterObjectBuilder.cs b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObjectBuilder.cs similarity index 85% rename from VpSharp/src/Entities/ParticleEmitterObjectBuilder.cs rename to VpSharp/src/Entities/VirtualParadiseParticleEmitterObjectBuilder.cs index ad1b8e9..0b357eb 100644 --- a/VpSharp/src/Entities/ParticleEmitterObjectBuilder.cs +++ b/VpSharp/src/Entities/VirtualParadiseParticleEmitterObjectBuilder.cs @@ -11,13 +11,13 @@ using VpSharp.Internal.ValueConverters; namespace VpSharp.Entities; /// -/// Provides mutability for a . +/// Provides mutability for a . /// -public sealed class ParticleEmitterObjectBuilder : ObjectBuilder +public sealed class VirtualParadiseParticleEmitterObjectBuilder : VirtualParadiseObjectBuilder { - internal ParticleEmitterObjectBuilder( + internal VirtualParadiseParticleEmitterObjectBuilder( VirtualParadiseClient client, - ParticleEmitterObject targetObject, + VirtualParadiseParticleEmitterObject targetObject, ObjectBuilderMode mode ) : base(client, targetObject, mode) @@ -220,7 +220,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum volume, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithAccelerationMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithAccelerationMax(Option value) { AccelerationMax = value; return this; @@ -231,7 +231,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum acceleration, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithAccelerationMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithAccelerationMin(Option value) { AccelerationMin = value; return this; @@ -242,7 +242,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The blend mode, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithBlendMode(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithBlendMode(Option value) { BlendMode = value; return this; @@ -253,7 +253,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum color, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithColorMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithColorMax(Option value) { ColorMax = value; return this; @@ -264,7 +264,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum color, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithColorMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithColorMin(Option value) { ColorMin = value; return this; @@ -275,7 +275,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The emitter lifespan, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithEmitterLifespan(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithEmitterLifespan(Option value) { EmitterLifespan = value; return this; @@ -289,7 +289,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// to leave unchanged. /// /// The current instance. - public ParticleEmitterObjectBuilder WithInterpolation(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithInterpolation(Option value) { Interpolate = value; return this; @@ -300,7 +300,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The opacity, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithOpacity(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithOpacity(Option value) { Opacity = value; return this; @@ -311,7 +311,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The particle lifespan, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithParticleLifespan(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithParticleLifespan(Option value) { ParticleLifespan = value; return this; @@ -322,7 +322,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The particle type, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithParticleType(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithParticleType(Option value) { ParticleType = value; return this; @@ -333,7 +333,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The release count, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithReleaseCount(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithReleaseCount(Option value) { ReleaseCount = value; return this; @@ -344,7 +344,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The release time, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithReleaseTime(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithReleaseTime(Option value) { ReleaseTime = value; return this; @@ -355,7 +355,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum size, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSizeMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSizeMax(Option value) { SizeMax = value; return this; @@ -366,7 +366,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum size, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSizeMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSizeMin(Option value) { SizeMin = value; return this; @@ -377,7 +377,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum speed, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSpeedMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSpeedMax(Option value) { SpeedMax = value; return this; @@ -388,7 +388,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum speed, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSpeedMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSpeedMin(Option value) { SpeedMin = value; return this; @@ -399,7 +399,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum spin, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSpinMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSpinMax(Option value) { SpinMax = value; return this; @@ -410,7 +410,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum spin, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithSpinMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithSpinMin(Option value) { SpinMin = value; return this; @@ -421,7 +421,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum start angle, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithStartAngleMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithStartAngleMax(Option value) { StartAngleMax = value; return this; @@ -432,7 +432,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum start angle, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithStartAngleMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithStartAngleMin(Option value) { StartAngleMin = value; return this; @@ -443,7 +443,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The maximum volume, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithVolumeMax(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithVolumeMax(Option value) { VolumeMax = value; return this; @@ -454,7 +454,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The minimum volume, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithVolumeMin(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithVolumeMin(Option value) { VolumeMin = value; return this; @@ -465,7 +465,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The tag, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithTag(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithTag(Option value) { Tag = value; return this; @@ -476,7 +476,7 @@ public sealed class ParticleEmitterObjectBuilder : ObjectBuilder /// /// The texture, or to leave unchanged. /// The current instance. - public ParticleEmitterObjectBuilder WithTexture(Option value) + public VirtualParadiseParticleEmitterObjectBuilder WithTexture(Option value) { Texture = value; return this; diff --git a/VpSharp/src/Entities/Path.cs b/VpSharp/src/Entities/VirtualParadisePath.cs similarity index 75% rename from VpSharp/src/Entities/Path.cs rename to VpSharp/src/Entities/VirtualParadisePath.cs index 5e8529c..26b7adb 100644 --- a/VpSharp/src/Entities/Path.cs +++ b/VpSharp/src/Entities/VirtualParadisePath.cs @@ -1,11 +1,11 @@ namespace VpSharp.Entities; /// -/// Represents a path contained by a . +/// Represents a path contained by a . /// -public sealed class Path : ICloneable +public sealed class VirtualParadisePath : ICloneable { - internal Path(PathEasing easing, string name, IEnumerable points, bool isClosed) + internal VirtualParadisePath(PathEasing easing, string name, IEnumerable points, bool isClosed) { Easing = easing; Name = name; @@ -40,6 +40,6 @@ public sealed class Path : ICloneable /// public object Clone() { - return new Path(Easing, Name, Points, IsClosed); + return new VirtualParadisePath(Easing, Name, Points, IsClosed); } } diff --git a/VpSharp/src/Entities/PathObject.cs b/VpSharp/src/Entities/VirtualParadisePathObject.cs similarity index 91% rename from VpSharp/src/Entities/PathObject.cs rename to VpSharp/src/Entities/VirtualParadisePathObject.cs index 795a370..76298fb 100644 --- a/VpSharp/src/Entities/PathObject.cs +++ b/VpSharp/src/Entities/VirtualParadisePathObject.cs @@ -9,15 +9,15 @@ namespace VpSharp.Entities; /// /// Represents a path object. /// -public sealed class PathObject : VirtualParadiseObject +public sealed class VirtualParadisePathObject : VirtualParadiseObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The owning client. /// The object ID. /// is . - internal PathObject(VirtualParadiseClient client, int id) + internal VirtualParadisePathObject(VirtualParadiseClient client, int id) : base(client, id) { } @@ -26,17 +26,17 @@ public sealed class PathObject : VirtualParadiseObject /// Gets the path in this object. /// /// The path in this object. - public Path Path { get; set; } = null!; + public VirtualParadisePath Path { get; set; } = null!; /// protected internal override void ExtractFromOther(VirtualParadiseObject virtualParadiseObject) { - if (virtualParadiseObject is not PathObject path) + if (virtualParadiseObject is not VirtualParadisePathObject path) { return; } - Path = (Path)path.Path.Clone(); + Path = (VirtualParadisePath)path.Path.Clone(); } /// @@ -92,7 +92,7 @@ public sealed class PathObject : VirtualParadiseObject buffer.Append(current); } - Path = new Path((PathEasing)pathType, name, points, closed == 1); + Path = new VirtualParadisePath((PathEasing)pathType, name, points, closed == 1); buffer.Dispose(); } diff --git a/VpSharp/src/Entities/User.cs b/VpSharp/src/Entities/VirtualParadiseUser.cs similarity index 90% rename from VpSharp/src/Entities/User.cs rename to VpSharp/src/Entities/VirtualParadiseUser.cs index f4c417e..3dd8723 100644 --- a/VpSharp/src/Entities/User.cs +++ b/VpSharp/src/Entities/VirtualParadiseUser.cs @@ -8,11 +8,11 @@ namespace VpSharp.Entities; /// /// Represents a Virtual Paradise user. /// -public sealed class User : IEquatable, IUser +public sealed class VirtualParadiseUser : IEquatable { private readonly VirtualParadiseClient _client; - internal User(VirtualParadiseClient client, int id) + internal VirtualParadiseUser(VirtualParadiseClient client, int id) { _client = client; Id = id; @@ -55,7 +55,7 @@ public sealed class User : IEquatable, IUser public DateTimeOffset RegistrationTime { get; internal set; } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The first instance. /// The second instance. @@ -63,13 +63,13 @@ public sealed class User : IEquatable, IUser /// if is equal to ; otherwise, /// . /// - public static bool operator ==(User? left, User? right) + public static bool operator ==(VirtualParadiseUser? left, VirtualParadiseUser? right) { return Equals(left, right); } /// - /// Determines if two instances are not equal. + /// Determines if two instances are not equal. /// /// The first instance. /// The second instance. @@ -77,19 +77,19 @@ public sealed class User : IEquatable, IUser /// if is not equal to ; otherwise, /// . /// - public static bool operator !=(User? left, User? right) + public static bool operator !=(VirtualParadiseUser? left, VirtualParadiseUser? right) { return !Equals(left, right); } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The other instance. /// /// if this instance is equal to ; otherwise, . /// - public bool Equals(User? other) + public bool Equals(VirtualParadiseUser? other) { if (ReferenceEquals(null, other)) { @@ -107,7 +107,7 @@ public sealed class User : IEquatable, IUser /// public override bool Equals(object? obj) { - return ReferenceEquals(this, obj) || (obj is User other && Equals(other)); + return ReferenceEquals(this, obj) || (obj is VirtualParadiseUser other && Equals(other)); } /// @@ -214,7 +214,7 @@ public sealed class User : IEquatable, IUser var position = new Vector3d(x, y, z); var rotation = Rotation.CreateFromTiltYawRoll(pitch, yaw, 0); - World world = (await _client.GetWorldAsync(worldName).ConfigureAwait(false))!; + VirtualParadiseWorld world = (await _client.GetWorldAsync(worldName).ConfigureAwait(false))!; location = new Location(world, position, rotation); diff --git a/VpSharp/src/Entities/World.cs b/VpSharp/src/Entities/VirtualParadiseWorld.cs similarity index 81% rename from VpSharp/src/Entities/World.cs rename to VpSharp/src/Entities/VirtualParadiseWorld.cs index eef5e3a..1b69508 100644 --- a/VpSharp/src/Entities/World.cs +++ b/VpSharp/src/Entities/VirtualParadiseWorld.cs @@ -5,16 +5,16 @@ namespace VpSharp.Entities; /// /// Represents a world in the Virtual Paradise universe. /// -public sealed class World : IEquatable +public sealed class VirtualParadiseWorld : IEquatable { /// /// A world that represents no world in the universe. /// - public static readonly World Nowhere = new(null!, "") {IsNowhere = true}; + public static readonly VirtualParadiseWorld Nowhere = new(null!, "") {IsNowhere = true}; private readonly VirtualParadiseClient _client; - internal World(VirtualParadiseClient client, string name) + internal VirtualParadiseWorld(VirtualParadiseClient client, string name) { _client = client; Name = name ?? throw new ArgumentNullException(nameof(name)); @@ -53,7 +53,7 @@ public sealed class World : IEquatable internal bool IsNowhere { get; private init; } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The first instance. /// The second instance. @@ -61,13 +61,13 @@ public sealed class World : IEquatable /// if is equal to ; otherwise, /// . /// - public static bool operator ==(World? left, World? right) + public static bool operator ==(VirtualParadiseWorld? left, VirtualParadiseWorld? right) { return Equals(left, right); } /// - /// Determines if two instances are not equal. + /// Determines if two instances are not equal. /// /// The first instance. /// The second instance. @@ -75,19 +75,19 @@ public sealed class World : IEquatable /// if is not equal to ; otherwise, /// . /// - public static bool operator !=(World? left, World? right) + public static bool operator !=(VirtualParadiseWorld? left, VirtualParadiseWorld? right) { return !Equals(left, right); } /// - /// Determines if two instances are equal. + /// Determines if two instances are equal. /// /// The other instance. /// /// if this instance is equal to ; otherwise, . /// - public bool Equals(World? other) + public bool Equals(VirtualParadiseWorld? other) { if (ReferenceEquals(null, other)) { @@ -105,7 +105,7 @@ public sealed class World : IEquatable /// public override bool Equals(object? obj) { - return ReferenceEquals(this, obj) || (obj is World other && Equals(other)); + return ReferenceEquals(this, obj) || (obj is VirtualParadiseWorld other && Equals(other)); } /// diff --git a/VpSharp/src/EventData/AvatarClickedEventArgs.cs b/VpSharp/src/EventData/AvatarClickedEventArgs.cs index 85836ce..ebf9e02 100644 --- a/VpSharp/src/EventData/AvatarClickedEventArgs.cs +++ b/VpSharp/src/EventData/AvatarClickedEventArgs.cs @@ -13,7 +13,7 @@ public sealed class AvatarClickedEventArgs : EventArgs /// The avatar responsible for the click. /// The clicked avatar. /// The click point. - public AvatarClickedEventArgs(IAvatar avatar, IAvatar clickedAvatar, Vector3d clickPoint) + public AvatarClickedEventArgs(VirtualParadiseAvatar avatar, VirtualParadiseAvatar clickedAvatar, Vector3d clickPoint) { Avatar = avatar; ClickedAvatar = clickedAvatar; @@ -24,13 +24,13 @@ public sealed class AvatarClickedEventArgs : EventArgs /// Gets the avatar responsible for the click. /// /// The avatar responsible for the click. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the clicked avatar. /// /// The clicked avatar. - public IAvatar ClickedAvatar { get; } + public VirtualParadiseAvatar ClickedAvatar { get; } /// /// Gets the point at which the avatar clicked the object. diff --git a/VpSharp/src/EventData/AvatarMovedEventArgs.cs b/VpSharp/src/EventData/AvatarMovedEventArgs.cs index 6f2b6e7..6c85cb8 100644 --- a/VpSharp/src/EventData/AvatarMovedEventArgs.cs +++ b/VpSharp/src/EventData/AvatarMovedEventArgs.cs @@ -13,7 +13,7 @@ public sealed class AvatarMovedEventArgs : EventArgs /// The avatar whose type was changed. /// The avatar's new location. /// The avatar's old location. - public AvatarMovedEventArgs(IAvatar avatar, Location locationAfter, Location? locationBefore) + public AvatarMovedEventArgs(VirtualParadiseAvatar avatar, Location locationAfter, Location? locationBefore) { Avatar = avatar; LocationAfter = locationAfter; @@ -24,7 +24,7 @@ public sealed class AvatarMovedEventArgs : EventArgs /// Gets the avatar whose location was changed. /// /// The avatar whose location was changed. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the avatar's location after the change. diff --git a/VpSharp/src/EventData/AvatarTypeChangedEventArgs.cs b/VpSharp/src/EventData/AvatarTypeChangedEventArgs.cs index 0a2d0c9..ec58b3b 100644 --- a/VpSharp/src/EventData/AvatarTypeChangedEventArgs.cs +++ b/VpSharp/src/EventData/AvatarTypeChangedEventArgs.cs @@ -13,7 +13,7 @@ public sealed class AvatarTypeChangedEventArgs : EventArgs /// The avatar whose type was changed. /// The avatar's new type. /// The avatar's old type. - public AvatarTypeChangedEventArgs(IAvatar avatar, int typeAfter, int? typeBefore) + public AvatarTypeChangedEventArgs(VirtualParadiseAvatar avatar, int typeAfter, int? typeBefore) { Avatar = avatar; TypeAfter = typeAfter; @@ -24,7 +24,7 @@ public sealed class AvatarTypeChangedEventArgs : EventArgs /// Gets the avatar whose type was changed. /// /// The avatar whose type was changed. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the avatar's type after the change. diff --git a/VpSharp/src/EventData/ObjectBumpEventArgs.cs b/VpSharp/src/EventData/ObjectBumpEventArgs.cs index ca0d5df..30fbc9d 100644 --- a/VpSharp/src/EventData/ObjectBumpEventArgs.cs +++ b/VpSharp/src/EventData/ObjectBumpEventArgs.cs @@ -13,7 +13,7 @@ public sealed class ObjectBumpEventArgs : EventArgs /// The avatar. /// The bumped object. /// The bump phase. - public ObjectBumpEventArgs(IAvatar avatar, VirtualParadiseObject bumpedObject, BumpPhase phase) + public ObjectBumpEventArgs(VirtualParadiseAvatar avatar, VirtualParadiseObject bumpedObject, BumpPhase phase) { Avatar = avatar; BumpedObject = bumpedObject; @@ -24,7 +24,7 @@ public sealed class ObjectBumpEventArgs : EventArgs /// Gets the avatar responsible for the bump. /// /// The avatar responsible for the bump. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the object to which this event pertains. diff --git a/VpSharp/src/EventData/ObjectChangedEventArgs.cs b/VpSharp/src/EventData/ObjectChangedEventArgs.cs index e1db7a1..dc9ad31 100644 --- a/VpSharp/src/EventData/ObjectChangedEventArgs.cs +++ b/VpSharp/src/EventData/ObjectChangedEventArgs.cs @@ -14,7 +14,7 @@ public sealed class ObjectChangedEventArgs : EventArgs /// The state of the object prior to the change. /// The object which was changed, containing updated values. public ObjectChangedEventArgs( - IAvatar avatar, + VirtualParadiseAvatar avatar, VirtualParadiseObject? objectBefore, VirtualParadiseObject objectAfter) { @@ -27,7 +27,7 @@ public sealed class ObjectChangedEventArgs : EventArgs /// Gets the avatar which changed the object. /// /// The avatar which changed the object. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the object which was changed. diff --git a/VpSharp/src/EventData/ObjectClickedEventArgs.cs b/VpSharp/src/EventData/ObjectClickedEventArgs.cs index f402d03..031bc64 100644 --- a/VpSharp/src/EventData/ObjectClickedEventArgs.cs +++ b/VpSharp/src/EventData/ObjectClickedEventArgs.cs @@ -14,7 +14,7 @@ public sealed class ObjectClickedEventArgs : EventArgs /// The clicked object. /// The click point. public ObjectClickedEventArgs( - IAvatar avatar, + VirtualParadiseAvatar avatar, VirtualParadiseObject clickedObject, Vector3d clickPoint) { @@ -27,7 +27,7 @@ public sealed class ObjectClickedEventArgs : EventArgs /// Gets the avatar responsible for the click. /// /// The avatar responsible for the click. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the clicked object. diff --git a/VpSharp/src/EventData/ObjectCreatedEventArgs.cs b/VpSharp/src/EventData/ObjectCreatedEventArgs.cs index dad9592..ccdab38 100644 --- a/VpSharp/src/EventData/ObjectCreatedEventArgs.cs +++ b/VpSharp/src/EventData/ObjectCreatedEventArgs.cs @@ -12,7 +12,7 @@ public sealed class ObjectCreatedEventArgs : EventArgs /// /// The avatar responsible for the object being created. /// The created object. - public ObjectCreatedEventArgs(IAvatar avatar, VirtualParadiseObject createdObject) + public ObjectCreatedEventArgs(VirtualParadiseAvatar avatar, VirtualParadiseObject createdObject) { Avatar = avatar; CreatedObject = createdObject; @@ -22,7 +22,7 @@ public sealed class ObjectCreatedEventArgs : EventArgs /// Gets the avatar responsible for the object being created. /// /// The avatar responsible for the object being created. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the object which was created. diff --git a/VpSharp/src/EventData/ObjectDeletedEventArgs.cs b/VpSharp/src/EventData/ObjectDeletedEventArgs.cs index eeddc8b..7e18f20 100644 --- a/VpSharp/src/EventData/ObjectDeletedEventArgs.cs +++ b/VpSharp/src/EventData/ObjectDeletedEventArgs.cs @@ -13,7 +13,7 @@ public sealed class ObjectDeletedEventArgs : EventArgs /// The avatar responsible for the object being deleted. /// The ID of the deleted object. /// The deleted object. - public ObjectDeletedEventArgs(IAvatar avatar, int objectId, VirtualParadiseObject deletedObject) + public ObjectDeletedEventArgs(VirtualParadiseAvatar avatar, int objectId, VirtualParadiseObject deletedObject) { Avatar = avatar; ObjectId = objectId; @@ -24,7 +24,7 @@ public sealed class ObjectDeletedEventArgs : EventArgs /// Gets the avatar responsible for the object being deleted. /// /// The avatar responsible for the object being deleted. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the object which was deleted. diff --git a/VpSharp/src/EventData/TeleportedEventArgs.cs b/VpSharp/src/EventData/TeleportedEventArgs.cs index 2400378..e42be54 100644 --- a/VpSharp/src/EventData/TeleportedEventArgs.cs +++ b/VpSharp/src/EventData/TeleportedEventArgs.cs @@ -12,7 +12,7 @@ public sealed class TeleportedEventArgs : EventArgs /// /// The avatar which initiated the teleport. /// The target location of the teleport. - public TeleportedEventArgs(IAvatar avatar, Location location) + public TeleportedEventArgs(VirtualParadiseAvatar avatar, Location location) { Avatar = avatar; Location = location; @@ -22,7 +22,7 @@ public sealed class TeleportedEventArgs : EventArgs /// Gets the avatar which initiated the teleport. /// /// The avatar which initiated the teleport. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the target location of the teleport. diff --git a/VpSharp/src/EventData/UriReceivedEventArgs.cs b/VpSharp/src/EventData/UriReceivedEventArgs.cs index d5bf0c4..6d4995b 100644 --- a/VpSharp/src/EventData/UriReceivedEventArgs.cs +++ b/VpSharp/src/EventData/UriReceivedEventArgs.cs @@ -13,7 +13,7 @@ public sealed class UriReceivedEventArgs : EventArgs /// The received URI. /// The URI target. /// The avatar who sent the URI. - public UriReceivedEventArgs(Uri uri, UriTarget target, IAvatar avatar) + public UriReceivedEventArgs(Uri uri, UriTarget target, VirtualParadiseAvatar avatar) { Uri = uri; Target = target; @@ -24,7 +24,7 @@ public sealed class UriReceivedEventArgs : EventArgs /// Gets the avatar who sent the URI. /// /// The avatar who sent the URI. - public IAvatar Avatar { get; } + public VirtualParadiseAvatar Avatar { get; } /// /// Gets the URI target. diff --git a/VpSharp/src/InviteRequest.cs b/VpSharp/src/InviteRequest.cs index aa13560..7fceff6 100644 --- a/VpSharp/src/InviteRequest.cs +++ b/VpSharp/src/InviteRequest.cs @@ -16,7 +16,7 @@ public sealed class InviteRequest : IEquatable VirtualParadiseClient client, int requestId, string name, - IUser user, + VirtualParadiseUser user, Location location) { Name = name; @@ -42,7 +42,7 @@ public sealed class InviteRequest : IEquatable /// Gets the user which sent the request. /// /// The user which sent the request. - public IUser User { get; } + public VirtualParadiseUser User { get; } /// /// Returns a value indicating whether two instances are equal. diff --git a/VpSharp/src/JoinRequest.cs b/VpSharp/src/JoinRequest.cs index 9bd935c..7e78ebb 100644 --- a/VpSharp/src/JoinRequest.cs +++ b/VpSharp/src/JoinRequest.cs @@ -12,7 +12,7 @@ public sealed class JoinRequest : IEquatable private readonly VirtualParadiseClient _client; private readonly int _requestId; - internal JoinRequest(VirtualParadiseClient client, int requestId, string name, IUser user) + internal JoinRequest(VirtualParadiseClient client, int requestId, string name, VirtualParadiseUser user) { Name = name; User = user; @@ -30,7 +30,7 @@ public sealed class JoinRequest : IEquatable /// Gets the user which sent the request. /// /// The user which sent the request. - public IUser User { get; } + public VirtualParadiseUser User { get; } /// /// Returns a value indicating whether two instances are equal. diff --git a/VpSharp/src/Location.cs b/VpSharp/src/Location.cs index bfdaae6..5598c18 100644 --- a/VpSharp/src/Location.cs +++ b/VpSharp/src/Location.cs @@ -10,7 +10,7 @@ public readonly struct Location : IEquatable /// /// A location that represents nowhere in the universe. /// - public static readonly Location Nowhere = new(Entities.World.Nowhere); + public static readonly Location Nowhere = new(VirtualParadiseWorld.Nowhere); /// /// Initializes a new instance of the struct. @@ -22,7 +22,7 @@ public readonly struct Location : IEquatable /// parameter. /// /// is . - public Location(World world, in Coordinates coordinates) + public Location(VirtualParadiseWorld world, in Coordinates coordinates) { World = world ?? throw new ArgumentNullException(nameof(world)); Position = new Vector3d(coordinates.X, coordinates.Y, coordinates.Z); @@ -36,7 +36,7 @@ public readonly struct Location : IEquatable /// The position. /// The rotation. /// is . - public Location(World world, Vector3d position = default, Rotation rotation = default) + public Location(VirtualParadiseWorld world, Vector3d position = default, Rotation rotation = default) { World = world ?? throw new ArgumentNullException(nameof(world)); Position = position; @@ -67,7 +67,7 @@ public readonly struct Location : IEquatable /// Gets the world represented by this location. /// /// The world. - public World World { get; init; } + public VirtualParadiseWorld World { get; init; } /// /// Determines if two instances are equal. diff --git a/VpSharp/src/MessageType.cs b/VpSharp/src/MessageType.cs new file mode 100644 index 0000000..b57dfbe --- /dev/null +++ b/VpSharp/src/MessageType.cs @@ -0,0 +1,17 @@ +namespace VpSharp; + +/// +/// An enumeration of message types. +/// +public enum MessageType +{ + /// + /// A chat message sent by an avatar. + /// + ChatMessage, + + /// + /// A console message sent by a bot. + /// + ConsoleMessage +} diff --git a/VpSharp/src/PathEasing.cs b/VpSharp/src/PathEasing.cs index 0d24c06..026994c 100644 --- a/VpSharp/src/PathEasing.cs +++ b/VpSharp/src/PathEasing.cs @@ -3,7 +3,7 @@ namespace VpSharp; /// -/// An enumeration of easings for use with . +/// An enumeration of easings for use with . /// public enum PathEasing { diff --git a/VpSharp/src/PathPoint.cs b/VpSharp/src/PathPoint.cs index 1f56f03..34d2e89 100644 --- a/VpSharp/src/PathPoint.cs +++ b/VpSharp/src/PathPoint.cs @@ -4,7 +4,7 @@ using VpSharp.Entities; namespace VpSharp; /// -/// Represents a point along a . +/// Represents a point along a . /// #pragma warning disable CA1815 public readonly struct PathPoint diff --git a/VpSharp/src/UriTarget.cs b/VpSharp/src/UriTarget.cs index 9b464db..6c73215 100644 --- a/VpSharp/src/UriTarget.cs +++ b/VpSharp/src/UriTarget.cs @@ -6,7 +6,7 @@ namespace VpSharp; /// An enumeration of URI targets. /// /// -/// When used with , indicates that that the URI +/// When used with , indicates that that the URI /// will be displayed as a 2D overlay over the 3D world view. This currently uses CEF (Chromium Embedded Framework). /// public enum UriTarget diff --git a/VpSharp/src/VirtualParadiseClient.Avatars.cs b/VpSharp/src/VirtualParadiseClient.Avatars.cs index 8bdeeaa..5c3f8f8 100644 --- a/VpSharp/src/VirtualParadiseClient.Avatars.cs +++ b/VpSharp/src/VirtualParadiseClient.Avatars.cs @@ -10,7 +10,7 @@ namespace VpSharp; public sealed partial class VirtualParadiseClient { - private readonly ConcurrentDictionary _avatars = new(); + private readonly ConcurrentDictionary _avatars = new(); /// /// Gets the avatar with the specified session. @@ -20,18 +20,18 @@ public sealed partial class VirtualParadiseClient /// The avatar whose session is equal to , or if no match was /// found. /// - public IAvatar? GetAvatar(int session) + public VirtualParadiseAvatar? GetAvatar(int session) { - _avatars.TryGetValue(session, out Avatar? avatar); + _avatars.TryGetValue(session, out VirtualParadiseAvatar? avatar); return avatar; } - private Avatar AddOrUpdateAvatar(Avatar avatar) + private VirtualParadiseAvatar AddOrUpdateAvatar(VirtualParadiseAvatar avatar) { return _avatars.AddOrUpdate(avatar.Session, avatar, (_, existing) => { // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract - existing ??= new Avatar(this, avatar.Session); + existing ??= new VirtualParadiseAvatar(this, avatar.Session); existing.Name = avatar.Name; existing.Location = avatar.Location; existing.Application = avatar.Application; @@ -41,7 +41,7 @@ public sealed partial class VirtualParadiseClient }); } - private Avatar ExtractAvatar(nint sender) + private VirtualParadiseAvatar ExtractAvatar(nint sender) { lock (Lock) { @@ -58,7 +58,7 @@ public sealed partial class VirtualParadiseClient string applicationVersion = vp_string(sender, StringAttribute.AvatarApplicationVersion); int session = vp_int(sender, IntegerAttribute.AvatarSession); - return new Avatar(this, session) + return new VirtualParadiseAvatar(this, session) { Name = vp_string(sender, StringAttribute.AvatarName), Location = new Location(CurrentWorld!, position, rotation), diff --git a/VpSharp/src/VirtualParadiseClient.Events.cs b/VpSharp/src/VirtualParadiseClient.Events.cs index dffb7bb..6e3f2ea 100644 --- a/VpSharp/src/VirtualParadiseClient.Events.cs +++ b/VpSharp/src/VirtualParadiseClient.Events.cs @@ -7,13 +7,13 @@ namespace VpSharp; public sealed partial class VirtualParadiseClient { private readonly Subject _avatarClicked = new(); - private readonly Subject _avatarJoined = new(); - private readonly Subject _avatarLeft = new(); + private readonly Subject _avatarJoined = new(); + private readonly Subject _avatarLeft = new(); private readonly Subject _avatarMoved = new(); private readonly Subject _avatarTypeChanged = new(); private readonly Subject _inviteRequestReceived = new(); private readonly Subject _joinRequestReceived = new(); - private readonly Subject _messageReceived = new(); + private readonly Subject _messageReceived = new(); private readonly Subject _objectBump = new(); private readonly Subject _objectChanged = new(); private readonly Subject _objectClicked = new(); @@ -35,7 +35,7 @@ public sealed partial class VirtualParadiseClient /// /// Occurs when an avatar has entered the vicinity of the client. /// - public IObservable AvatarJoined + public IObservable AvatarJoined { get => _avatarJoined; } @@ -43,7 +43,7 @@ public sealed partial class VirtualParadiseClient /// /// Occurs when an avatar has left the vicinity of the client. /// - public IObservable AvatarLeft + public IObservable AvatarLeft { get => _avatarLeft; } @@ -83,7 +83,7 @@ public sealed partial class VirtualParadiseClient /// /// Occurs when a chat message or console message has been received. /// - public IObservable MessageReceived + public IObservable MessageReceived { get => _messageReceived; } diff --git a/VpSharp/src/VirtualParadiseClient.NativeEvents.cs b/VpSharp/src/VirtualParadiseClient.NativeEvents.cs index 863287c..e45ef4b 100644 --- a/VpSharp/src/VirtualParadiseClient.NativeEvents.cs +++ b/VpSharp/src/VirtualParadiseClient.NativeEvents.cs @@ -52,7 +52,7 @@ public sealed partial class VirtualParadiseClient private void OnChatNativeEvent(nint sender) { - IMessage message; + VirtualParadiseMessage message; lock (Lock) { @@ -61,7 +61,6 @@ public sealed partial class VirtualParadiseClient string content = vp_string(sender, StringAttribute.ChatMessage); int type = vp_int(sender, IntegerAttribute.ChatType); - IAvatar avatar = GetAvatar(session)!; Color color = Color.Black; var style = FontStyle.Regular; @@ -73,12 +72,10 @@ public sealed partial class VirtualParadiseClient int b = vp_int(sender, IntegerAttribute.ChatColorBlue); color = Color.FromArgb(r, g, b); style = (FontStyle)vp_int(sender, IntegerAttribute.ChatEffects); - message = new ConsoleMessage(avatar, name, content, color, style); - } - else - { - message = new UserMessage(avatar, content); } + + VirtualParadiseAvatar avatar = GetAvatar(session)!; + message = new VirtualParadiseMessage((MessageType)type, name, content, avatar, style, color); } _messageReceived.OnNext(message); @@ -91,7 +88,7 @@ public sealed partial class VirtualParadiseClient private void OnAvatarAddNativeEvent(nint sender) { - Avatar avatar = ExtractAvatar(sender); + VirtualParadiseAvatar avatar = ExtractAvatar(sender); avatar = AddOrUpdateAvatar(avatar); _avatarJoined.OnNext(avatar); } @@ -118,7 +115,7 @@ public sealed partial class VirtualParadiseClient rotation = Rotation.CreateFromTiltYawRoll(pitch, yaw, 0); } - var avatar = (Avatar)GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; if (type != avatar.Type) { int oldType = avatar.Type; @@ -148,8 +145,8 @@ public sealed partial class VirtualParadiseClient session = vp_int(sender, IntegerAttribute.AvatarSession); } - IAvatar avatar = GetAvatar(session)!; - _avatars.TryRemove(session, out Avatar _); + VirtualParadiseAvatar avatar = GetAvatar(session)!; + _avatars.TryRemove(session, out VirtualParadiseAvatar _); _avatarLeft.OnNext(avatar); } @@ -176,7 +173,7 @@ public sealed partial class VirtualParadiseClient } else { - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; var args = new ObjectCreatedEventArgs(avatar, virtualParadiseObject); _objectCreated.OnNext(args); } @@ -193,7 +190,7 @@ public sealed partial class VirtualParadiseClient session = vp_int(sender, IntegerAttribute.AvatarSession); } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; VirtualParadiseObject? cachedObject = null; if (_objects.TryGetValue(objectId, out VirtualParadiseObject? virtualParadiseObject)) @@ -229,7 +226,7 @@ public sealed partial class VirtualParadiseClient session = vp_int(sender, IntegerAttribute.AvatarSession); } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar? avatar = GetAvatar(session); VirtualParadiseObject? virtualParadiseObject; try @@ -243,7 +240,7 @@ public sealed partial class VirtualParadiseClient _objects.TryRemove(objectId, out VirtualParadiseObject _); - var args = new ObjectDeletedEventArgs(avatar, objectId, virtualParadiseObject!); + var args = new ObjectDeletedEventArgs(avatar!, objectId, virtualParadiseObject!); _objectDeleted.OnNext(args); } @@ -264,7 +261,7 @@ public sealed partial class VirtualParadiseClient clickPoint = new Vector3d(x, y, z); } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; try { VirtualParadiseObject virtualParadiseObject = await GetObjectAsync(objectId).ConfigureAwait(false); @@ -279,7 +276,7 @@ public sealed partial class VirtualParadiseClient private async void OnWorldListNativeEvent(nint sender) { - World world; + VirtualParadiseWorld world; string name; int avatarCount; WorldState state; @@ -290,7 +287,7 @@ public sealed partial class VirtualParadiseClient avatarCount = vp_int(sender, IntegerAttribute.WorldUsers); state = (WorldState)vp_int(sender, IntegerAttribute.WorldState); - world = new World(this, name) { AvatarCount = avatarCount, State = state }; + world = new VirtualParadiseWorld(this, name) { AvatarCount = avatarCount, State = state }; _worlds[name] = world; } @@ -335,7 +332,7 @@ public sealed partial class VirtualParadiseClient userId = vp_int(sender, IntegerAttribute.FriendUserId); } - var user = (User)await GetUserAsync(userId).ConfigureAwait(false); + VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false); _friends.AddOrUpdate(userId, user, (_, _) => user); } @@ -364,7 +361,7 @@ public sealed partial class VirtualParadiseClient private void OnUserAttributesNativeEvent(nint sender) { int userId; - User user; + VirtualParadiseUser user; lock (Lock) { @@ -376,7 +373,7 @@ public sealed partial class VirtualParadiseClient int onlineTime = vp_int(sender, IntegerAttribute.UserOnlineTime); int registered = vp_int(sender, IntegerAttribute.UserRegistrationTime); - user = new User(this, userId) + user = new VirtualParadiseUser(this, userId) { Name = name, EmailAddress = email, @@ -386,7 +383,7 @@ public sealed partial class VirtualParadiseClient }; } - if (_usersCompletionSources.TryGetValue(userId, out TaskCompletionSource? taskCompletionSource)) + if (_usersCompletionSources.TryGetValue(userId, out TaskCompletionSource? taskCompletionSource)) { taskCompletionSource.SetResult(user); } @@ -426,8 +423,8 @@ public sealed partial class VirtualParadiseClient clickPoint = new Vector3d(x, y, z); } - IAvatar avatar = GetAvatar(session)!; - IAvatar clickedAvatar = GetAvatar(clickedSession)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar clickedAvatar = GetAvatar(clickedSession)!; var args = new AvatarClickedEventArgs(avatar, clickedAvatar, clickPoint); _avatarClicked.OnNext(args); } @@ -455,13 +452,13 @@ public sealed partial class VirtualParadiseClient worldName = vp_string(sender, StringAttribute.TeleportWorld); } - World world = (string.IsNullOrWhiteSpace(worldName) + VirtualParadiseWorld world = (string.IsNullOrWhiteSpace(worldName) ? CurrentWorld : await GetWorldAsync(worldName).ConfigureAwait(false))!; var location = new Location(world, position, rotation); - ((Avatar)CurrentAvatar!).Location = location; - IAvatar avatar = GetAvatar(session)!; + CurrentAvatar!.Location = location; + VirtualParadiseAvatar avatar = GetAvatar(session)!; var args = new TeleportedEventArgs(avatar, location); _teleported.OnNext(args); } @@ -477,7 +474,7 @@ public sealed partial class VirtualParadiseClient objectId = vp_int(sender, IntegerAttribute.ObjectId); } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; try { var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false); @@ -508,7 +505,7 @@ public sealed partial class VirtualParadiseClient return; } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; var uri = new Uri(url); var args = new UriReceivedEventArgs(uri, target, avatar); _uriReceived.OnNext(args); @@ -525,7 +522,7 @@ public sealed partial class VirtualParadiseClient objectId = vp_int(sender, IntegerAttribute.ObjectId); } - IAvatar avatar = GetAvatar(session)!; + VirtualParadiseAvatar avatar = GetAvatar(session)!; try { var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false); @@ -551,7 +548,7 @@ public sealed partial class VirtualParadiseClient name = vp_string(NativeInstanceHandle, StringAttribute.JoinName); } - IUser user = await GetUserAsync(userId).ConfigureAwait(false); + VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false); var joinRequest = new JoinRequest(this, requestId, name, user); _joinRequestReceived.OnNext(joinRequest); } @@ -584,8 +581,8 @@ public sealed partial class VirtualParadiseClient worldName = vp_string(sender, StringAttribute.InviteWorld); } - World world = (await GetWorldAsync(worldName).ConfigureAwait(false))!; - IUser user = await GetUserAsync(userId).ConfigureAwait(false); + VirtualParadiseWorld world = (await GetWorldAsync(worldName).ConfigureAwait(false))!; + VirtualParadiseUser user = await GetUserAsync(userId).ConfigureAwait(false); var location = new Location(world, position, rotation); var request = new InviteRequest(this, requestId, avatarName, user, location); diff --git a/VpSharp/src/VirtualParadiseClient.Objects.cs b/VpSharp/src/VirtualParadiseClient.Objects.cs index d3d8dff..61c1b02 100644 --- a/VpSharp/src/VirtualParadiseClient.Objects.cs +++ b/VpSharp/src/VirtualParadiseClient.Objects.cs @@ -214,9 +214,9 @@ public sealed partial class VirtualParadiseClient VirtualParadiseObject virtualParadiseObject = type switch { - ObjectType.Model => new ModelObject(this, id), - ObjectType.ParticleEmitter => new ParticleEmitterObject(this, id), - ObjectType.Path => new PathObject(this, id), + ObjectType.Model => new VirtualParadiseModelObject(this, id), + ObjectType.ParticleEmitter => new VirtualParadiseParticleEmitterObject(this, id), + ObjectType.Path => new VirtualParadisePathObject(this, id), _ => throw new NotSupportedException(ExceptionMessages.UnsupportedObjectType) }; diff --git a/VpSharp/src/VirtualParadiseClient.Users.cs b/VpSharp/src/VirtualParadiseClient.Users.cs index 2fe64cd..286d9af 100644 --- a/VpSharp/src/VirtualParadiseClient.Users.cs +++ b/VpSharp/src/VirtualParadiseClient.Users.cs @@ -6,8 +6,8 @@ namespace VpSharp; public sealed partial class VirtualParadiseClient { - private readonly ConcurrentDictionary _users = new(); - private readonly ConcurrentDictionary> _usersCompletionSources = new(); + private readonly ConcurrentDictionary _users = new(); + private readonly ConcurrentDictionary> _usersCompletionSources = new(); /// /// Gets a user by their ID. @@ -16,19 +16,19 @@ public sealed partial class VirtualParadiseClient /// /// The user whose ID is equal to , or if no match was found. /// - public async Task GetUserAsync(int userId) + public async Task GetUserAsync(int userId) { - if (_users.TryGetValue(userId, out User? user)) + if (_users.TryGetValue(userId, out VirtualParadiseUser? user)) { return user; } - if (_usersCompletionSources.TryGetValue(userId, out TaskCompletionSource? taskCompletionSource)) + if (_usersCompletionSources.TryGetValue(userId, out TaskCompletionSource? taskCompletionSource)) { return await taskCompletionSource.Task.ConfigureAwait(false); } - taskCompletionSource = new TaskCompletionSource(); + taskCompletionSource = new TaskCompletionSource(); _usersCompletionSources.TryAdd(userId, taskCompletionSource); lock (Lock) @@ -39,16 +39,16 @@ public sealed partial class VirtualParadiseClient user = await taskCompletionSource.Task.ConfigureAwait(false); user = AddOrUpdateUser(user); - _usersCompletionSources.TryRemove(userId, out TaskCompletionSource _); + _usersCompletionSources.TryRemove(userId, out TaskCompletionSource _); return user; } - private User AddOrUpdateUser(User user) + private VirtualParadiseUser AddOrUpdateUser(VirtualParadiseUser user) { return _users.AddOrUpdate(user.Id, user, (_, existing) => { // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract - existing ??= new User(this, user.Id); + existing ??= new VirtualParadiseUser(this, user.Id); existing.Name = user.Name; existing.EmailAddress = user.EmailAddress; existing.LastLogin = user.LastLogin; diff --git a/VpSharp/src/VirtualParadiseClient.Worlds.cs b/VpSharp/src/VirtualParadiseClient.Worlds.cs index 14111b4..66bb6a3 100644 --- a/VpSharp/src/VirtualParadiseClient.Worlds.cs +++ b/VpSharp/src/VirtualParadiseClient.Worlds.cs @@ -8,22 +8,22 @@ namespace VpSharp; public sealed partial class VirtualParadiseClient { private readonly ConcurrentDictionary _worldSettings = new(); - private readonly ConcurrentDictionary _worlds = new(); - private Channel? _worldListChannel = Channel.CreateUnbounded(); + private readonly ConcurrentDictionary _worlds = new(); + private Channel? _worldListChannel = Channel.CreateUnbounded(); private TaskCompletionSource _worldSettingsCompletionSource = new(); /// /// Gets an enumerable of the worlds returned by the universe server. /// - /// An containing values. + /// An containing values. /// /// This method will yield results back as they are received from the world server. To access a consumed collection, /// use . /// /// - public IAsyncEnumerable EnumerateWorldsAsync() + public IAsyncEnumerable EnumerateWorldsAsync() { - _worldListChannel = Channel.CreateUnbounded(); + _worldListChannel = Channel.CreateUnbounded(); lock (Lock) { _ = vp_world_list(NativeInstanceHandle, 0); @@ -37,20 +37,20 @@ public sealed partial class VirtualParadiseClient /// /// The name of the world. /// - /// A whose name is equal to , or + /// A whose name is equal to , or /// if no match was found. /// /// /// is , empty, or consists of only whitespace. /// - public async Task GetWorldAsync(string name) + public async Task GetWorldAsync(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException(ExceptionMessages.WorldNameCannotBeEmpty, nameof(name)); } - await foreach (World world in EnumerateWorldsAsync()) + await foreach (VirtualParadiseWorld world in EnumerateWorldsAsync()) { if (string.Equals(world.Name, name, StringComparison.Ordinal)) { @@ -64,18 +64,18 @@ public sealed partial class VirtualParadiseClient /// /// Gets a read-only view of the worlds returned by the universe server. /// - /// An containing values. + /// An containing values. /// /// This method will consume the list in full before returning, and therefore can result in apparent "hang" while the /// list is being fetched. For an alternative, use /// . /// /// - public async Task> GetWorldsAsync() + public async Task> GetWorldsAsync() { - var worlds = new List(); + var worlds = new List(); - await foreach (World world in EnumerateWorldsAsync()) + await foreach (VirtualParadiseWorld world in EnumerateWorldsAsync()) { worlds.Add(world); } diff --git a/VpSharp/src/VirtualParadiseClient.cs b/VpSharp/src/VirtualParadiseClient.cs index c32b22d..d926787 100644 --- a/VpSharp/src/VirtualParadiseClient.cs +++ b/VpSharp/src/VirtualParadiseClient.cs @@ -24,7 +24,7 @@ public sealed partial class VirtualParadiseClient : IDisposable private readonly VirtualParadiseConfiguration _configuration; - private readonly ConcurrentDictionary _friends = new(); + private readonly ConcurrentDictionary _friends = new(); private readonly Dictionary> _inviteCompletionSources = new(); private readonly Dictionary> _joinCompletionSources = new(); @@ -66,7 +66,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Gets a read-only view of the cached avatars. /// /// The cached avatars. - public IReadOnlyList Avatars + public IReadOnlyList Avatars { get => _avatars.Values.ToArray(); } @@ -75,17 +75,17 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Gets the current avatar associated with this client. /// /// - /// An instance of , or if this client is not in a world. + /// An instance of , or if this client is not in a world. /// - public IAvatar? CurrentAvatar { get; internal set; } + public VirtualParadiseAvatar? CurrentAvatar { get; internal set; } /// /// Gets the current user to which this client is logged in. /// /// - /// An instance of , or if this client is not logged in. + /// An instance of , or if this client is not logged in. /// - public IUser? CurrentUser { get; internal set; } + public VirtualParadiseUser? CurrentUser { get; internal set; } /// /// Gets the world to which this client is currently connected. @@ -94,7 +94,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// The world to which this client is currently connected, or if this client is not currently /// in a world. /// - public World? CurrentWorld + public VirtualParadiseWorld? CurrentWorld { get => CurrentAvatar?.Location.World; } @@ -109,7 +109,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Gets a read-only view of the cached worlds. /// /// The cached worlds. - public IReadOnlyList Worlds + public IReadOnlyList Worlds { get => _worlds.Values.ToArray(); } @@ -225,7 +225,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(string worldName, Vector3d position) + public async Task EnterAsync(string worldName, Vector3d position) { await EnterAsync(worldName).ConfigureAwait(false); await CurrentAvatar!.TeleportAsync(position, Rotation.None).ConfigureAwait(false); @@ -245,7 +245,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(string worldName, Vector3d position, Rotation rotation) + public async Task EnterAsync(string worldName, Vector3d position, Rotation rotation) { await EnterAsync(worldName).ConfigureAwait(false); await CurrentAvatar!.TeleportAsync(position, rotation).ConfigureAwait(false); @@ -264,7 +264,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(World world, Vector3d position) + public async Task EnterAsync(VirtualParadiseWorld world, Vector3d position) { await EnterAsync(world).ConfigureAwait(false); await CurrentAvatar!.TeleportAsync(position, Rotation.None).ConfigureAwait(false); @@ -283,7 +283,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(World world, Vector3d position, Rotation rotation) + public async Task EnterAsync(VirtualParadiseWorld world, Vector3d position, Rotation rotation) { await EnterAsync(world).ConfigureAwait(false); await CurrentAvatar!.TeleportAsync(position, rotation).ConfigureAwait(false); @@ -300,7 +300,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(World world) + public async Task EnterAsync(VirtualParadiseWorld world) { if (world is null) { @@ -314,7 +314,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Enters a specified world. /// /// The world to enter. - /// A representing the world. + /// A representing the world. /// is . /// /// A world enter was attempted before the client was connected to a universe. @@ -323,7 +323,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// Connection to the universe server was lost, or connecting to the world failed. /// The specified world was not found. /// Connection to the world server timed out. - public async Task EnterAsync(string worldName) + public async Task EnterAsync(string worldName) { if (worldName is null) { @@ -389,22 +389,21 @@ public sealed partial class VirtualParadiseClient : IDisposable await _worldSettingsCompletionSource.Task.ConfigureAwait(false); - World? world = await GetWorldAsync(worldName).ConfigureAwait(false); + VirtualParadiseWorld? world = await GetWorldAsync(worldName).ConfigureAwait(false); if (world is null) { // we entered the world but it wasn't listed. unlisted world. we'll try our best to create details for it - world = new World(this, worldName); + world = new VirtualParadiseWorld(this, worldName); } if (CurrentAvatar is not null) { - // TODO why is this here? we reassign CurrentAvatar right below! - ((Avatar)CurrentAvatar).Location = new Location(world); + CurrentAvatar.Location = new Location(world); } world.Size = new Size(size, size); - CurrentAvatar = new Avatar(this, -1) + CurrentAvatar = new VirtualParadiseAvatar(this, -1) { Application = _configuration.Application!, Name = $"[{_configuration.BotName}]", @@ -565,7 +564,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// -or- /// is too long to send. /// - public Task SendMessageAsync(string message) + public Task SendMessageAsync(string message) { if (message is null) { @@ -593,9 +592,14 @@ public sealed partial class VirtualParadiseClient : IDisposable } } - return Task.FromResult((IUserMessage)new UserMessage( - CurrentAvatar!, - message + VirtualParadiseAvatar? avatar = CurrentAvatar; + return Task.FromResult(new VirtualParadiseMessage( + MessageType.ChatMessage, + avatar!.Name, + message, + avatar, + FontStyle.Regular, + Color.Black )); } @@ -615,7 +619,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// -or- /// is too long to send. /// - public Task SendMessageAsync(string message, FontStyle fontStyle, Color color) + public Task SendMessageAsync(string message, FontStyle fontStyle, Color color) { return SendMessageAsync(null, message, fontStyle, color); } @@ -637,7 +641,7 @@ public sealed partial class VirtualParadiseClient : IDisposable /// -or- /// is too long to send. /// - public Task SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color) + public Task SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color) { if (message is null) { @@ -675,13 +679,14 @@ public sealed partial class VirtualParadiseClient : IDisposable } } - IAvatar avatar = CurrentAvatar!; - return Task.FromResult((IConsoleMessage)new ConsoleMessage( - avatar, - avatar.Name, + VirtualParadiseAvatar avatar = CurrentAvatar!; + return Task.FromResult(new VirtualParadiseMessage( + MessageType.ConsoleMessage, + name, message, - color, - fontStyle + avatar, + fontStyle, + color )); } @@ -733,7 +738,7 @@ public sealed partial class VirtualParadiseClient : IDisposable pair.Value.TrySetCanceled(); } - foreach (KeyValuePair> pair in _usersCompletionSources) + foreach (KeyValuePair> pair in _usersCompletionSources) { pair.Value.TrySetCanceled(); }