Interface that allows the creation of automatically serializable and deserializable structs.
More...
Interface that allows the creation of automatically serializable and deserializable structs.
public enum PurchaseResult
{
Completed,
Declined
}
[NetworkSerialize]
struct NetStoreTransaction : INetSerializableStruct
{
public long Timestamp { get; set; }
public PurchaseResult Result { get; set; }
public NetPurchasedItem? PurchasedItem { get; set; }
}
[NetworkSerialize]
struct NetPurchasedItem : INetSerializableStruct
{
public string Identifier;
public string[] Tags;
public int Amount;
}
Supported types are:
bool
byte
ushort
short
uint
int
ulong
long
float
double
string
Microsoft.Xna.Framework.Color
Microsoft.Xna.Framework.Vector2
In addition arrays, enums, Nullable<T> and Option<T> are supported.
Using Nullable<T> or Option<T> will make the field or property optional.
- See also
- NetworkSerialize
Definition at line 584 of file INetSerializableStruct.cs.
void Barotrauma.INetSerializableStruct.Write |
( |
IWriteMessage |
msg | ) |
|
Serializes the struct into a network message
public void ServerWrite(IWriteMessage msg) { INetSerializableStruct transaction = new NetStoreTransaction { Result = PurchaseResult.Completed, Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds(), PurchasedItem = new NetPurchasedItem { Identifier = "Wrench", Amount = 3, Tags = new []{ "smallitem", "mechanical", "tool" } } };
transaction.Write(msg); }
- Parameters
-
msg | Outgoing network message |
Definition at line 652 of file INetSerializableStruct.cs.