Exemple #1
0
        public void UpdateCamera(TimeUpdateEvent e, SpectatorTransitionCameraNode transitionCameraNode, [JoinAll] Optional <SingleNode <CameraTargetComponent> > target)
        {
            CameraSaveData cameraSaveData = transitionCameraNode.transitionCamera.CameraSaveData;

            if ((cameraSaveData.Type == CameraType.Free) || target.IsPresent())
            {
                UpdateCamera(e.DeltaTime, transitionCameraNode);
                ApplyCameraTransformEvent eventInstance = ApplyCameraTransformEvent.ResetApplyCameraTransformEvent();
                eventInstance.PositionSmoothingRatio = SPECTATOR_TRANSITION_CAMERA_POSITION_SMOOTHING_RATIO;
                eventInstance.RotationSmoothingRatio = SPECTATOR_TRANSITION_CAMERA_ROTATION_SMOOTHING_RATIO;
                eventInstance.DeltaTime = e.DeltaTime;
                base.ScheduleEvent(eventInstance, transitionCameraNode);
                if (transitionCameraNode.transitionCamera.TransitionComplete)
                {
                    CameraType type = cameraSaveData.Type;
                    if (type == CameraType.Follow)
                    {
                        transitionCameraNode.bezierPosition.BezierPosition.SetBaseRatio(cameraSaveData.FollowCameraBezierPositionRatio);
                        transitionCameraNode.bezierPosition.BezierPosition.SetRatioOffset(cameraSaveData.FollowCameraBezierPositionRatioOffset);
                        transitionCameraNode.cameraESM.Esm.ChangeState <CameraStates.CameraFollowState>();
                    }
                    else if (type == CameraType.MouseOrbit)
                    {
                        MouseOrbitCameraComponent mouseOrbitCamera = transitionCameraNode.cameraESM.Esm.ChangeState <CameraStates.CameraOrbitState>().mouseOrbitCamera;
                        mouseOrbitCamera.distance       = cameraSaveData.MouseOrbitDistance;
                        mouseOrbitCamera.targetRotation = cameraSaveData.MouseOrbitTargetRotation;
                    }
                    else if (type == CameraType.Free)
                    {
                        transitionCameraNode.cameraESM.Esm.ChangeState <CameraStates.CameraFreeState>();
                    }
                }
            }
        }
        public void ApplyCameraTransform(ApplyCameraTransformEvent e, BattleCameraNode battleCamera)
        {
            CameraComponent camera = battleCamera.camera;
            CameraTransformDataComponent cameraTransformData = battleCamera.cameraTransformData;
            Transform  root     = battleCamera.cameraRootTransform.Root;
            Vector3    position = cameraTransformData.Data.Position;
            Quaternion rotation = cameraTransformData.Data.Rotation;
            float      t        = 1f;
            float      num2     = 1f;

            if (e.DeltaTimeValid)
            {
                float deltaTime = e.DeltaTime;
                t    = !e.PositionSmoothingRatioValid ? battleCamera.applyCameraTransform.positionSmoothingRatio : e.PositionSmoothingRatio;
                num2 = !e.RotationSmoothingRatioValid ? battleCamera.applyCameraTransform.rotationSmoothingRatio : e.RotationSmoothingRatio;
                battleCamera.applyCameraTransform.positionSmoothingRatio = t;
                battleCamera.applyCameraTransform.rotationSmoothingRatio = num2;
                t    *= deltaTime;
                num2 *= deltaTime;
            }
            root.SetPositionSafe(Vector3.Lerp(root.position, position, t));
            Vector3 eulerAngles = rotation.eulerAngles;
            Vector3 vector3     = root.rotation.eulerAngles;

            root.rotation = Quaternion.Euler(new Vector3(Mathf.LerpAngle(vector3.x, eulerAngles.x, num2), Mathf.LerpAngle(vector3.y, eulerAngles.y, num2), 0f));
            base.ScheduleEvent <TransformTimeSmoothingEvent>(battleCamera);
        }
