コード例 #1
0
        /// <summary>
        /// Handle received vehicle synchronization message.
        /// </summary>
        /// <param name="msg">The received synchronization message.</param>
        public void HandleVehicleSync(Messages.VehicleSyncMessage msg)
        {
            if (!IsSpawned)
            {
                return;
            }

            Client.Assert(state == State.DrivingVehicle, "Received driving vehicle update but player is not driving any vehicle.");
            currentVehicle.HandleSynchronization(msg);
        }
コード例 #2
0
        /// <summary>
        /// Handle synchronization packet from the network.
        /// </summary>
        /// <param name="msg">The message to handle.</param>
        public virtual void HandleSynchronization(Messages.VehicleSyncMessage message)
        {
            interpolator.SetTarget(Utils.NetVec3ToGame(message.position), Utils.NetQuatToGame(message.rotation));
            syncReceiveTime = netManager.GetNetworkClock();

            if (GameObject != null)
            {
                GameObject.Steering = message.steering;
            }
        }
コード例 #3
0
ファイル: NetLocalPlayer.cs プロジェクト: kuppa213/MSCMP
        /// <summary>
        /// Send in vehicle synchronization.
        /// </summary>
        /// <returns>true if sync was set, false otherwise</returns>
        private bool SendInVehicleSync()
        {
            Client.Assert(currentVehicle != null, "Tried to send in vehicle sync packet but no current vehicle is set.");

            Messages.VehicleSyncMessage message = new Messages.VehicleSyncMessage();
            if (!currentVehicle.WriteSyncMessage(message))
            {
                return(false);
            }
            if (!netManager.BroadcastMessage(message, Steamworks.EP2PSend.k_EP2PSendUnreliable))
            {
                return(false);
            }

            timeToUpdate = (float)NetVehicle.SYNC_DELAY / 1000;
            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Write vehicle data into sync message.
        /// </summary>
        /// <param name="message">The sync message to write to.</param>
        public bool WriteSyncMessage(Messages.VehicleSyncMessage message)
        {
            if (GameObject == null)
            {
                return(false);
            }

            Transform transform = GameObject.VehicleTransform;

            if (!transform)
            {
                return(false);
            }
            message.position = Utils.GameVec3ToNet(transform.position);
            message.rotation = Utils.GameQuatToNet(transform.rotation);
            return(true);
        }
コード例 #5
0
 /// <summary>
 /// Handle synchronization packet from the network.
 /// </summary>
 /// <param name="msg">The message to handle.</param>
 public virtual void HandleSynchronization(Messages.VehicleSyncMessage msg)
 {
     interpolator.SetTarget(Utils.NetVec3ToGame(msg.position), Utils.NetQuatToGame(msg.rotation));
     syncReceiveTime = netManager.GetNetworkClock();
 }