public override void DoAction1(uLink.BitStream stream, ItemRepresentation rep, ref uLink.NetworkMessageInfo info)
    {
        Vector3    pos = stream.ReadVector3();
        Quaternion ang = stream.ReadQuaternion();

        this.FireArrow(pos, ang, rep, null);
    }
    void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        if (stream.isWriting)
        {
            // Send information to all proxies and the owner (clients)
            // This code is executed on the creator (server)
            stream.Write(transform.position);
            stream.Write(rigidbody.rotation);
        }
        else
        {
            //This code is executed in the clients
            mostCurrentReceivedState.pos = stream.ReadVector3();
            mostCurrentReceivedState.rot = stream.ReadQuaternion();

            mostCurrentReceivedState.timestamp = info.rawServerTimestamp + (interpolationBackTimeMs / 1000);
        }
    }
    void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        if (stream.isWriting)
        {
            // Send information to all proxies (opponent player's computers)
            // This code is executed on the creator (server) when server is auth, or on the owner (client) when the server is non-auth.
            stream.Write(transform.position);
            stream.Write(character.velocity);
            stream.Write(transform.rotation);
        }
        else
        {
            // Update the proxy state when statesync arrives.
            Vector3    pos = stream.ReadVector3();
            Vector3    vel = stream.ReadVector3();
            Quaternion rot = stream.ReadQuaternion();

            UpdateState(pos, vel, rot, info.rawServerTimestamp);
        }
    }
