-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathColorPayload.cs
65 lines (48 loc) · 1.87 KB
/
ColorPayload.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
using System;
using System.IO;
using Dalamud.Game.Text.SeStringHandling;
using System.Numerics;
namespace Honorific;
public abstract class AbstractColorPayload : Payload {
protected byte Red { get; init; }
protected byte Green { get; init; }
protected byte Blue { get; init; }
protected override byte[] EncodeImpl() {
return new byte[] { START_BYTE, ChunkType, 0x05, 0xF6, Red, Green, Blue, END_BYTE };
}
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
}
public override PayloadType Type => PayloadType.Unknown;
protected abstract byte ChunkType { get; }
}
public abstract class AbstractColorEndPayload : Payload {
protected override byte[] EncodeImpl() {
return new byte[] { START_BYTE, ChunkType, 0x02, 0xEC, END_BYTE };
}
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
}
public override PayloadType Type => PayloadType.Unknown;
protected abstract byte ChunkType { get; }
}
public class ColorPayload : AbstractColorPayload {
protected override byte ChunkType => 0x13;
public ColorPayload(Vector3 color) {
Red = Math.Max((byte) 1, (byte) (color.X * 255f));
Green = Math.Max((byte) 1, (byte) (color.Y * 255f));
Blue = Math.Max((byte) 1, (byte) (color.Z * 255f));
}
}
public class ColorEndPayload : AbstractColorEndPayload {
protected override byte ChunkType => 0x13;
}
public class GlowPayload : AbstractColorPayload {
protected override byte ChunkType => 0x14;
public GlowPayload(Vector3 color) {
Red = Math.Max((byte) 1, (byte) (color.X * 255f));
Green = Math.Max((byte) 1, (byte) (color.Y * 255f));
Blue = Math.Max((byte) 1, (byte) (color.Z * 255f));
}
}
public class GlowEndPayload : AbstractColorEndPayload {
protected override byte ChunkType => 0x14;
}