using System;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
namespace Unity.BossRoom.Utils
{
///
/// NetworkBehaviour containing only one NetworkVariableString which represents this object's name.
///
public class NetworkNameState : NetworkBehaviour
{
[HideInInspector]
public NetworkVariable Name = new NetworkVariable();
}
///
/// Wrapping FixedString so that if we want to change player name max size in the future, we only do it once here
///
public struct FixedPlayerName : INetworkSerializable
{
FixedString32Bytes m_Name;
public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter
{
serializer.SerializeValue(ref m_Name);
}
public override string ToString()
{
return m_Name.Value.ToString();
}
public static implicit operator string(FixedPlayerName s) => s.ToString();
public static implicit operator FixedPlayerName(string s) => new FixedPlayerName() { m_Name = new FixedString32Bytes(s) };
}
}