Пример #1
0
        public ActionCameraDirector(ActionCameraConfig pluginSettings, PluginCameraHelper helper, ref TimerHelper timerHelper)
        {
            this.player         = new LivPlayerEntity(helper, ref timerHelper);
            this.timerHelper    = timerHelper;
            this.cameraHelper   = helper;
            this.pluginSettings = pluginSettings;

            randomizer = new System.Random();
            player.SetOffsets(pluginSettings.forwardHorizontalOffset, pluginSettings.forwardVerticalOffset, pluginSettings.forwardDistance);

            OverShoulderCamera   = new ShoulderActionCamera(pluginSettings);
            FullBodyActionCamera = new FullBodyActionCamera(pluginSettings);
            FPSCamera            = new FPSCamera(pluginSettings, 0.2f);
            TacticalCamera       = new TopDownActionCamera(pluginSettings, 0.6f, 6f);

            SetCamera(OverShoulderCamera);
        }
Пример #2
0
        // Next to FPS Camera, simplest Camerda
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            cameraTarget = player.head.TransformPoint(offset);
            lookAtTarget = player.head.TransformPoint(lookAtOffset);
            PluginLog.Log("SIMPLE CAMERA", "" + lookAtOffset);
            // average between Head and Waist to avoid head from flipping the camera around so much.s
            lookAtTarget = (lookAtTarget + player.waist.TransformPoint(lookAtOffset)) / 2;

            if (pluginSettings.cameraVerticalLock)
            {
                lookAtTarget.y = (player.waist.position.y + player.head.position.y) / 2;
            }

            cameraTarget.y = Mathf.Clamp(cameraTarget.y, player.head.position.y * 0.2f, player.head.position.y * 1.2f);
        }
Пример #3
0
 abstract public void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget,
                                    LivPlayerEntity player, bool isCameraAlreadyPlaced);
Пример #4
0
 public virtual Quaternion GetRotation(Vector3 lookDirection, LivPlayerEntity player)
 {
     return(Quaternion.LookRotation(lookDirection));
 }
Пример #5
0
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            Vector3 cameraPositionOffsetTarget = offset;

            sbyte estimatedSide = (player.headRRadialDelta.x < 0 ? NEGATIVE_SBYTE : POSITIVE_SBYTE);

            if (!swappingSides && Mathf.Abs(player.headRRadialDelta.x) > pluginSettings.cameraBodySensitivity &&
                player.timerHelper.cameraActionTimer > GetBetweenTime() &&
                estimatedSide != currentSide)
            {
                PluginLog.Log("FullBodyActionCamera", "Swapping sides " + estimatedSide);
                swappingSides   = true;
                destinationSide = estimatedSide;
                player.timerHelper.ResetCameraActionTimer();
            }
            else if (swappingSides && player.timerHelper.cameraActionTimer > GetBetweenTime())
            {
                swappingSides = false;
                currentSide   = destinationSide;

                PluginLog.Log("FullBodyActionCamera", "Done Swapping ");
                player.timerHelper.ResetCameraActionTimer();
            }

            if (swappingSides && pluginSettings.inBetweenCameraEnabled)
            {
                betweenCamera.ApplyBehavior(ref cameraTarget, ref lookAtTarget, player, isCameraAlreadyPlaced);
            }
            else
            {
                sbyte settingsReverse = pluginSettings.reverseFBT ? NEGATIVE_SBYTE : POSITIVE_SBYTE;
                cameraPositionOffsetTarget.x = -currentSide *Mathf.Abs(cameraPositionOffsetTarget.x) * settingsReverse;

                cameraTarget = player.head.TransformPoint(cameraPositionOffsetTarget);

                // Floor and Ceiling Avoidance. Camera should not be too high or too low in ratio to player head position
                cameraTarget.y = Mathf.Clamp(cameraTarget.y, player.head.position.y * 0.2f, player.head.position.y * 1.2f);


                lookAtTarget = (player.waist.position + player.head.TransformPoint(lookAtOffset)) / 2;

                if (pluginSettings.cameraVerticalLock)
                {
                    lookAtTarget.y = (player.waist.position.y + player.head.position.y) / 2;
                }
            }
        }
Пример #6
0
 public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
 {
     cameraTarget = player.head.position + offset;
     lookAtTarget = player.head.position;
 }
Пример #7
0
 public override Quaternion GetRotation(Vector3 lookDirection, LivPlayerEntity player)
 {
     return(Quaternion.Slerp(Quaternion.LookRotation(player.head.forward, player.head.up), sightsCamera.GetRotation(lookDirection, player), blend));
 }
