~ruther/NosSmooth

451c5c0c10dad9b378ec801ec9c7e19e3fd866e2 — Rutherther 2 years ago a1afbb1
feat(packets): add inventory packets
A Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs => Packets/NosSmooth.Packets/Enums/Inventory/BagType.cs +43 -0
@@ 0,0 1,43 @@
//
//  BagType.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.Inventory;

/// <summary>
/// A bag in an inventory storing a given type of items.
/// </summary>
public enum BagType
{
    /// <summary>
    /// Equipment bag (first bag inside regular inventory).
    /// </summary>
    Equipment = 0,

    /// <summary>
    /// Main bag (second bag inside regular inventory).
    /// </summary>
    Main = 1,

    /// <summary>
    /// Etc bag (first bag inside the inventory).
    /// </summary>
    Etc = 2,

    /// <summary>
    /// Miniland bag (can be seen after pressing L).
    /// </summary>
    Miniland = 3,

    /// <summary>
    /// Specialist bag (last bag inside regular inventory, in a new window).
    /// </summary>
    Specialist = 6,

    /// <summary>
    /// Costume bag (last bag inside regular inventory, in a new window, right under specialist tab.).
    /// </summary>
    Costume = 7
}
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs => Packets/NosSmooth.Packets/Server/Inventory/InvPacket.cs +30 -0
@@ 0,0 1,30 @@
//
//  InvPacket.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.Inventory;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Inventory;

/// <summary>
/// Contents of inventory bag.
/// </summary>
/// <remarks>
/// This is sent at startup.
/// For updates, <see cref="IvnPacket"/>,
/// that is sent after changes.
/// </remarks>
/// <param name="Bag">The bag that the items are in.</param>
/// <param name="InvSubPackets">The items inside the bag.</param>
[PacketHeader("inv", PacketSource.Server)]
[GenerateSerializer(true)]
public record InvPacket
(
    [PacketIndex(0)]
    BagType Bag,
    [PacketListIndex(1, InnerSeparator = '.', ListSeparator = ' ')]
    IReadOnlyList<InvSubPacket> InvSubPackets
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs => Packets/NosSmooth.Packets/Server/Inventory/InvSubPacket.cs +37 -0
@@ 0,0 1,37 @@
//
//  InvSubPacket.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.Inventory;

/// <summary>
/// A sub packet of <see cref="InvPacket"/>
/// containing items in the given bag.
/// </summary>
/// <param name="Slot">The slot the item is in.</param>
/// <param name="VNum">The vnum of the item.</param>
/// <param name="RareOrAmount">Rare for equipment, otherwise amount.</param>
/// <param name="UpgradeOrDesign">Upgrade for equipment, otherwise design. May not be present.</param>
/// <param name="SpStoneUpgrade">A stone upgrade of sp. Zero for other equipment. Not present otherwise.</param>
/// <param name="RuneCount">The rune count for equipment.</param>
[PacketHeader(null, PacketSource.Server)]
[GenerateSerializer(true)]
public record InvSubPacket
(
    [PacketIndex(0)]
    short Slot,
    [PacketIndex(1)]
    short? VNum,
    [PacketIndex(2)]
    short RareOrAmount,
    [PacketIndex(3, IsOptional = true)]
    short? UpgradeOrDesign,
    [PacketIndex(4, IsOptional = true)]
    byte? SpStoneUpgrade,
    [PacketIndex(5, IsOptional = true)]
    int? RuneCount
) : IPacket;
\ No newline at end of file

A Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs => Packets/NosSmooth.Packets/Server/Inventory/IvnPacket.cs +27 -0
@@ 0,0 1,27 @@
//
//  IvnPacket.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.Inventory;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace NosSmooth.Packets.Server.Inventory;

/// <summary>
/// An update of inventory.
/// For inventory initialization,
/// <see cref="InvPacket"/>.
/// </summary>
/// <param name="Bag">The bag that should be updated.</param>
/// <param name="InvSubPacket">The data to be updated.</param>
[PacketHeader("ivn", PacketSource.Server)]
[GenerateSerializer(true)]
public record IvnPacket
(
    [PacketIndex(0)]
    BagType Bag,
    [PacketIndex(1, InnerSeparator = '.')]
    InvSubPacket InvSubPacket
) : IPacket;
\ No newline at end of file

A Samples/FileClient/Properties/launchSettings.json => Samples/FileClient/Properties/launchSettings.json +8 -0
@@ 0,0 1,8 @@
{
  "profiles": {
    "FileClient": {
      "commandName": "Project",
      "commandLineArgs": "D:\\Shared\\Documents\\my_projects\\cheats\\NosSmooth\\Samples\\FileClient\\bin\\Debug\\net7.0\\gf_login"
    }
  }
}
\ No newline at end of file