mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
485698e93b
* Showing player markers * Marker above head * Use player name on marker * Sync full state on init * Sync game state on start * removed name from death and leave message Co-authored-by: Ricardo Lopes <raicuparta@gmail.com>
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using QSB.Messaging;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
public class FullStateMessage : PlayerMessage
|
|
{
|
|
public override MessageType MessageType => MessageType.FullState;
|
|
|
|
public Dictionary<uint, string> PlayerNames;
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
PlayerNames = new Dictionary<uint, string>();
|
|
|
|
reader.ReadString().Split(',').ToList().ForEach(pair =>
|
|
{
|
|
var splitPair = pair.Split(':');
|
|
var key = Convert.ToUInt16(splitPair[0]);
|
|
var value = splitPair[1];
|
|
PlayerNames[key] = value;
|
|
});
|
|
}
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
|
|
var playerNamePairs = PlayerNames.ToList().Select(pair => $"{pair.Key}:{pair.Value}").ToArray();
|
|
|
|
writer.Write(string.Join(",", playerNamePairs));
|
|
}
|
|
}
|
|
}
|