-
Notifications
You must be signed in to change notification settings - Fork 7
/
Sub60PlayerAttackStepOneCommand.cs
69 lines (60 loc) · 1.79 KB
/
Sub60PlayerAttackStepOneCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FreecraftCore.Serializer;
namespace Booma.Proxy
{
//https://sylverant.net/wiki/index.php/Packet_0x60#Subcommand_0x43
[WireDataContract]
[SubCommand60(SubCommand60OperationCode.AttackStepOne)]
public sealed class Sub60PlayerAttackStepOneCommand : BaseSubCommand60, IMessageContextIdentifiable, ISerializationEventListener
{
/// <inheritdoc />
[WireMember(1)]
public byte Identifier { get; }
//Unknown 1 byte always follows id
[WireMember(2)]
private byte unk1 { get; }
//TODO: The calculation we're doing to init or parse this is wrong. It does not match the binary packet
//TODO: We must figure out how to exactly compute this value, test cases show off by 1 bit.
/// <summary>
/// The raw rotation value
/// that is sent over the network.
/// </summary>
[WireMember(3)]
private short RawNetworkRotation { get; set; }
/// <summary>
/// The rotation about the Y-axis.
/// </summary>
public float YAxisRotation { get; private set; }
//TODO: Is this anything but padding?
[WireMember(4)]
private short unk2 { get; }
/// <inheritdoc />
public Sub60PlayerAttackStepOneCommand(byte identifier, float yAxisRotation)
: this()
{
Identifier = identifier;
YAxisRotation = yAxisRotation;
}
//Serializer ctor
private Sub60PlayerAttackStepOneCommand()
{
CommandSize = 8 / 4;
}
//The below serialization event callbacks will properly handle the network rotation
//conversion
/// <inheritdoc />
public void OnBeforeSerialization()
{
RawNetworkRotation = (short)(YAxisRotation * 182.04444f);
}
/// <inheritdoc />
public void OnAfterDeserialization()
{
YAxisRotation = (RawNetworkRotation & 0xffff) / 182.04444f;
}
}
}