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;