Ejemplo n.º 1
0
        public void OnAction(PlayerEntity player, ICameraMotorState state)
        {
            for (int i = 1; i < 32; i++)
            {
                if (JudgeAction(CameraActionType.Enter, i))// &&
                {
                    if (EnterActionList.ContainsKey(i))
                    {
                        foreach (var act in EnterActionList[i])
                        {
                            act(player, state);
                        }
//                        EnterActionList[i](player, state);
                    }
                }
                if (JudgeAction(CameraActionType.Leave, i))// &&
                {
                    if (LeaveActionList.ContainsKey(i))
                    {
                        foreach (var act in LeaveActionList[i])
                        {
                            act(player, state);
                        }
                    }
                }
//                        LeaveActionList[i](player, state);
            }
        }
Ejemplo n.º 2
0
 public bool IsActive(ICameraMotorInput input, ICameraMotorState state)
 {
     return(input.NextPostureState == PostureInConfig.Stand ||
            input.NextPostureState == PostureInConfig.Jump ||
            input.NextPostureState == PostureInConfig.Land ||
            input.NextPostureState == PostureInConfig.ProneToStand);
 }
Ejemplo n.º 3
0
        public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
        {
            if (state.IsFree())
            {
                return(false);
            }
            if (!state.GetMainConfig().CanSwitchView)
            {
                return(false);
            }
            //if (state.ViewMode.Equals(ECameraViewMode.FirstPerson) && (input.ChangeCamera))
            if (state.ViewMode == ECameraViewMode.FirstPerson && input.FilteredChangeCamera)
            {
                return(false);
            }
            //if (state.ViewMode.Equals(ECameraViewMode.ThirdPerson) &&  input.ChangeCamera)
            if (state.ViewMode == ECameraViewMode.ThirdPerson && input.FilteredChangeCamera)
            {
                return(true);
            }

            //if (state.ViewMode.Equals(ECameraViewMode.GunSight) && input.IsCameraFocus && state.LastViewMode.Equals(ECameraViewMode.FirstPerson))
            if (state.ViewMode.Equals(ECameraViewMode.GunSight) && (input.FilteredCameraFocus || input.ForceChangeGunSight || input.ForceInterruptGunSight) && state.LastViewMode.Equals(ECameraViewMode.FirstPerson))
            {
                return(true);
            }

            return(state.ViewMode == ECameraViewMode.FirstPerson);
        }
Ejemplo n.º 4
0
        public override void UpdatePlayerRotation(ICameraMotorInput input, ICameraMotorState state, PlayerEntity player)
        {
            if (!input.IsDead && CanRotatePlayer(state))
            {
                float newDeltaAngle = input.DeltaYaw;

                if (player.playerRotateLimit.LimitAngle)
                {
                    var candidateAngle = YawPitchUtility.Normalize(player.orientation.Yaw) + input.DeltaYaw;
                    candidateAngle = Mathf.Clamp(candidateAngle, player.playerRotateLimit.LeftBound,
                                                 player.playerRotateLimit.RightBound);
                    player.orientation.Yaw = CalculateFrameVal(candidateAngle, 0f, _config.YawLimit);
                }
                else
                {
                    player.orientation.Yaw = CalculateFrameVal(player.orientation.Yaw, newDeltaAngle, _config.YawLimit);
                }

                //               newDeltaAngle = player.characterContoller.Value.PreRotateAngle(player.orientation.ModelView, player.position.Value,input.DeltaYaw, input.FrameInterval * 0.001f);

//                Logger.DebugFormat("deltaAngle:{0},prevAngle:{1}, curYaw:{2}, input.DeltaYaw:{4},player.orientationLimit.LimitAngle:{5}",
//                    newDeltaAngle,
//                    player.orientation.Yaw,
//                    CalculateFrameVal(player.orientation.Yaw, newDeltaAngle, _config.YawLimit),
//                    input.DeltaYaw
//                );



                var deltaPitch = HandlePunchPitch(player, input);
                player.orientation.Pitch =
                    CalculateFrameVal(player.orientation.Pitch, deltaPitch, _config.PitchLimit);
            }
        }
Ejemplo n.º 5
0
 public void CallLeaveActions(PlayerEntity player, ICameraMotorState state)
 {
     if (LeaveActions != null)
     {
         LeaveActions(player, state);
     }
 }