Exemple #3
0
 public void UpdateCamera(TimeUpdateEvent e, TransitionCameraNode transitionCameraNode, [JoinAll] SingleNode <SelfTankComponent> selfTank)
 {
     UpdateCamera(e.DeltaTime, transitionCameraNode);
     base.ScheduleEvent(ApplyCameraTransformEvent.ResetApplyCameraTransformEvent(), transitionCameraNode);
     if (transitionCameraNode.transitionCamera.TransitionComplete)
     {
         transitionCameraNode.cameraESM.Esm.ChangeState <CameraStates.CameraFollowState>();
     }
 }
        public void UpdateFollowCameraData(UpdateEvent e, FollowSpectratorCameraNode cameraNode, [JoinAll] CameraTargetNode targetNode, [JoinByTank] TankNode tank, [JoinAll] SingleNode <SelfUserComponent> selfUser, [JoinByUser] SingleNode <MouseControlStateHolderComponent> mouseControlStateHolderNode)
        {
            this.UpdateFollowCameraData(e.DeltaTime, cameraNode, targetNode, tank, mouseControlStateHolderNode.component);
            ApplyCameraTransformEvent eventInstance = ApplyCameraTransformEvent.ResetApplyCameraTransformEvent();

            eventInstance.PositionSmoothingRatio = SPECTATOR_FOLLOW_CAMERA_POSITION_SMOOTHING_RATIO;
            eventInstance.RotationSmoothingRatio = SPECTATOR_FOLLOW_CAMERA_ROTATION_RATIO;
            eventInstance.DeltaTime = e.DeltaTime;
            base.ScheduleEvent(eventInstance, cameraNode);
        }
        public void UpdateGoCamera(TimeUpdateEvent evt, GoCameraNode goCameraNode, [JoinAll] CameraTargetNode cameraTargetNode)
        {
            Transform     transform     = cameraTargetNode.cameraTarget.TargetObject.transform;
            int           goCameraIndex = goCameraNode.goCamera.goCameraIndex;
            GoCameraPoint point         = goCameraNode.goCameraPointsUnity.goCameraPoints[goCameraIndex];
            Vector3       vector        = (Vector3)(transform.rotation * point.poistion);
            TransformData data          = new TransformData {
                Position = transform.position + vector,
                Rotation = Quaternion.Euler(transform.rotation.eulerAngles + point.rotation)
            };

            goCameraNode.cameraTransformData.Data = data;
            base.ScheduleEvent(ApplyCameraTransformEvent.ResetApplyCameraTransformEvent(), goCameraNode);
        }
Exemple #6
0
        public unsafe void UpdateMouseOrbitCamera(TimeUpdateEvent evt, OrbitCameraNode cameraNode, [JoinAll] CameraTargetNode targetNode)
        {
            float deltaTime = evt.DeltaTime;
            MouseOrbitCameraComponent mouseOrbitCamera = cameraNode.mouseOrbitCamera;
            Vector3 eulerAngles = mouseOrbitCamera.targetRotation.eulerAngles;
            float   num2        = 1f;

            if (InputManager.CheckAction(SpectatorCameraActions.SlowMovement))
            {
                num2 = MouseOrbitCameraConstants.ROTATION_SLOW_RATIO;
            }
            float    num3       = MouseOrbitCameraConstants.X_ROTATION_SPEED * deltaTime;
            float    num4       = MouseOrbitCameraConstants.Y_ROTATION_SPEED * deltaTime;
            Vector3 *vectorPtr1 = &eulerAngles;

            vectorPtr1->x -= (InputManager.GetUnityAxis(UnityInputConstants.MOUSE_Y) * num3) * num2;
            Vector3 *vectorPtr2 = &eulerAngles;

            vectorPtr2->y += (InputManager.GetUnityAxis(UnityInputConstants.MOUSE_X) * num4) * num2;
            mouseOrbitCamera.targetRotation = Quaternion.Euler(MouseOrbitCameraUtils.NormalizeEuler(eulerAngles));
            mouseOrbitCamera.distance      *= Mathf.Pow(3f, -InputManager.GetUnityAxis(UnityInputConstants.MOUSE_SCROLL_WHEEL));
            mouseOrbitCamera.distance       = Mathf.Clamp(mouseOrbitCamera.distance, MouseOrbitCameraConstants.MIN_DISTANCE, MouseOrbitCameraConstants.MAX_DISTANCE);
            Vector3       position = targetNode.cameraTarget.TargetObject.transform.position;
            TransformData data     = new TransformData {
                Position = MouseOrbitCameraUtils.GetClippedPosition(position, position + (mouseOrbitCamera.targetRotation * new Vector3(0f, 0f, -mouseOrbitCamera.distance)), MouseOrbitCameraConstants.MAX_DISTANCE),
                Rotation = mouseOrbitCamera.targetRotation
            };

            cameraNode.cameraTransformData.Data = data;
            ApplyCameraTransformEvent eventInstance = ApplyCameraTransformEvent.ResetApplyCameraTransformEvent();

            eventInstance.PositionSmoothingRatio = MouseOrbitCameraConstants.POSITION_SMOOTHING_SPEED;
            eventInstance.RotationSmoothingRatio = MouseOrbitCameraConstants.ROTATION_SMOOTHING_SPEED;
            eventInstance.DeltaTime = deltaTime;
            base.ScheduleEvent(eventInstance, cameraNode);
        }
