Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomAce.cs
Go to the documentation of this file.
2
3public sealed class CustomAce : GenericAce
4{
5 private byte[] _opaque;
6
7 public static readonly int MaxOpaqueLength = 65531;
8
9 public int OpaqueLength
10 {
11 get
12 {
13 if (_opaque == null)
14 {
15 return 0;
16 }
17 return _opaque.Length;
18 }
19 }
20
21 public override int BinaryLength => 4 + OpaqueLength;
22
23 public CustomAce(AceType type, AceFlags flags, byte[]? opaque)
24 : base(type, flags)
25 {
26 if ((int)type <= 16)
27 {
29 }
30 SetOpaque(opaque);
31 }
32
33 public byte[]? GetOpaque()
34 {
35 return _opaque;
36 }
37
38 public void SetOpaque(byte[]? opaque)
39 {
40 if (opaque != null)
41 {
42 if (opaque.Length > MaxOpaqueLength)
43 {
45 }
46 if (opaque.Length % 4 != 0)
47 {
49 }
50 }
51 _opaque = opaque;
52 }
53
54 public override void GetBinaryForm(byte[] binaryForm, int offset)
55 {
56 MarshalHeader(binaryForm, offset);
57 offset += 4;
58 if (OpaqueLength != 0)
59 {
61 {
62 throw new InvalidOperationException();
63 }
64 GetOpaque().CopyTo(binaryForm, offset);
65 }
66 }
67}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentOutOfRange_ArrayLength
Definition SR.cs:70
static string ArgumentOutOfRange_ArrayLengthMultiple
Definition SR.cs:72
static string ArgumentOutOfRange_InvalidUserDefinedAceType
Definition SR.cs:78
Definition SR.cs:7
CustomAce(AceType type, AceFlags flags, byte[]? opaque)
Definition CustomAce.cs:23
override void GetBinaryForm(byte[] binaryForm, int offset)
Definition CustomAce.cs:54
static readonly int MaxOpaqueLength
Definition CustomAce.cs:7
void MarshalHeader(byte[] binaryForm, int offset)
Definition GenericAce.cs:82