Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ChatCommandId.cs
Go to the documentation of this file.
1
using
System.IO
;
2
using
System.Text
;
3
using
ReLogic.Utilities
;
4
using
Terraria.Chat.Commands
;
5
6
namespace
Terraria.Chat
;
7
8
public
struct
ChatCommandId
9
{
10
private
readonly
string
_name
;
11
12
private
ChatCommandId
(
string
name)
13
{
14
_name
= name;
15
}
16
17
public
static
ChatCommandId
FromType<T>
() where T :
IChatCommand
18
{
19
ChatCommandAttribute
cacheableAttribute =
AttributeUtilities
.GetCacheableAttribute<T,
ChatCommandAttribute
>();
20
if
(cacheableAttribute !=
null
)
21
{
22
return
new
ChatCommandId
(cacheableAttribute.
Name
);
23
}
24
return
new
ChatCommandId
(
null
);
25
}
26
27
public
void
Serialize
(
BinaryWriter
writer)
28
{
29
writer.Write(
_name
??
""
);
30
}
31
32
public
static
ChatCommandId
Deserialize
(
BinaryReader
reader)
33
{
34
return
new
ChatCommandId
(reader.
ReadString
());
35
}
36
37
public
int
GetMaxSerializedSize
()
38
{
39
return
4 +
Encoding
.
UTF8
.GetByteCount(
_name
??
""
);
40
}
41
}
ReLogic.Utilities.AttributeUtilities
Definition
AttributeUtilities.cs:8
System.IO.BinaryReader.ReadString
virtual string ReadString()
Definition
BinaryReader.cs:263
System.IO.BinaryReader
Definition
BinaryReader.cs:8
System.IO.BinaryWriter
Definition
BinaryWriter.cs:10
System.Text.Encoding.UTF8
static Encoding UTF8
Definition
Encoding.cs:526
System.Text.Encoding
Definition
Encoding.cs:15
Terraria.Chat.Commands.ChatCommandAttribute.Name
readonly string Name
Definition
ChatCommandAttribute.cs:8
Terraria.Chat.Commands.ChatCommandAttribute
Definition
ChatCommandAttribute.cs:7
Terraria.Chat.Commands.IChatCommand
Definition
IChatCommand.cs:4
ReLogic.Utilities
Definition
AttributeUtilities.cs:5
System.IO
Definition
ConsoleStream.cs:3
System.Text
Definition
ConsoleEncoding.cs:1
Terraria.Chat.Commands
Definition
AllDeathCommand.cs:4
Terraria.Chat
Definition
AllDeathCommand.cs:4
Terraria.Chat.ChatCommandId.Serialize
void Serialize(BinaryWriter writer)
Definition
ChatCommandId.cs:27
Terraria.Chat.ChatCommandId.ChatCommandId
ChatCommandId(string name)
Definition
ChatCommandId.cs:12
Terraria.Chat.ChatCommandId._name
readonly string _name
Definition
ChatCommandId.cs:10
Terraria.Chat.ChatCommandId.Deserialize
static ChatCommandId Deserialize(BinaryReader reader)
Definition
ChatCommandId.cs:32
Terraria.Chat.ChatCommandId.GetMaxSerializedSize
int GetMaxSerializedSize()
Definition
ChatCommandId.cs:37
Terraria.Chat.ChatCommandId.FromType< T >
static ChatCommandId FromType< T >()
Definition
ChatCommandId.cs:17
Terraria.Chat.ChatCommandId
Definition
ChatCommandId.cs:9
source
Terraria.Chat
ChatCommandId.cs
Generated by
1.10.0