Exemple #7
0
        public unsafe void RecieveInput(TimeUpdateEvent evt, FreeCameraNode cameraNode, [JoinAll] UserNode user)
        {
            float deltaTime = evt.DeltaTime;
            FreeCameraComponent          freeCamera          = cameraNode.freeCamera;
            CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData;
            Quaternion rotation = freeCamera.Data.Rotation;
            Vector3    position = freeCamera.Data.Position;
            bool       flag     = freeCamera.Data != cameraTransformData.Data;
            float      num2     = 1f;
            float      num3     = 1f;

            if (InputManager.CheckAction(SpectatorCameraActions.AccelerateMovement))
            {
                num3 *= freeCamera.speedUp;
            }
            if (InputManager.CheckAction(SpectatorCameraActions.SlowMovement))
            {
                num2 *= freeCamera.slowDown;
                num3 *= freeCamera.slowDown;
            }
            if (InputManager.GetActionKeyDown(FreeCameraActions.FIXED_HEIGHT))
            {
                freeCamera.fixedHeight ^= true;
            }
            float num4 = ((!InputManager.CheckAction(FreeCameraActions.UP_TURN) ? 0 : -1) + (!InputManager.CheckAction(FreeCameraActions.DOWN_TURN) ? 0 : 1)) * 0.5f;
            float num5 = ((!InputManager.CheckAction(FreeCameraActions.RIGHT_TURN) ? 0 : 1) + (!InputManager.CheckAction(FreeCameraActions.LEFT_TURN) ? 0 : -1)) * 0.5f;

            if (InputManager.CheckMouseButtonInAllActiveContexts(FreeCameraActions.MOUSE_BUTTON_DOWN, UnityInputConstants.MOUSE_BUTTON_LEFT))
            {
                num4 += -InputManager.GetUnityAxis(UnityInputConstants.MOUSE_Y);
                num5 += InputManager.GetUnityAxis(UnityInputConstants.MOUSE_X);
            }
            Vector3  eulerAngles = rotation.eulerAngles;
            Vector3 *vectorPtr1  = &eulerAngles;

            vectorPtr1->x += ((num4 * freeCamera.xRotationSpeed) * num2) * deltaTime;
            Vector3 *vectorPtr2 = &eulerAngles;

            vectorPtr2->y += ((num5 * freeCamera.yRotationSpeed) * num2) * deltaTime;
            rotation       = Quaternion.Euler(NormalizeEuler(eulerAngles, freeCamera.xMinAngle, freeCamera.xMaxAngle));
            float   num6    = (!InputManager.CheckAction(FreeCameraActions.FORWARD_MOVING) ? 0 : 1) + (!InputManager.CheckAction(FreeCameraActions.BACK_MOVING) ? 0 : -1);
            float   num7    = (!InputManager.CheckAction(FreeCameraActions.RIGHT_MOVING) ? 0 : 1) + (!InputManager.CheckAction(FreeCameraActions.LEFT_MOVING) ? 0 : -1);
            float   num8    = (InputManager.GetAxis(FreeCameraActions.MOUSE_SCROLL_WHEEL_UP, true) - InputManager.GetAxis(FreeCameraActions.MOUSE_SCROLL_WHEEL_DOWN, true)) + (InputManager.GetAxis(FreeCameraActions.UP_MOVING, false) - InputManager.GetAxis(FreeCameraActions.DOWN_MOVING, false));
            Vector3 forward = Vector3.forward;
            Vector3 right   = Vector3.right;
            Vector3 up      = Vector3.up;

            if (!freeCamera.fixedHeight)
            {
                forward = (Vector3)(rotation * forward);
                right   = (Vector3)(rotation * right);
                up      = (Vector3)(rotation * up);
            }
            else
            {
                Vector3 euler = rotation.eulerAngles;
                euler.x = 0f;
                Quaternion quaternion2 = Quaternion.Euler(euler);
                forward = (Vector3)(quaternion2 * forward);
                right   = (Vector3)(quaternion2 * right);
            }
            TransformData data3 = new TransformData {
                Position = GetClippedPosition(position, position + (((Vector3.ClampMagnitude(((forward * num6) + (right * num7)) + (up * num8), 1f) * freeCamera.flySpeed) * num3) * deltaTime)),
                Rotation = rotation
            };
            ApplyCameraTransformEvent eventInstance = ApplyCameraTransformEvent.ResetApplyCameraTransformEvent();

            if (data3 != freeCamera.Data)
            {
                cameraNode.cameraTransformData.Data = data3;
                freeCamera.Data = data3;
                eventInstance.PositionSmoothingRatio = freeCamera.positionSmoothingSpeed;
                eventInstance.RotationSmoothingRatio = freeCamera.rotationSmoothingSpeed;
            }
            eventInstance.DeltaTime = deltaTime;
            base.ScheduleEvent(eventInstance, cameraNode);
        }
 public void UpdateFollowCameraData(UpdateEvent e, FollowCameraNode cameraNode, [JoinAll] CameraTargetNode targetNode, [JoinByTank] TankNode tank, [JoinAll] SingleNode <SelfTankComponent> selfTank, [JoinByUser] SingleNode <MouseControlStateHolderComponent> mouseControlStateHolderNode)
 {
     this.UpdateFollowCameraData(e.DeltaTime, cameraNode, targetNode, tank, mouseControlStateHolderNode.component);
     base.ScheduleEvent(ApplyCameraTransformEvent.ResetApplyCameraTransformEvent(), cameraNode);
 }