Skip to content

Commit

Permalink
Add inventory gather and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 29, 2024
1 parent 685484c commit f2b327a
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Edelstein.Common.Gameplay.Handling;
using Edelstein.Protocol.Gameplay.Game;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;
using Edelstein.Protocol.Gameplay.Handling;
using Edelstein.Protocol.Network.Packets;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handling.Packets;

public class UserGatherItemRequestHandler(
IPipeline<PipedPacketMessage<IGameStageSystem, IGameStageSystemUser, UserGatherItemRequest>> pipeline
) : PipedPacketHandler<IGameStageSystem, IGameStageSystemUser, UserGatherItemRequest>(
(short)PacketRecvOperation.UserGatherItemRequest,
pipeline
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Edelstein.Common.Gameplay.Handling;
using Edelstein.Protocol.Gameplay.Game;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;
using Edelstein.Protocol.Gameplay.Handling;
using Edelstein.Protocol.Network.Packets;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handling.Packets;

public class UserSortItemRequestHandler(
IPipeline<PipedPacketMessage<IGameStageSystem, IGameStageSystemUser, UserSortItemRequest>> pipeline
) : PipedPacketHandler<IGameStageSystem, IGameStageSystemUser, UserSortItemRequest>(
(short)PacketRecvOperation.UserSortItemRequest,
pipeline
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send;
using Edelstein.Protocol.Gameplay.Game.Objects.Users;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handling.Pipes;

public class UserOnPacketUserGatherItemRequest : AbstractUserOnPacketInField<UserGatherItemRequest>
{
protected override async Task HandleAfter(IPipelineContext ctx, PipedFieldPacketMessage<UserGatherItemRequest> message)
{
await message.User.ModifyInventory(i => i[message.Packet.Type]?.Gather(), true);
await message.User.Dispatch(new GatherItemResult
{
Type = message.Packet.Type
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Threading.Tasks;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;
using Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send;
using Edelstein.Protocol.Gameplay.Game.Objects.Users;
using Edelstein.Protocol.Utilities.Pipelines;

namespace Edelstein.Common.Gameplay.Game.Handling.Pipes;

public class UserOnPacketUserSortItemRequest : AbstractUserOnPacketInField<UserSortItemRequest>
{
protected override async Task HandleAfter(IPipelineContext ctx, PipedFieldPacketMessage<UserSortItemRequest> message)
{
await message.User.ModifyInventory(i => i[message.Packet.Type]?.Sort(), true);
await message.User.Dispatch(new SortItemResult
{
Type = message.Packet.Type
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BinarySerialization;
using Edelstein.Protocol.Gameplay.Entities.Inventories;
using Edelstein.Protocol.Network.Packets;

namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;

public record UserGatherItemRequest : StructuredRecvPacket
{
[FieldOrder(0)] public int UpdateTime { get; init; }
[FieldOrder(1)] public ItemInventoryType Type { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BinarySerialization;
using Edelstein.Protocol.Gameplay.Entities.Inventories;
using Edelstein.Protocol.Network.Packets;

namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Recv;

public record UserSortItemRequest : StructuredRecvPacket
{
[FieldOrder(0)] public int UpdateTime { get; init; }
[FieldOrder(1)] public ItemInventoryType Type { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BinarySerialization;
using Edelstein.Protocol.Gameplay.Entities.Inventories;
using Edelstein.Protocol.Network.Packets;

namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send;

public record GatherItemResult() : StructuredSendPacket((short)PacketSendOperation.GatherItemResult)
{
[FieldOrder(0)] public byte Unk1 { get; init; }
[FieldOrder(1)] public required ItemInventoryType Type { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using BinarySerialization;
using Edelstein.Protocol.Gameplay.Entities.Inventories;
using Edelstein.Protocol.Network.Packets;

namespace Edelstein.Protocol.Gameplay.Game.Contracts.Packets.Send;

public record SortItemResult() : StructuredSendPacket((short)PacketSendOperation.SortItemResult)
{
[FieldOrder(0)] public byte Unk1 { get; init; }
[FieldOrder(1)] public required ItemInventoryType Type { get; init; }
}

0 comments on commit f2b327a

Please sign in to comment.