Beispiel #4
0
    void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.Write(transform.position);
            stream.Write(character.velocity);
            stream.Write(transform.rotation);
        }
        else
        {
            State state;
            state.timestamp = info.rawServerTimestamp;

            state.pos = stream.ReadVector3();
            state.vel = stream.ReadVector3();
            state.rot = stream.ReadQuaternion();

            // Shift the buffer sideways, deleting state 20
            for (int i = proxyStates.Length - 1; i >= 1; i--)
            {
                proxyStates[i] = proxyStates[i - 1];
            }


            // Record current state in slot 0
            proxyStates[0] = state;

            // Update used slot count, however never exceed the buffer size
            // Slots aren't actually freed so this just makes sure the buffer is
            // filled up and that uninitalized slots aren't used.
            proxyStateCount = Mathf.Min(proxyStateCount + 1, proxyStates.Length);

            // Check if states are in order
            if (proxyStates[0].timestamp < proxyStates[1].timestamp)
            {
                Debug.LogError("Timestamp inconsistent: " + proxyStates[0].timestamp + " should be greater than " + proxyStates[1].timestamp);
            }
        }
    }
        public void ExecuteInternal(NetworkBase network)
        {
            // TODO: optimize arg reading!

            switch (internCode)
            {
            case InternalCode.BufferedRPCs: network._RPCBufferedRPCs(stream.ReadSerializedBuffers(), this); break;

            case InternalCode.CellConnectResponse: network._RPCCellConnectResponse(stream.ReadNetworkPlayer(), stream.ReadBoolean(), this); break;

            case InternalCode.ClientConnectRequest: network._RPCClientConnectRequest(stream, this); break;

            case InternalCode.ClientConnectResponse: network._RPCClientConnectResponse(stream.ReadNetworkPlayer(), stream, this); break;

            case InternalCode.ConnectDenied: network._RPCConnectDenied(stream.ReadInt32(), this); break;

            case InternalCode.Create: network._RPCCreate(stream.ReadNetworkPlayer(), stream.ReadNetworkGroup(), (NetworkAuthFlags)stream.ReadByte(), stream.ReadVector3(), stream.ReadQuaternion(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream, this); break;

            case InternalCode.DestroyByPlayerID: network._RPCDestroyByPlayerID(stream.ReadNetworkPlayer(), this); break;

            case InternalCode.DestroyByViewID: network._RPCDestroyByViewID(this); break;

            case InternalCode.HandoverRequest: network._RPCHandoverRequest(stream.ReadNetworkViewID(), this); break;

            case InternalCode.HandoverResponse: network._RPCHandoverResponse(stream.ReadNetworkViewID(), stream.ReadNetworkPlayer(), stream.ReadNetworkGroup(), (NetworkAuthFlags)stream.ReadByte(), stream.ReadVector3(), stream.ReadQuaternion(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream.ReadString(), stream.ReadBytes(), stream, this); break;

            case InternalCode.Redirect: network._RPCRedirect(stream.ReadEndPoint(), stream.ReadPassword(), this); break;

            case InternalCode.SecurityRequest: network._RPCSecurityRequest(stream.ReadPublicKey(), this); break;

            case InternalCode.SecurityResponse: network._RPCSecurityResponse(stream.ReadSymmetricKey(), this); break;

            case InternalCode.UnsecurityRequest: network._RPCUnsecurityRequest(stream.ReadSymmetricKey(), this); break;

            case InternalCode.UnsecurityResponse: network._RPCUnsecurityResponse(this); break;

            case InternalCode.StateSyncOwner: network._RPCStateSyncOwner(stream, this); break;

            case InternalCode.StateSyncProxy: network._RPCStateSyncProxy(stream, this); break;

            case InternalCode.PlayerIDConnected: network._RPCPlayerIDConnected(stream.ReadNetworkPlayer(), stream.ReadEndPoint(), stream, this); break;

            case InternalCode.PlayerIDDisconnected: network._RPCPlayerIDDisconnected(stream.ReadNetworkPlayer(), stream.ReadInt32(), this); break;

            case InternalCode.MultiStateSyncProxy: network._RPCMultiStateSyncProxy(this); break;

            case InternalCode.MultiStateSyncOwner: network._RPCMultiStateSyncOwner(stream.ReadStateSyncs(), this); break;

            case InternalCode.DestroyAll: network._RPCDestroyAll(!stream.isEOF && stream.ReadBoolean(), this); break;

            case InternalCode.DestroyInGroup: network._RPCDestroyInGroup(stream.ReadNetworkGroup(), this); break;

            case InternalCode.DestroyInGroupByPlayerID: network._RPCDestroyInGroupByPlayerID(stream.ReadNetworkPlayer(), stream.ReadNetworkGroup(), this); break;

            case InternalCode.LicenseCheck: network._RPCLicenseCheck(this); break;

            case InternalCode.ChangeGroup: network._RPCChangeGroup(stream.ReadNetworkViewID(), stream.ReadNetworkGroup(), this); break;

            case InternalCode.StateSyncCellProxy: network._RPCStateSyncCellProxy(stream, this); break;

            case InternalCode.MultiStateSyncCellProxy: network._RPCMultiStateSyncCellProxy(this); break;

            case InternalCode.RepairAuthFromProxyRequest: network._RPCRepairAuthFromProxyRequest(stream.ReadNetworkViewID(), this); break;

            case InternalCode.MastDebugInfo: network._RPCMastDebugInfo(stream.ReadVector3(), this); break;

            case InternalCode.ChangeAuthFlags: network._RPCChangeAuthFlags(stream.ReadNetworkViewID(), (NetworkAuthFlags)stream.ReadByte(), stream.ReadVector3(), this); break;

            case InternalCode.StateSyncOwnerDeltaCompressed: network._RPCStateSyncOwnerDeltaCompressed(stream, this); break;

            case InternalCode.StateSyncProxyDeltaCompressed: network._RPCStateSyncProxyDeltaCompressed(stream, this); break;

            case InternalCode.StateSyncOwnerDeltaCompressedInit: network._RPCStateSyncOwnerDeltaCompressedInit(stream, this); break;

            case InternalCode.StateSyncProxyDeltaCompressedInit: network._RPCStateSyncProxyDeltaCompressedInit(stream, this); break;

            default:
                Log.Debug(NetworkLogFlags.RPC, "Unknown internal RPC: ", internCode, " from ", connection, " channel ", channel);
                break;
            }
        }
Beispiel #6
0
 public void ReadFrom(uLink.BitStream stream)
 {
     FixedTime = stream.ReadSingle();
     Position  = stream.ReadVector3();
     Rotation  = stream.ReadQuaternion();
 }
Beispiel #7
0
 internal static object _ReadQuaternion(BitStream stream, object[] codecOptions)
 {
     return(stream.ReadQuaternion());
 }