Ejemplo n.º 6
0
        public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
        {
            if (state.IsFree())
            {
                return(false);
            }
            if (!state.GetMainConfig().CanSwitchView)
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.FirstPerson && input.FilteredChangeCamera)
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.ThirdPerson && input.FilteredChangeCamera)
            {
                return(true);
            }

            if (state.ViewMode == ECameraViewMode.GunSight && (input.FilteredCameraFocus || input.InterruptCameraFocus) && state.LastViewMode == ECameraViewMode.FirstPerson)
            {
                return(true);
            }

            if (input.LastViewByOrder == (short)ECameraViewMode.FirstPerson)
            {
                return(true);
            }
            return(state.ViewMode == ECameraViewMode.FirstPerson);
        }
Ejemplo n.º 7
0
 public void CallEnterActions(PlayerEntity player, ICameraMotorState state)
 {
     if (EnterActions != null)
     {
         EnterActions(player, state);
     }
 }
Ejemplo n.º 8
0
        public override void CalcOutput(PlayerEntity player,
                                        ICameraMotorInput input,
                                        ICameraMotorState state,
                                        SubCameraMotorState subState,
                                        DummyCameraMotorOutput output,
                                        ICameraNewMotor last,
                                        int clientTime)
        {
            output.ArchorEulerAngle = Vector3.zero;
            if (last.ModeId == (short)ECameraFreeMode.On)
            {
                var elapsedPercent = ElapsedPercent(clientTime, subState.ModeTime, _transitionTime);

                if (elapsedPercent < 1)
                {
                    output.EulerAngle = Vector3.Lerp(new Vector3(state.LastFreePitch, state.LastFreeYaw, 0), Vector3.zero, elapsedPercent);
                    state.FreeYaw     = output.ArchorEulerAngle.y;
                    state.FreePitch   = output.ArchorEulerAngle.x;

//                    output.ArchorPostOffset =
//                        Vector3.Lerp( -state.GetMainConfig().ScreenOffset,Vector3.zero, elapsedPercent);
                }
                else
                {
                    output.EulerAngle = Vector3.zero;
                    state.FreeYaw     = output.ArchorEulerAngle.y;
                    state.FreePitch   = output.ArchorEulerAngle.x;
                }
            }
        }
