0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-24 04:05:17 +00:00

Add ChangeStagePacket

This commit is contained in:
Sanae 2022-03-24 22:28:53 -06:00
parent 51a39fa258
commit 3525ac2099
6 changed files with 26 additions and 6 deletions

View file

@ -11,5 +11,6 @@ public enum PacketType : short {
Costume,
Shine,
Capture,
ChangeStage,
Command
}

View file

@ -5,7 +5,6 @@ namespace Shared.Packet.Packets;
[Packet(PacketType.Capture)]
public struct CapturePacket : IPacket {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
public string ModelName;
public short Size => Constants.CostumeNameSize;

View file

@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
using System.Text;
namespace Shared.Packet.Packets;
[Packet(PacketType.ChangeStage)]
public struct ChangeStagePacket : IPacket {
private const int IdSize = 0x10;
private const int StageSize = 0x30;
public string Stage = "";
public string Id = "";
public byte Scenario = 0;
public byte SubScenarioType = 0;
public ChangeStagePacket() { }
public short Size => 0x44;
public void Serialize(Span<byte> data) {
Encoding.UTF8.GetBytes(Stage).CopyTo(data[..StageSize]);
Encoding.UTF8.GetBytes(Id).CopyTo(data[StageSize..(IdSize + StageSize)]);
MemoryMarshal.Write(data[(IdSize + StageSize)..(IdSize + StageSize + 1)], ref Scenario);
MemoryMarshal.Write(data[(IdSize + StageSize + 1)..(IdSize + StageSize + 2)], ref SubScenarioType);
}
public void Deserialize(Span<byte> data) {
throw new NotImplementedException("This packet should not be sent by the client.");
}
}

View file

@ -5,10 +5,7 @@ namespace Shared.Packet.Packets;
[Packet(PacketType.Costume)]
public struct CostumePacket : IPacket {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
public string BodyName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
public string CapName;
public short Size => Constants.CostumeNameSize * 2;

View file

@ -8,7 +8,6 @@ public struct GamePacket : IPacket {
private const int StageSize = 0x30;
public bool Is2d;
public byte ScenarioNum;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = StageSize)]
public string Stage = "";
public GamePacket() {

View file

@ -12,7 +12,6 @@ public struct PlayerPacket : IPacket {
public Vector3 Position;
public Quaternion Rotation;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public float[] AnimationBlendWeights = Array.Empty<float>();
public ushort Act;