ChatMessage

Immutable value type representing a single chat message with timestamp, sender, message body, and category. Used throughout the Chat System as the data unit stored in channels.

Definition

Namespace: Paragon.Townskeep.ChatSystem Assembly: Townskeep.dll

public readonly struct ChatMessage

Remarks

ChatMessage is a readonly struct — it is stack-allocated, immutable, and passed by value. All fields are set via the constructor and cannot be modified after creation.

The ToString() format is [HH:mm:ss] Sender: Message, pre-computed at construction time for display efficiency.

Quick Lookup

Goal
How

Create a message

new ChatMessage(DateTime.Now, "Player", "Hello!", "General")

Get empty/default

ChatMessage.Empty

Display formatted

message.ToString()[14:30:05] Player: Hello!

Check sender

message.Sender

Get category

message.Category

Properties

Time

The timestamp when the message was created.

Sender

The name of the entity that sent the message.

Message

The text content of the message.

Category

A category tag for the message (e.g., "General", "System", "Combat").

Methods

Constructor

Creates a new chat message with all fields.

Parameter
Type
Description

time

DateTime

Timestamp of the message

sender

string

Name of the sender

message

string

Message body text

category

string

Category tag for filtering

ToString

Returns the pre-formatted display string.

Returns: [HH:mm:ss] Sender: Message

Statics

Empty

A default-initialized ChatMessage with null/default fields.

Common Pitfalls

circle-exclamation

Examples

Creating and Displaying a Message

Using with Chat Singleton

See Also

  • ChatChannel — channel that stores and dispatches messages

Last updated