Пример #8
0
        /*
         *
         * Logic for Scope should only occur when
         */
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            Vector3 averageHandPosition = player.handAverage;
            Vector3 handDirection;

            if (pluginSettings.rightHandDominant)
            {
                handDirection = (player.leftHand.position - player.rightHand.position).normalized;
            }
            else
            {
                handDirection = (player.rightHand.position - player.leftHand.position).normalized;
            }

            // If Hands close enough, and aligned, then do the thing, if not then
            float handDistance               = Vector3.Distance(player.rightHand.position, player.leftHand.position);
            bool  isWithinTwoHandedUse       = handDistance > pluginSettings.cameraGunMinTwoHandedDistance && handDistance < pluginSettings.cameraGunMaxTwoHandedDistance;
            bool  isHeadWithinAimingDistance = Vector3.Distance(averageHandPosition, player.head.position) < pluginSettings.cameraGunHeadDistanceTrigger;
            bool  isAimingTwoHandedForward   = Mathf.Rad2Deg * PluginUtility.GetConeAngle(player.head.position, averageHandPosition + handDirection * 4f, player.head.right) <
                                               pluginSettings.cameraGunHeadAlignAngleTrigger;

            if (!pluginSettings.disableGunCamera && Mathf.Abs(player.headRRadialDelta.x) < pluginSettings.controlMovementThreshold / 2 &&
                isWithinTwoHandedUse && isHeadWithinAimingDistance && isAimingTwoHandedForward)
            {
                ironSightsEnabled = true;
                // Should have a smooth transition between Iron Sights and non iron sights.
                sightsCamera.ApplyBehavior(ref cameraTarget, ref lookAtTarget, player, isCameraAlreadyPlaced);
                blend += (pluginSettings.cameraGunSmoothing / 2) * Time.deltaTime;
            }
            else
            {
                ironSightsEnabled = false;
                cameraTarget      = player.head.TransformPoint(offset);
                lookAtTarget      = player.head.TransformPoint(lookAtOffset);


                blend -= 1 / (pluginSettings.cameraGunSmoothing / 2) * Time.deltaTime;
            }

            blend = Mathf.Clamp(blend, 0, 1.0f);
        }
Пример #9
0
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            /**
             * Logic for betweenCamera
             * When Camera is triggering swap sides (when player moves head fast enough, and the direction does not match previous)
             *  use only the betweenCamera behavior.
             *  once timeBetween Change has been fully realized, then start applying current behavior as planned.
             */

            sbyte estimatedSide = (player.headRRadialDelta.x < 0 ? NEGATIVE_SBYTE : POSITIVE_SBYTE);

            if (!swappingSides && Mathf.Abs(player.headRRadialDelta.x) > pluginSettings.cameraShoulderSensitivity &&
                player.timerHelper.cameraActionTimer > GetBetweenTime() &&
                estimatedSide != currentSide)
            {
                PluginLog.Log("ShoulderCamera", "Swapping sides " + estimatedSide);
                swappingSides   = true;
                destinationSide = estimatedSide;
                player.timerHelper.ResetCameraActionTimer();
            }
            else if (swappingSides && player.timerHelper.cameraActionTimer > GetBetweenTime())
            {
                swappingSides = false;
                currentSide   = destinationSide;
                PluginLog.Log("ShoulderCamera", "Done Swapping");
                player.timerHelper.ResetCameraActionTimer();
            }

            if (swappingSides && pluginSettings.inBetweenCameraEnabled)
            {
                betweenCamera.ApplyBehavior(ref cameraTarget, ref lookAtTarget, player, isCameraAlreadyPlaced);
            }
            else
            {
                Vector3 cameraOffsetTarget = offset;
                sbyte   settingsReverse    = pluginSettings.reverseShoulder ? NEGATIVE_SBYTE : POSITIVE_SBYTE;

                cameraOffsetTarget.x = -currentSide *Mathf.Abs(cameraOffsetTarget.x) * settingsReverse;

                cameraTarget = player.head.TransformPoint(cameraOffsetTarget);

                // Floor and Ceiling Avoidance. Camera should not be too high or too low in ratio to player head position
                cameraTarget.y = Mathf.Clamp(cameraTarget.y, player.head.position.y * 0.2f, player.head.position.y * 1.2f);

                lookAtTarget = player.head.TransformPoint(lookAtOffset);

                if (pluginSettings.cameraVerticalLock)
                {
                    lookAtTarget.y = (player.waist.position.y + player.head.position.y) / 2;
                }
            }
        }
Пример #10
0
        public override void ApplyBehavior(ref Vector3 cameraTarget, ref Vector3 lookAtTarget, LivPlayerEntity player, bool isCameraAlreadyPlaced)
        {
            // Automatic determination which is closest?
            if (pluginSettings.rightHandDominant)
            {
                dominantHand    = player.rightHand;
                nonDominantHand = player.leftHand;
                dominantEye     = player.rightEye;
            }
            else
            {
                dominantHand    = player.leftHand;
                nonDominantHand = player.rightHand;
                dominantEye     = player.leftEye;
            }

            lookAtDirection = (nonDominantHand.position - new Vector3(0, pluginSettings.cameraGunEyeVerticalOffset, 0) - dominantHand.position);
            // We will override the lookAtTarget and use GetRotation to define the actual rotation.
            lookAtTarget = Vector3.zero;
            cameraTarget = dominantEye;
        }
Пример #11
0
 public override Quaternion GetRotation(Vector3 lookDirection, LivPlayerEntity player)
 {
     return(Quaternion.LookRotation(lookAtDirection, player.head.up));
 }