using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Video;

//空间坐标系同步
public class MRCCommonBehavior : NetworkBehaviour
{
    //位置和旋转
    private NetworkVariable<Vector3> spacePos;
    private NetworkVariable<Quaternion> spaceRot;

    

    public void SyncSpaceCordinateServer(Vector3 pos, Quaternion rot)
    {
        spacePos.Value = pos;
        spaceRot.Value = rot;
    }

    public void SyncSpaceCordinateClient()
    {
        //同步
    }

    //生成物体
    public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();

        if(!NetworkManager.Singleton.IsClient)
        {
            enabled = false;
        }
        else
        {
            NetworkManager.OnClientConnectedCallback += OnClientConnected;
            NetworkManager.OnClientDisconnectCallback += OnClientDisconnected;
        }
    }

    private void OnClientConnected(ulong clientId)
    {
    }

    private void OnClientDisconnected(ulong clientId)
    {
    }

    //删除物体
    public override void OnNetworkDespawn()
    {
        base.OnNetworkDespawn();
    }

    //获得所有权
    public override void OnGainedOwnership()
    {
        base.OnGainedOwnership();
    }

    //失去所有权
    public override void OnLostOwnership()
    {
        base.OnLostOwnership();
    }

    //更改了该物体的父物体
    public override void OnNetworkObjectParentChanged(NetworkObject parentNetworkObject)
    {
        base.OnNetworkObjectParentChanged(parentNetworkObject);
    }

    public void TestSend()
    {
        //向某个客户端发送消息
        //var message = new DestroyObjectMessage
        //{
        //    NetworkObjectId = NetworkObjectId,
        //    DestroyGameObject = 
        //};
        //NetworkManager.Singleton.SendMessage(ref message, NetworkDelivery.ReliableSequenced, clientId);
    }

}