Ejemplo n.º 9
0
 private bool CanRotatePlayer(ICameraMotorState state)
 {
     if (state.IsFree())
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 10
0
        private ICameraNewMotor SetNextMotor(PlayerEntity player, SubCameraMotorType type,
                                             ICameraMotorState stat, DummyCameraMotorInput input
                                             )
        {
            var dict     = _motors.GetDict(type);
            var subState = _state.Get(type);

            if (!dict.ContainsKey(subState.NowMode))
            {
                return(null);
            }
            var oldMotor = dict[subState.NowMode];

            var excludes  = oldMotor.ExcludeNextMotor();
            var nextMotor = oldMotor;
            var orderId   = int.MinValue;

            foreach (var motor in dict.Values)
            {
                if (excludes.Contains(motor.ModeId))
                {
                    continue;
                }
                if (motor.IsActive(input, stat))
                {
                    if (motor.Order > orderId)
                    {
                        nextMotor = motor;
                        orderId   = motor.Order;
                    }
                }
            }

            if (nextMotor.ModeId != oldMotor.ModeId || subState.ModeTime == 0)
            {
                Logger.DebugFormat("{0} Levae :{1} To {2} with input{3}", _cmdSeq, oldMotor.ModeId, nextMotor.ModeId,
                                   input);

                CameraActionManager.SetActionCode(CameraActionType.Leave, type, oldMotor.ModeId);
                CameraActionManager.SetActionCode(CameraActionType.Enter, type, nextMotor.ModeId);

                subState.NowMode  = (byte)nextMotor.ModeId;
                subState.ModeTime = player.time.ClientTime;
                subState.LastMode = (byte)oldMotor.ModeId;
            }

            if (type == SubCameraMotorType.View)
            {
                if (CanChangeViewMotor(input))
                {
                    UpdateOrderViewMode(player, nextMotor.ModeId);
                }
            }

            return(oldMotor);
        }
Ejemplo n.º 11
0
 public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
 {
     if (state.GetMainMotor().NowMode == (short)ECameraPoseMode.AirPlane)
     {
         return(false);
     }
     return(_isRight
         ? input.LeanState == LeanInConfig.PeekRight && state.LastPeekPercent >= 0
         : input.LeanState == LeanInConfig.PeekLeft && state.LastPeekPercent <= 0);
 }
Ejemplo n.º 12
0
 private bool CanRotatePlayer(ICameraMotorState state)
 {
     if (state.IsFristPersion() && state.GetMainMotor().NowMode == (byte)ECameraPoseMode.Climb)
     {
         return(false);
     }
     if (state.IsFree())
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 13
0
 public static float GetGunSightSpeed(PlayerEntity player, ICameraMotorState state)
 {
     if (state.ViewMode == ECameraViewMode.GunSight)
     {
         var upperRail = player.WeaponController().HeldWeaponAgent.BaseComponent.UpperRail;
         if (upperRail > 0)
         {
             return(SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(upperRail).FovMove);
         }
         return(0.9f);
     }
     return(1f);
 }
Ejemplo n.º 14
0
        private DummyCameraMotorOutput CalcSubFinalCamera(PlayerEntity player, ICameraMotorInput input,
                                                          ICameraMotorState state,
                                                          Dictionary <int, ICameraNewMotor> dict, SubCameraMotorState subState, int clientTime)
        {
            _tempOutput.Init();
            if (!dict.ContainsKey(subState.NowMode))
            {
                return(_tempOutput);
            }
            var oldMotor = dict[subState.LastMode];
            var nowMotor = dict[subState.NowMode];

            nowMotor.CalcOutput(player, input, state, subState, _tempOutput, oldMotor, clientTime);
            Logger.DebugFormat("CalcSubFinalCamera:{0}", nowMotor, subState.NowMode);
            return(_tempOutput);
        }
Ejemplo n.º 15
0
        public void Generate(PlayerEntity player, IUserCmd usercmd, ICameraMotorState state, bool lockView)
        {
            var speedRatio = CameraUtility.GetGunSightSpeed(player, state);

            DeltaYaw   = usercmd.DeltaYaw * speedRatio;
            DeltaPitch = usercmd.DeltaPitch * speedRatio;
            if (usercmd.FilteredInput != null)
            {
                IsCameraFree         = usercmd.FilteredInput.IsInput(EPlayerInput.IsCameraFree);
                FilteredChangeCamera = lockView ? false : usercmd.FilteredInput.IsInput(EPlayerInput.ChangeCamera);
                FilteredCameraFocus  = usercmd.FilteredInput.IsInput(EPlayerInput.IsCameraFocus);
            }
            FrameInterval        = usercmd.FrameInterval;
            ChangeCamera         = lockView ? false :usercmd.ChangeCamera;
            IsCameraFocus        = usercmd.IsCameraFocus;
            IsCmdRun             = usercmd.IsRun;
            IsCmdMoveVertical    = usercmd.MoveVertical > 0;
            InterruptCameraFocus = usercmd.IsUseAction || usercmd.IsTabDown;

            if (player.hasStateInterface)
            {
                CurrentPostureState = player.stateInterface.State.GetCurrentPostureState();
                NextPostureState    = player.stateInterface.State.GetNextPostureState();
                LeanState           = player.stateInterface.State.GetNextLeanState();
                ActionState         = player.stateInterface.State.GetActionState();
                ActionKeepState     = player.stateInterface.State.GetActionKeepState();
            }
            else if (player.hasThirdPersonAppearance)
            {
                CurrentPostureState = (PostureInConfig)player.thirdPersonAppearance.PostureValue;
                NextPostureState    = (PostureInConfig)player.thirdPersonAppearance.NextPostureValue;
                ActionState         = (ActionInConfig)player.thirdPersonAppearance.ActionValue;
            }

            IsAirPlane          = player.gamePlay.GameState == GameState.AirPlane;
            IsDriveCar          = player.IsOnVehicle();
            IsDead              = player.gamePlay.IsLifeState(EPlayerLifeState.Dead);
            CanWeaponGunSight   = player.WeaponController().HeldWeaponAgent.CanWeaponSight;
            ArchorPitch         = YawPitchUtility.Normalize(player.cameraArchor.ArchorEulerAngle.x);
            ArchorYaw           = YawPitchUtility.Normalize(player.cameraArchor.ArchorEulerAngle.y);
            IsParachuteAttached = player.hasPlayerSkyMove && player.playerSkyMove.IsParachuteAttached;
            LastViewByOrder     = player.gamePlay.LastViewModeByCmd;
            RoleId              = player.playerInfo.RoleModelId;
            LockViewByRoom      = lockView;
            ModelLoaded         = player.hasFirstPersonModel && player.hasThirdPersonModel;
            IsVariant           = JudgeVariant(player);
        }
Ejemplo n.º 16
0
        public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
        {
            if (input.IsDead)
            {
                return(false);
            }
            if (!input.CanWeaponGunSight)
            {
                return(false);
            }
            if (state.IsFree())
            {
                return(false);
            }
            var config = input.GetPoseConfig(state.GetMainMotor().NowMode);

            if (!config.CanSwitchView)
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.GunSight &&
                (input.FilteredCameraFocus || input.InterruptCameraFocus))
            {
                if (input.InterruptCameraFocus)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("ForceInterruptGunSight");
                    }
                }
                return(false);
            }
            if (state.ViewMode == ECameraViewMode.ThirdPerson && !input.InterruptCameraFocus && (input.FilteredCameraFocus))
            {
                // DebugUtil.MyLog("Change cmr to gunsight");
                return(true);
            }

            if (state.ViewMode == ECameraViewMode.FirstPerson && !input.InterruptCameraFocus && (input.FilteredCameraFocus))
            {
                return(true);
            }

            return(state.ViewMode == ECameraViewMode.GunSight);
        }
