#ChatGPT gave me this solution to

1 messages · Page 1 of 1 (latest)

woven quartz
#
[System.Serializable]
public struct PlayerData : INetworkSerializable
{
    public string Name;
    public List<int> Cards;
    public int LeaderID;
    public bool IsHost;
    public int MatID;

    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref Name);
        serializer.SerializeValue(ref LeaderID);
        serializer.SerializeValue(ref IsHost);
        serializer.SerializeValue(ref MatID);

        // Serialize the list of cards
        if (serializer.IsReader)
        {
            int count = 0;
            serializer.SerializeValue(ref count);
            Cards = new List<int>(count);
            for (int i = 0; i < count; i++)
            {
                int card = 0;
                serializer.SerializeValue(ref card);
                Cards.Add(card);
            }
        }
        else
        {
            int count = Cards.Count;
            serializer.SerializeValue(ref count);
            foreach (var card in Cards)
            {
                int cardValue = card;
                serializer.SerializeValue(ref cardValue);
            }
        }
    }
}```
obsidian ridge
#

I would just have the list on it’s own outside of the struct.

woven quartz
#

I need to pass in that list

#

how would you send all 50 cards IDs?

#

of each player to another

#

oof, I figured the list out but