protected virtual void ApplyTrackData(TrackingEntity trackingEntity, TrackRecord trackRecord)
 {
     trackingEntity.AbsolutePosition             = new Vector3(trackRecord.currentPos.x - gridOffset.x, trackRecord.currentPos.y - gridOffset.y, trackRecord.currentPos.z - gridOffset.z);
     trackingEntity.NextExpectedAbsolutePosition = new Vector3(trackRecord.expectPos.x - gridOffset.x, trackRecord.expectPos.y - gridOffset.y, trackRecord.expectPos.z - gridOffset.z);
     trackingEntity.RelativePosition             = new Vector3(trackRecord.relPos.x, trackRecord.relPos.y, trackRecord.relPos.z);
     trackingEntity.Orientation = new Vector3(trackRecord.orientation.x, trackRecord.orientation.y, trackRecord.orientation.z);
     trackingEntity.Speed       = trackRecord.speed;
     trackingEntity.Echoes.Clear();
     trackRecord.echoes.AddRange(trackingEntity.Echoes);
 }
        public virtual void TrackRemoved(int trackID)
        {
            TrackingEntity trackingEntity = null;

            if (_trackingEntityDict.TryGetValue(trackID, out trackingEntity))
            {
                _trackingEntityDict.Remove(trackID);

                if (trackingEntity != null)
                {
                    Destroy(trackingEntity.gameObject);
                }
            }
        }
        public virtual void TrackAdded(TrackRecord trackRecord)
        {
            Vector2    position      = _trackingReceiveHandler.TrackingSettings.GetScreenPositionFromRelativePosition(trackRecord.relPos.x, trackRecord.relPos.y);
            GameObject trackInstance = GameObject.Instantiate(TrackingEntityPrefab, new Vector3(position.x, -1.7f, position.y), Quaternion.identity) as GameObject;

            trackInstance.transform.SetParent(trackSpawnParent);
            trackInstance.name = string.Format("PharusTrack_{0}", trackRecord.trackID);

            TrackingEntity trackingEntity = trackInstance.GetComponent <TrackingEntity>();

            trackingEntity.TrackID = trackRecord.trackID;

            ApplyTrackData(trackingEntity, trackRecord);

            _trackingEntityDict.Add(trackingEntity.TrackID, trackingEntity);
        }
        public virtual void TrackUpdated(TrackRecord trackRecord)
        {
            TrackingEntity trackingEntity = null;

            if (_trackingEntityDict.TryGetValue(trackRecord.trackID, out trackingEntity))
            {
                ApplyTrackData(trackingEntity, trackRecord);

                trackingEntity.SetPosition(_trackingReceiveHandler.TrackingSettings.GetScreenPositionFromRelativePosition(trackRecord.relPos.x, trackRecord.relPos.y));
            }
            else
            {
                if (addUnknownTrackOnUpdate)
                {
                    TrackAdded(trackRecord);
                }
            }
        }