Example #1
0
        public void ResetCamera(NodeAddedEvent evt, AimingIdleStateNode weapon, AimingCameraNode cameraNode)
        {
            ShaftAimingCameraComponent   shaftAimingCamera   = cameraNode.shaftAimingCamera;
            CameraTransformDataComponent cameraTransformData = cameraNode.cameraTransformData;
            CameraComponent camera = cameraNode.camera;
            Transform       root   = cameraNode.cameraRootTransform.Root;

            root.SetPositionSafe(cameraTransformData.Data.Position);
            root.SetRotationSafe(cameraTransformData.Data.Rotation);
            Entity entity = cameraNode.Entity;

            entity.RemoveComponent <ShaftAimingCameraComponent>();
            entity.AddComponent <ShaftAimingCameraFOVRecoveringComponent>();
            entity.AddComponent <ApplyCameraTransformComponent>();
        }
Example #2
0
        public void InterpolateManualTargetingCamera(UpdateEvent evt, AimingWorkActivationStateNode weapon, [JoinAll] AimingCameraNode cameraNode)
        {
            MuzzleVisualAccessor       accessor          = new MuzzleVisualAccessor(weapon.muzzlePoint);
            CameraComponent            camera            = cameraNode.camera;
            Transform                  root              = cameraNode.cameraRootTransform.Root;
            ShaftAimingCameraComponent shaftAimingCamera = cameraNode.shaftAimingCamera;
            float t = Mathf.Clamp01(weapon.shaftAimingWorkActivationState.ActivationTimer / weapon.shaftStateConfig.ActivationToWorkingTransitionTimeSec);
            MuzzleLogicAccessor accessor2 = new MuzzleLogicAccessor(weapon.muzzlePoint, weapon.weaponInstance);

            root.SetPositionSafe(Vector3.Lerp(shaftAimingCamera.WorldInitialCameraPosition, accessor2.GetBarrelOriginWorld(), t));
            Quaternion quaternion2 = Quaternion.LookRotation(accessor.GetFireDirectionWorld(), accessor.GetUpDirectionWorld());

            weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle = Mathf.Clamp(weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, -weapon.shaftAimingRotationConfig.AimingOffsetClipping, weapon.shaftAimingRotationConfig.AimingOffsetClipping);
            Vector3 eulerAngles = quaternion2.eulerAngles;

            root.SetRotationSafe(Quaternion.Slerp(shaftAimingCamera.WorldInitialCameraRotation, Quaternion.Euler(eulerAngles.x, eulerAngles.y + weapon.weaponRotationControl.MouseRotationCumulativeHorizontalAngle, eulerAngles.z), t));
            camera.FOV = Mathf.Lerp(shaftAimingCamera.InitialFOV, weapon.shaftAimingCameraConfigEffect.ActivationStateTargetFov, t);
        }
Example #3
0
        public void InitManualTargetingCamera(NodeAddedEvent evt, AimingWorkActivationStateNode weapon, InitialCameraNode cameraNode)
        {
            Entity    entity = cameraNode.Entity;
            Transform root   = cameraNode.cameraRootTransform.Root;
            ShaftAimingCameraComponent component = new ShaftAimingCameraComponent {
                WorldInitialCameraPosition = root.position,
                WorldInitialCameraRotation = root.rotation,
                InitialFOV = cameraNode.camera.FOV
            };

            entity.AddComponent(component);
            if (entity.HasComponent <ApplyCameraTransformComponent>())
            {
                entity.RemoveComponent <ApplyCameraTransformComponent>();
            }
            if (entity.HasComponent <CameraFOVUpdateComponent>())
            {
                entity.RemoveComponent <CameraFOVUpdateComponent>();
            }
            if (entity.HasComponent <ShaftAimingCameraFOVRecoveringComponent>())
            {
                cameraNode.Entity.RemoveComponent <ShaftAimingCameraFOVRecoveringComponent>();
            }
        }