- Code: Select all
public struct CreateStructureMsg : INetworkMessageBase
{
public string StructureName;
public int XPos;
public int YPos;
public static readonly CreateStructureMsg EmptyMessage = new CreateStructureMsg();
public void PrepareForSend( ref Message message )
{
message.Add( StructureName );
message.Add( XPos );
message.Add( YPos );
}
public void Unpack( Message message )
{
StructureName = message.GetString( 0 );
XPos = message.GetInt( 1 );
YPos = message.GetInt( 2 );
}
}
Is there any way I can allocate a struct on the stack without having to do this every time:
- Code: Select all
CreateStructureMsg msg;
msg.StructureName = string.Empty;
msg.XPos = 0;
msg.YPos = 0;
As you can imagine, if I have to change the struct this becomes a maintenance nightmare.
-D