~ruther/NosSmooth

ea0cb9d3a0715061be29328566579c2cb7b4d6f4 — Rutherther 3 years ago 2cebbe1
feat(packets): add miniland info and objects packets
A Packets/NosSmooth.Packets/Enums/MinilandState.cs => Packets/NosSmooth.Packets/Enums/MinilandState.cs +28 -0
@@ 0,0 1,28 @@
//
//  MinilandState.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace NosSmooth.Packets.Enums;

/// <summary>
/// State of a miniland.
/// </summary>
public enum MinilandState
{
    /// <summary>
    /// The miniland is open for anybody.
    /// </summary>
    Open,

    /// <summary>
    /// The miniland is closed, cannot be accessed by anyone.
    /// </summary>
    Private,

    /// <summary>
    /// The miniland is locked, cannot be accessed and objects can be built.
    /// </summary>
    Lock,
}
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MlInfoBrPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MlInfoBrPacket.cs +37 -0
@@ 0,0 1,37 @@
//
//  MlInfoBrPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;
using NosSmooth.PacketSerializer.Abstractions.Common;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Miniland info packet. For minilands not owned by the playing character.
/// </summary>
/// <param name="MinilandMusicId">The id of the music. 3800 by default.</param>
/// <param name="OwnerName">The name of the owner.</param>
/// <param name="DailyVisitCount">The number of daily visits.</param>
/// <param name="VisitCount">The number of total visits.</param>
/// <param name="Unknown">Unknown TODO.</param>
/// <param name="MinilandMessage">The welcome message.</param>
[PacketHeader("mlinfobr", PacketSource.Server)]
[GenerateSerializer(true)]
public record MlInfoBrPacket
(
    [PacketIndex(0)]
    short MinilandMusicId,
    [PacketIndex(1)]
    NameString OwnerName,
    [PacketIndex(2)]
    int DailyVisitCount,
    [PacketIndex(3)]
    int VisitCount,
    [PacketIndex(4)]
    byte Unknown,
    [PacketGreedyIndex(5)]
    string MinilandMessage
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MlInfoPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MlInfoPacket.cs +47 -0
@@ 0,0 1,47 @@
//
//  MlInfoPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.Packets.Enums;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using NosSmooth.PacketSerializer.Abstractions.Common;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Miniland info packet. For miniland owned by the playing character.
/// </summary>
/// <param name="MinilandMusicId">The id of the music. 3800 by default.</param>
/// <param name="MinilandPoints">The points of the miniland.</param>
/// <param name="Unknown">Unknown TODO.</param>
/// <param name="DailyVisitCount">The number of daily visits.</param>
/// <param name="VisitCount">The number of total visits.</param>
/// <param name="Unknown1">Unknown TODO.</param>
/// <param name="MinilandState">The state of the miniland.</param>
/// <param name="MinilandMusicName">The name of the miniland music.</param>
/// <param name="MinilandMessage">The welcome message.</param>
[PacketHeader("mlinfo", PacketSource.Server)]
[GenerateSerializer(true)]
public record MlInfoPacket
(
    [PacketIndex(0)]
    short MinilandMusicId,
    [PacketIndex(1)]
    long MinilandPoints,
    [PacketIndex(2)]
    byte Unknown,
    [PacketIndex(3)]
    int DailyVisitCount,
    [PacketIndex(4)]
    int VisitCount,
    [PacketIndex(5)]
    byte Unknown1,
    [PacketIndex(6)]
    MinilandState MinilandState,
    [PacketIndex(7)]
    NameString MinilandMusicName,
    [PacketGreedyIndex(8)]
    string MinilandMessage
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MlObjLstPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MlObjLstPacket.cs +21 -0
@@ 0,0 1,21 @@
//
//  MlObjLstPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Miniland object list packet.
/// </summary>
/// <param name="Objects">The objects in the miniland or inventory.</param>
[PacketHeader("mlobjlst", PacketSource.Server)]
[GenerateSerializer(true)]
public record MlObjLstPacket
(
    [PacketListIndex(0, ListSeparator = ' ', InnerSeparator = '.')]
    IReadOnlyList<MlObjPacket> Objects
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MlObjPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MlObjPacket.cs +48 -0
@@ 0,0 1,48 @@
//
//  MlObjPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Miniland object packet.
/// </summary>
/// <param name="Slot">The slot in the inventory.</param>
/// <param name="InUse">Whether the item is placed in the miniland.</param>
/// <param name="X">The x coordinate, if in use.</param>
/// <param name="Y">The y coordinate, if in use.</param>
/// <param name="Width">The width of the object.</param>
/// <param name="Height">The height of the object.</param>
/// <param name="Unknown">Unknown TODO.</param>
/// <param name="DurabilityPoints">The durability points of a minigame.</param>
/// <param name="Unknown1">Unknown TODO.</param>
/// <param name="Unknown2">Unknown TODO.</param>
[PacketHeader("mlobj", PacketSource.Server)]
[GenerateSerializer(true)]
public record MlObjPacket
(
    [PacketIndex(0)]
    short Slot,
    [PacketIndex(1)]
    bool InUse,
    [PacketIndex(2)]
    short X,
    [PacketIndex(3)]
    short Y,
    [PacketIndex(4)]
    byte Width,
    [PacketIndex(5)]
    byte Height,
    [PacketIndex(6)]
    byte Unknown,
    [PacketIndex(7)]
    int DurabilityPoints,
    [PacketIndex(8)]
    bool Unknown1,
    [PacketIndex(9)]
    bool Unknown2
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MltObjPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MltObjPacket.cs +24 -0
@@ 0,0 1,24 @@
//
//  MltObjPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Miniland objects list packet.
/// </summary>
/// <remarks>
/// Used for minilands of different owners.
/// </remarks>
/// <param name="Objects">The miniland objects.</param>
[PacketHeader("mltobj", PacketSource.Server)]
[GenerateSerializer(true)]
public record MltObjPacket
(
    [PacketIndex(0)]
    IReadOnlyList<MltObjSubPacket> Objects
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Miniland/MltObjSubPacket.cs => Packets/NosSmooth.Packets/Server/Miniland/MltObjSubPacket.cs +30 -0
@@ 0,0 1,30 @@
//
//  MltObjSubPacket.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Miniland;

/// <summary>
/// Sub packet of <see cref="MltObjPacket"/>.
/// </summary>
/// <param name="VNum">The vnum of the item.</param>
/// <param name="Slot">The slot.</param>
/// <param name="X">The x coordinate.</param>
/// <param name="Y">The y coordinate.</param>
[PacketHeader("mltobjsub", PacketSource.Server)]
[GenerateSerializer(true)]
public record MltObjSubPacket
(
    [PacketIndex(0)]
    int VNum,
    [PacketIndex(1)]
    int Slot,
    [PacketIndex(2)]
    short X,
    [PacketIndex(3)]
    short Y
) : IPacket;
\ No newline at end of file

Do not follow this link