public void SwitchCameraToSpawnState(NodeAddedEvent evt, SelfTankReadyForCameraNode tank, [JoinByUser] SingleNode <UserUidComponent> userUidNode, [Context, JoinAll] ESMNode camera, [JoinAll] Optional <SingleNode <FollowCameraComponent> > followCameraOptional) { TransitionCameraComponent transitionCamera = camera.transitionCamera; transitionCamera.CameraSaveData = CameraSaveData.CreateFollowData(userUidNode.component.Uid, camera.bezierPosition.BezierPosition.GetBaseRatio(), camera.bezierPosition.BezierPosition.GetRatioOffset()); transitionCamera.Spawn = true; camera.cameraESM.Esm.ChangeState <CameraStates.CameraTransitionState>(); }
public void SwitchCameraToSpawnState(NodeAddedEvent evt, SingleNode <FollowedTankReadyToCameraComponent> tank, [JoinByUser] SingleNode <UserUidComponent> userUidNode, [JoinAll] MouseOrbitESMNode camera) { TransitionCameraComponent transitionCamera = camera.transitionCamera; transitionCamera.CameraSaveData = CameraSaveData.CreateMouseOrbitData(userUidNode.component.Uid, camera.mouseOrbitCamera.distance, camera.mouseOrbitCamera.targetRotation); transitionCamera.Spawn = true; camera.cameraESM.Esm.ChangeState <CameraStates.CameraTransitionState>(); }
private void InitFollowCamera(TransitionCameraNode cameraNode, WeaponNode weapon, TankNode tank, float flyTimeSec, float flyHeight) { TransitionCameraComponent transitionCamera = cameraNode.transitionCamera; Transform target = weapon.cameraTarget.TargetObject.transform; BezierPosition bezierPosition = cameraNode.bezierPosition.BezierPosition; CameraOffsetConfigComponent cameraOffsetConfig = cameraNode.cameraOffsetConfig; Vector3 cameraOffset = new Vector3(cameraOffsetConfig.XOffset, cameraOffsetConfig.YOffset, cameraOffsetConfig.ZOffset); CameraData cameraData = new CameraData(); Vector3 position = CameraPositionCalculator.CalculateCameraPosition(target, tank.baseRenderer, tank.tankColliders.BoundsCollider.bounds.center, bezierPosition, cameraData, cameraOffset, 0f); Vector3 zero = Vector3.zero; zero.x = -CameraPositionCalculator.GetPitchAngle(cameraData, bezierPosition) * 57.29578f; zero.y = target.transform.rotation.eulerAngles.y; InitCamera(cameraNode, position, zero, flyTimeSec, flyHeight); }
private static void UpdateCamera(float dt, TransitionCameraNode cameraNode) { TransitionCameraComponent transitionCamera = cameraNode.transitionCamera; CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData; if (transitionCamera.TotalDistance == 0f) { transitionCamera.TransitionComplete = true; } else if (transitionCamera.Speed < 0f) { transitionCamera.TransitionComplete = true; } else { if ((transitionCamera.Distance > (0.5f * transitionCamera.TotalDistance)) && (transitionCamera.Acceleration > 0f)) { transitionCamera.Acceleration = -transitionCamera.Acceleration; transitionCamera.AngleValuesX.ReverseAcceleration(); transitionCamera.AngleValuesY.ReverseAcceleration(); } float num = transitionCamera.Acceleration * dt; transitionCamera.Distance += (transitionCamera.Speed + (0.5f * num)) * dt; transitionCamera.Speed += num; if (transitionCamera.Distance > transitionCamera.TotalDistance) { transitionCamera.Distance = transitionCamera.TotalDistance; } TransformData data2 = new TransformData { Position = Bezier.PointOnCurve(transitionCamera.Distance / transitionCamera.TotalDistance, transitionCamera.P1, transitionCamera.P2, transitionCamera.P3, transitionCamera.P4), Rotation = Quaternion.Euler(cameraTransformData.Data.Rotation.eulerAngles + new Vector3(transitionCamera.AngleValuesX.Update(dt), transitionCamera.AngleValuesY.Update(dt), 0f)) }; cameraTransformData.Data = data2; if (Mathf.Abs((float)(transitionCamera.Distance - transitionCamera.TotalDistance)) < 0.01f) { transitionCamera.TransitionComplete = true; } } }
private static void InitCamera(TransitionCameraNode transitionCameraNode, Vector3 position, Vector3 angles, float flyTimeSec, float flyHeight) { TransitionCameraComponent transitionCamera = transitionCameraNode.transitionCamera; CameraTransformDataComponent cameraTransformData = transitionCameraNode.cameraTransformData; transitionCamera.P1 = cameraTransformData.Data.Position; transitionCamera.P2 = transitionCamera.P1; transitionCamera.P4 = position; transitionCamera.P3 = transitionCamera.P4; float y = ((transitionCamera.P1.y <= transitionCamera.P4.y) ? transitionCamera.P4.y : transitionCamera.P1.y) + flyHeight; transitionCamera.P2 = new Vector3(transitionCamera.P2.x, y, transitionCamera.P2.z); transitionCamera.P3 = new Vector3(transitionCamera.P3.x, y, transitionCamera.P3.z); float accelerationCoeff = 4f / (flyTimeSec * flyTimeSec); Vector3 eulerAngles = cameraTransformData.Data.Rotation.eulerAngles; transitionCamera.AngleValuesX = new AngleValues(eulerAngles.x, angles.x, accelerationCoeff); transitionCamera.AngleValuesY = new AngleValues(eulerAngles.y, angles.y, accelerationCoeff); Vector3 vector10 = transitionCamera.P4 - transitionCamera.P1; transitionCamera.TotalDistance = vector10.magnitude; transitionCamera.Acceleration = transitionCamera.TotalDistance * accelerationCoeff; }