public EventNotifyPacket(D2gsPacket packet) : base(packet.Raw) { var reader = new BinaryReader(new MemoryStream(packet.Raw), Encoding.ASCII); var id = reader.ReadByte(); if ((InComingPacket)id != InComingPacket.EventMessage) { throw new D2GSPacketException($"Invalid Packet Id {id}"); } EventType = (EventType)reader.ReadByte(); Action = reader.ReadByte(); EntityId = reader.ReadUInt32(); PlayerRelationType = (PlayerRelationType)reader.ReadByte(); }
public static byte[] Build(uint uid, PlayerRelationType relation, bool value) { return new byte[] { 0x5d, ((byte) relation), (value ? ((byte) 1) : ((byte) 0)), ((byte) uid), ((byte) (uid >> 8)), ((byte) (uid >> 0x10)), ((byte) (uid >> 0x18)) }; }
public SetPlayerRelation(uint uid, PlayerRelationType relation, bool value) : base(Build(uid, relation, value)) { this.uid = uid; this.relation = relation; this.value = value; }
// Methods public SetPlayerRelation(byte[] data) : base(data) { this.relation = (PlayerRelationType) data[1]; this.value = BitConverter.ToBoolean(data, 2); this.uid = BitConverter.ToUInt32(data, 3); }