Ejemplo n.º 17
0
        public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
        {
            if (input.IsDead)
            {
                return(false);
            }
            if (!input.CanWeaponGunSight)
            {
                return(false);
            }
            if (state.IsFree())
            {
                return(false);
            }
            if (!state.GetMainConfig().CanSwitchView)
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.GunSight &&
                (input.FilteredCameraFocus || input.ForceChangeGunSight || input.ForceInterruptGunSight))
            {
                if (input.ForceInterruptGunSight)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.Debug("ForceInterruptGunSight");
                    }
                }
                return(false);
            }

            //if (state.ViewMode.Equals(ECameraViewMode.ThirdPerson) &&  input.IsCameraFocus)
            if (state.ViewMode == ECameraViewMode.ThirdPerson && !input.ForceInterruptGunSight && (input.FilteredCameraFocus || input.ForceChangeGunSight))
            {
                return(true);
            }

            //if (state.ViewMode.Equals(ECameraViewMode.FirstPerson) && input.IsCameraFocus)
            if (state.ViewMode == ECameraViewMode.FirstPerson && !input.ForceInterruptGunSight && (input.FilteredCameraFocus || input.ForceChangeGunSight))
            {
                return(true);
            }

            return(state.ViewMode == ECameraViewMode.GunSight);
        }
Ejemplo n.º 18
0
        public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
        {
            var config = input.GetPoseConfig(state.GetMainMotor().NowMode);

            if (!config.CanSwitchView)
            {
                return(false);
            }
            if (input.IsVariant)
            {
                return(false);
            }
            if (!SharedConfig.IsOffline && input.LockViewByRoom && input.ModelLoaded && !input.IsDead)
            {
                return(true);
            }

            if (state.IsFree())
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.FirstPerson && input.FilteredChangeCamera)
            {
                return(false);
            }

            if (state.ViewMode == ECameraViewMode.ThirdPerson && input.FilteredChangeCamera)
            {
                return(true);
            }

            if (state.ViewMode == ECameraViewMode.GunSight &&
                (input.FilteredCameraFocus || input.InterruptCameraFocus) &&
                state.LastViewMode == ECameraViewMode.FirstPerson)
            {
                return(true);
            }

            if (input.LastViewByOrder == (short)ECameraViewMode.FirstPerson)
            {
                return(true);
            }
            return(state.ViewMode == ECameraViewMode.FirstPerson);
        }
Ejemplo n.º 19
0
 public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
 {
     if (state.IsFristPersion())
     {
         return(false);
     }
     if (state.GetMainMotor().NowMode == (short)ECameraPoseMode.Dead)
     {
         return(false);
     }
     if (state.PeekMode != ECameraPeekMode.Off)
     {
         return(false);
     }
     return(input.IsCameraFree || state.GetMainMotor().NowMode == (short)ECameraPoseMode.AirPlane ||
            state.GetMainMotor().NowMode == (short)ECameraPoseMode.Parachuting || input.IsDriveCar ||
            state.GetMainMotor().NowMode == (short)ECameraPoseMode.ParachutingOpen);
 }
