<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UI;
using PlayGroup;

namespace Items
{
	[RequireComponent (typeof(PhotonView))]
	public class ItemNetwork : Photon.PunBehaviour
	{
        
		private Vector3 lastPos;
		//Catch the last pos of the transform at the end of the frame
		[HideInInspector]
		public PhotonView photonView;
		private bool synced = false;

		void Awake ()
		{
			photonView = GetComponent<PhotonView> ();
		}

		void Start ()
		{
			
			lastPos = transform.position;
			if (PhotonNetwork.connectedAndReady) {
				//Has been instantiated at runtime and you received instantiate from photon on room join
				StartSync ();
			}
		}

         
		void LateUpdate ()
		{
			if (photonView != null) {
				if (transform.position != lastPos && PhotonNetwork.connectedAndReady) { //if the item has been moved by someone then update its transform to all other clients
					photonView.RPC ("UpdateItemTransform", PhotonTargets.All, new object[] { transform.position });
				}
			}
			lastPos = transform.position;

		}


		[PunRPC] 
		void UpdateItemTransform (Vector3 pos)
		{
           
			lastPos = pos;
			transform.position = pos;

		}

		//PUN Sync
		[PunRPC]
		void SendCurrentState ()
		{
			if (PhotonNetwork.isMasterClient) {
				photonView.RPC ("UpdateItemTransform", PhotonTargets.Others, transform.position); 
			}
		}

		//PUN Callbacks

		public override void OnJoinedRoom ()
		{
			//Update on join if this item was not instantiated by the game and is apart of the map
			StartSync ();

		}

		void StartSync ()
		{
			if (!synced) {
				if (!PhotonNetwork.isMasterClient) {
					//If you are not the master then update the current IG state of this object from the master
					photonView.RPC ("SendCurrentState", PhotonTargets.MasterClient, null);
				} 

				GameMatrix.control.AddItem (photonView.viewID, this.gameObject);
				synced = true;
			}
		}


	}
}<commit_msg>changed transform checks from lateupdate to update<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UI;
using PlayGroup;

namespace Items
{
	[RequireComponent (typeof(PhotonView))]
	public class ItemNetwork : Photon.PunBehaviour
	{
        
		private Vector3 lastPos;
		//Catch the last pos of the transform at the end of the frame
		[HideInInspector]
		public PhotonView photonView;
		private bool synced = false;

		void Awake ()
		{
			photonView = GetComponent<PhotonView> ();
		}

		void Start ()
		{
			
			lastPos = transform.position;
			if (PhotonNetwork.connectedAndReady) {
				//Has been instantiated at runtime and you received instantiate from photon on room join
				StartSync ();
			}
		}

         
		void Update ()
		{
			if (photonView != null) {
				if (transform.position != lastPos && PhotonNetwork.connectedAndReady) { //if the item has been moved by someone then update its transform to all other clients
					photonView.RPC ("UpdateItemTransform", PhotonTargets.All, new object[] { transform.position });
				}
			}
			lastPos = transform.position;

		}


		[PunRPC] 
		void UpdateItemTransform (Vector3 pos)
		{
           
			lastPos = pos;
			transform.position = pos;

		}

		//PUN Sync
		[PunRPC]
		void SendCurrentState ()
		{
			if (PhotonNetwork.isMasterClient) {
				photonView.RPC ("UpdateItemTransform", PhotonTargets.Others, transform.position); 
			}
		}

		//PUN Callbacks

		public override void OnJoinedRoom ()
		{
			//Update on join if this item was not instantiated by the game and is apart of the map
			StartSync ();

		}

		void StartSync ()
		{
			if (!synced) {
				if (!PhotonNetwork.isMasterClient) {
					//If you are not the master then update the current IG state of this object from the master
					photonView.RPC ("SendCurrentState", PhotonTargets.MasterClient, null);
				} 

				GameMatrix.control.AddItem (photonView.viewID, this.gameObject);
				synced = true;
			}
		}


	}
}
{'fraction_non_alphanumeric': 0.09088601167809089, 'fraction_numerical': 0.0010154861640010156, 'mean_word_length': 3.066047471620227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2745281', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1177, 'n_words': 362}