Skip to content

Commit

Permalink
Add SystemMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 14, 2024
1 parent 2bf5bb8 commit 9c1e15d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using BinarySerialization;
using Edelstein.Protocol.Gameplay.Game.Objects.Users.Messages;
using Edelstein.Protocol.Network.Packets;

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

public record Message() : StructuredSendPacket((short)PacketSendOperation.Message)
{
[FieldOrder(0)]
public required MessageType Type { get; init; }

[FieldOrder(1)]
[Subtype(nameof(Type), MessageType.SystemMessage, typeof(StructuredMessageInfoSystemMessage))]
[SubtypeDefault(typeof(StructuredMessageInfo))]
public required StructuredMessageInfo Info { get; init; }
}
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.Send;
using Edelstein.Protocol.Gameplay.Game.Objects.Users.Messages;
using Edelstein.Protocol.Network.Packets.Types;

namespace Edelstein.Protocol.Gameplay.Game.Objects.Users;

public static class IFieldUserExtensions
{
public static Task Message(this IFieldUser user, string chat)
=> user.Dispatch(new Message
{
Type = MessageType.SystemMessage,
Info = new StructuredMessageInfoSystemMessage
{
Chat = new LPString(chat)
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Edelstein.Protocol.Gameplay.Game.Objects.Users.Messages;

public enum MessageType : byte
{
DropPickUpMessage = 0x0,
QuestRecordMessage = 0x1,
CashItemExpireMessage = 0x2,
IncEXPMessage = 0x3,
IncSPMessage = 0x4,
IncPOPMessage = 0x5,
IncMoneyMessage = 0x6,
IncGPMessage = 0x7,
GiveBuffMessage = 0x8,
GeneralItemExpireMessage = 0x9,
SystemMessage = 0xA,
QuestRecordExMessage = 0xB,
ItemProtectExpireMessage = 0xC,
ItemExpireReplaceMessage = 0xD,
SkillExpireMessage = 0xE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Edelstein.Protocol.Network.Packets;

namespace Edelstein.Protocol.Gameplay.Game.Objects.Users.Messages;

public record StructuredMessageInfo : StructuredBasePacket;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BinarySerialization;
using Edelstein.Protocol.Network.Packets.Types;

namespace Edelstein.Protocol.Gameplay.Game.Objects.Users.Messages;

public record StructuredMessageInfoSystemMessage : StructuredMessageInfo
{
[FieldOrder(0)]
public required LPString Chat { get; init; }
}

0 comments on commit 9c1e15d

Please sign in to comment.