Exemplo n.º 1
0
    void AttachToHand(ref HandData hand, GameObject gameObject)
    {
        NetworkInfo networkInfo = gameObject.GetComponent <NetworkInfo>();

        networkInfo.AttachCubeToLocalPlayer(this, hand);

#if DEBUG_AUTHORITY
        Debug.Log("client " + context.GetClientIndex() + " grabbed cube " + networkInfo.GetCubeId() + " and set ownership sequence to " + networkInfo.GetOwnershipSequence());
#endif // #if DEBUG_AUTHORITY

        if (!context.IsServer())
        {
            networkInfo.ClearConfirmed();
        }
        else
        {
            networkInfo.SetConfirmed();
        }

        for (int i = 0; i < ThrowRingBufferSize; ++i)
        {
            hand.throwRingBufferEntries[i].valid = false;
            hand.throwRingBufferEntries[i].speed = 0.0f;
        }
    }
    public void TakeAuthorityOverObject(NetworkInfo networkInfo)
    {
        Assert.IsTrue(networkInfo.GetAuthorityIndex() == 0);
#if DEBUG_AUTHORITY
        Debug.Log("client " + clientIndex + " took authority over cube " + networkInfo.GetCubeId());
#endif // #if DEBUG_AUTHORITY
        networkInfo.SetAuthorityIndex(authorityIndex);
        networkInfo.IncreaseAuthoritySequence();
        if (!IsServer())
        {
            networkInfo.ClearConfirmed();
        }
        else
        {
            networkInfo.SetConfirmed();
        }
    }