public void SetTo(TimeEntityInfo info) { // if (!_isSimulated) { _transform.position = info.location; _transform.rotation = info.rotation; _viewPoint.rotation = info.viewRotation; // } }
void FixedUpdate() { _timeText.text = ReadableTime; _deathText.text = _deathCount.ToString(); if (_currTimeState == TimeState.Playing) { for (int i = 0; i < _avatarHistories.Count - 1; i++) { var entityToTest = _avatarHistories[i].entity; if (_newestSelf == entityToTest) { continue; } Vector3 toOther = _newestSelf.EyeLocation - entityToTest.EyeLocation; if (toOther.sqrMagnitude <= _separationToCatch * _separationToCatch) { InitiateParadox(ParadoxCause.TooClose, i); break; } Debug.DrawLine(entityToTest.EyeLocation, entityToTest.EyeLocation + entityToTest.Forward, Color.red); float f = Vector3.Dot(entityToTest.Forward, toOther.normalized); if (f >= _fovToCatch) { Debug.DrawLine(_newestSelf.EyeLocation, entityToTest.EyeLocation, Color.blue); // Debug.Log("In FOV: "+f+"!"); RaycastHit hitInfo; if (Physics.Raycast(entityToTest.EyeLocation, toOther.normalized, out hitInfo, distance: Mathf.Infinity)) { if (hitInfo.collider.gameObject.GetComponent <TimeEntity>() != null) { Debug.DrawLine(_newestSelf.EyeLocation, entityToTest.EyeLocation, Color.yellow); Debug.DrawLine(hitInfo.point, entityToTest.EyeLocation, Color.green); InitiateParadox(ParadoxCause.Seen, i); break; } } } } AvatarTravelInfo oldestHistory = _avatarHistories[_avatarHistories.Count - 1]; if (_currFrame < _maxFrames) { for (int i = 0; i < _avatarHistories.Count - 1; i++) { _avatarHistories[i].entity.SetTo(_avatarHistories[i].timeTravelFrames[_currFrame]); } TimeEntityInfo segment = _newestSelf.Simulate(); oldestHistory.timeTravelFrames[_currFrame] = segment; oldestHistory.framesSimulated = _currFrame + 1; _currFrame++; } else { GameObject newest = Instantiate(_newestSelf.gameObject, Vector3.zero, Quaternion.identity) as GameObject; oldestHistory.entity = newest.GetComponent <TimeEntity>(); oldestHistory.entity.SetTo(oldestHistory.timeTravelFrames[0]); oldestHistory.entity.SimulateMe = false; AvatarTravelInfo newestAvatarHistory = new AvatarTravelInfo(_newestSelf, _maxFrames); _avatarHistories.Add(newestAvatarHistory); _currTimeState = TimeState.RewindingBecauseLoop; _currFrame--; } } _maxFramesSimulated = (int)Mathf.Max(_currFrame, _maxFramesSimulated); }