Ejemplo n.º 20
0
        public override void UpdatePlayerRotation(ICameraMotorInput input, ICameraMotorState state, PlayerEntity player)
        {
            if ((!input.IsDead || input.IsDead && player.gamePlay.IsObserving()) && CanRotatePlayer(state))
            {
                float newDeltaAngle = input.DeltaYaw;
                if (player.playerRotateLimit.LimitAngle)
                {
                    var candidateAngle = YawPitchUtility.Normalize(player.orientation.Yaw) + input.DeltaYaw;
                    candidateAngle = Mathf.Clamp(candidateAngle, player.playerRotateLimit.LeftBound,
                                                 player.playerRotateLimit.RightBound);
                    player.orientation.Yaw = CalculateFrameVal(candidateAngle, 0f, input.GetPoseConfig(_modeId).YawLimit);
                }
                else
                {
                    player.orientation.Yaw = CalculateFrameVal(player.orientation.Yaw, newDeltaAngle, input.GetPoseConfig(_modeId).YawLimit);
                }

                var deltaPitch = HandlePunchPitch(player, input);
                player.orientation.Pitch =
                    CalculateFrameVal(player.orientation.Pitch, deltaPitch, input.GetPoseConfig(_modeId).PitchLimit);
            }
        }
Ejemplo n.º 21
0
 public abstract void CalcOutput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state,
                                 SubCameraMotorState subState,
                                 DummyCameraMotorOutput output, ICameraNewMotor last, int clientTime);
Ejemplo n.º 22
0
 public override void UpdatePlayerRotation(ICameraMotorInput input, ICameraMotorState state, PlayerEntity player)
 {
 }
Ejemplo n.º 23
0
 public override void PreProcessInput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state)
 {
 }
Ejemplo n.º 24
0
        public override void CalcOutput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state, SubCameraMotorState subState,
                                        DummyCameraMotorOutput output, ICameraNewMotor last, int clientTime)
        {
            //  output.Rotation = Quaternion.EulerAngles(player.orientation.Pitch,0,player.orientation.Roll);
            if (input.ChangeCamera)
            {
                subState.LastMode = (byte)(subState.LastMode == (int)ECameraViewMode.FirstPerson
                    ? ECameraViewMode.ThirdPerson
                    : ECameraViewMode.FirstPerson);
            }
            var fov = player.WeaponController().HeldWeaponAgent.GetGameFov(player.oxygenEnergyInterface.Oxygen.InShiftState);

            if (fov <= 0)
            {
                Logger.ErrorFormat("Illegal fov value {0}", fov);
                return;
            }
            output.Fov = fov;
        }
Ejemplo n.º 25
0
 public abstract void PreProcessInput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state);
Ejemplo n.º 26
0
 public override bool IsActive(ICameraMotorInput input, ICameraMotorState state)
 {
     return(input.IsDriveCar);
 }
Ejemplo n.º 27
0
 public abstract void UpdatePlayerRotation(ICameraMotorInput input, ICameraMotorState state,
                                           PlayerEntity player);
Ejemplo n.º 28
0
 public abstract bool IsActive(ICameraMotorInput input, ICameraMotorState state);
Ejemplo n.º 29
0
 public override void CalcOutput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state, SubCameraMotorState subState,
                                 DummyCameraMotorOutput output, ICameraNewMotor last, int clientTime)
 {
     //output.Rotation = Quaternion.EulerAngles(player.orientation.Pitch,0,0);
     return;
 }
Ejemplo n.º 30
0
        public override void CalcOutput(PlayerEntity player, ICameraMotorInput input, ICameraMotorState state,
                                        SubCameraMotorState subState,
                                        DummyCameraMotorOutput output, ICameraNewMotor last, int clientTime)
        {
            var cameraAnchorOffset = Vector3.zero;
            var cameraDistance     = 0.0f;

            if (player.IsOnVehicle())
            {
                var controlledVehicle = player.controlledVehicle;
                cameraAnchorOffset = controlledVehicle.CameraAnchorOffset;
                cameraDistance     = controlledVehicle.CameraDistance;
            }

            output.Far              = _config.Far;
            output.ArchorOffset     = FinalArchorOffset + cameraAnchorOffset;
            output.ArchorPostOffset = FinalArchorPostOffset;
            output.Offset           = FinalOffset;
            output.Offset.z        -= cameraDistance;
            output.ArchorEulerAngle = FinalEulerAngle;
            output.Fov              = FinalFov;
        }