Exemplo n.º 1
0
        private void CalcuForNormal(IUserCmd cmd, PlayerEntity player, Vector3 archotRotation,
                                    CameraStateOutputNewComponent result)
        {
            DummyCameraMotorState.Convert(player.cameraStateNew, _state);

            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(_context, player, cmd, archotRotation.y, archotRotation.x);

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                SetNextMotor(player, type, _state, _input);
            }

            CameraActionManager.OnAction(player, _state);

            player.cameraStateUpload.EnterActionCode = CameraActionManager.GetActionCode(CameraActionType.Enter);
            player.cameraStateUpload.LeaveActionCode = CameraActionManager.GetActionCode(CameraActionType.Leave);
            CameraActionManager.ClearActionCode();

            player.cameraStateNew.CameraMotorInput     = player.cameraStateNew.LastCameraMotorInput;
            player.cameraStateNew.LastCameraMotorInput = _input;

            CalcFinalOutput(player, (DummyCameraMotorInput)player.cameraStateNew.LastCameraMotorInput,
                            result, _state);
        }
Exemplo n.º 2
0
        public GunSightMotor(Contexts contexts)
        {
            _contexts = contexts;
            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) =>
            {
                if (player.hasAppearanceInterface)
                {
                    if (!player.appearanceInterface.Appearance.IsFirstPerson)
                    {
                        player.appearanceInterface.Appearance.SetFirstPerson();
                        player.characterBoneInterface.CharacterBone.SetFirstPerson();
                        player.UpdateCameraArchorPostion();
                    }
                    var speed = player.WeaponController().HeldWeaponAgent.CmrFocusSpeed;
                    player.stateInterface.State.SetSight(speed);
                    if (player.AudioController() != null)
                    {
                        player.AudioController().PlaySimpleAudio(EAudioUniqueId.SightOpen, true);
                    }
                }
            });

            CameraActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId,
                                          (player, state) =>
            {
                var speed = player.WeaponController().HeldWeaponAgent.CmrFocusSpeed;
                player.stateInterface.State.CancelSight(speed);
                if (player.AudioController() != null)
                {
                    player.AudioController().PlaySimpleAudio(EAudioUniqueId.SightClose, true);
                }
            });
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public FirstViewMotor()
 {
     CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) =>
     {
         if (player.hasAppearanceInterface && !player.appearanceInterface.Appearance.IsFirstPerson)
         {
             player.appearanceInterface.Appearance.SetFirstPerson();
             player.characterBoneInterface.CharacterBone.SetFirstPerson();
         }
     });
 }
Exemplo n.º 5
0
        public static Motors CraeteMotors(Contexts contexts, CameraConfig config)
        {
            Motors motors = new Motors();

            var pose = motors.GetDict(SubCameraMotorType.Pose);

//            config.GetCameraConfigItem(ECameraViewMode.ThirdPerson)
            pose[(int)ECameraPoseMode.Stand]       = new NormalPoseMotor(ECameraPoseMode.Stand, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ThirdPersonActice());
            pose[(int)ECameraPoseMode.Crouch]      = new NormalPoseMotor(ECameraPoseMode.Crouch, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new CrouchActice());
            pose[(int)ECameraPoseMode.Prone]       = new NormalPoseMotor(ECameraPoseMode.Prone, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ProneActice());
            pose[(int)ECameraPoseMode.Swim]        = new NormalPoseMotor(ECameraPoseMode.Swim, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new SwimActice());
            pose[(int)ECameraPoseMode.Dying]       = new NormalPoseMotor(ECameraPoseMode.Dying, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new DyingActice());
            pose[(int)ECameraPoseMode.Dead]        = new DeadPoseMotor(ECameraPoseMode.Dead, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new DeadActice(), config.DeadConfig);
            pose[(int)ECameraPoseMode.Parachuting] = new NormalPoseMotor(ECameraPoseMode.Parachuting, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ParachutingActice());

            pose[(int)ECameraPoseMode.ParachutingOpen] = new NormalPoseMotor(ECameraPoseMode.ParachutingOpen, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ParachutingOpenActice());

            pose[(int)ECameraPoseMode.Gliding]  = new GlidingPoseMotor(ECameraPoseMode.Gliding, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new GlidingActice());
            pose[(int)ECameraPoseMode.DriveCar] = new DrivePoseMotor(ECameraPoseMode.DriveCar, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), contexts.vehicle, contexts.freeMove);
            pose[(int)ECameraPoseMode.AirPlane] = new AirplanePoseMotor(ECameraPoseMode.AirPlane, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), contexts.vehicle, contexts.freeMove);
            pose[(int)ECameraPoseMode.Climb]    = new NormalPoseMotor(ECameraPoseMode.Climb, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new ClimbActive());

            pose[(int)ECameraPoseMode.Rescue] = new NormalPoseMotor(ECameraPoseMode.Rescue, config, new HashSet <ECameraPoseMode>(CommonIntEnumEqualityComparer <ECameraPoseMode> .Instance), new RescueActive());

            var free = motors.GetDict(SubCameraMotorType.Free);

            free[(int)ECameraFreeMode.On]  = new FreeOnMotor();
            free[(int)ECameraFreeMode.Off] = new FreeOffMotor(config.FreeConfig.TransitionTime);

            var peek = motors.GetDict(SubCameraMotorType.Peek);

            peek[(int)ECameraPeekMode.Off]   = new PeekOffMotor(config.PeekConfig.TransitionTime);
            peek[(int)ECameraPeekMode.Left]  = new PeekOnMotor(false, config.PeekConfig);
            peek[(int)ECameraPeekMode.Right] = new PeekOnMotor(true, config.PeekConfig);

            var view = motors.GetDict(SubCameraMotorType.View);

            view[(int)ECameraViewMode.FirstPerson] = new FirstViewMotor();
            view[(int)ECameraViewMode.GunSight]    = new GunSightMotor(contexts);
            view[(int)ECameraViewMode.ThirdPerson] = new ThirdViewMotor();

            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.Pose,
                                          (int)ECameraPoseMode.Parachuting, (player, state) =>
            {
                var cameraEulerAngle = player.cameraFinalOutputNew.EulerAngle;
                var carEulerAngle    = player.cameraArchor.ArchorEulerAngle;
                var t           = cameraEulerAngle - carEulerAngle;
                state.FreeYaw   = t.y;
                state.FreePitch = t.x;
            });

            return(motors);
        }
Exemplo n.º 6
0
        public DeadPoseMotor(ECameraPoseMode modeId, CameraConfigItem config, HashSet <ECameraPoseMode> excludes, IMotorActive active, DeadCameraConfig deadConfig) : base(modeId, config, excludes, active)
        {
            _config = deadConfig;

            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.Pose, (int)modeId,
                                          (player, state) =>
            {
                player.orientation.Pitch = 0;
                Debug.Log("Enter dead pose");
            });
            _finalRotation = deadConfig.Roatation;
        }
Exemplo n.º 7
0
        public DrivePoseMotor(ECameraPoseMode modeId,
                              CameraConfigItem config,
                              HashSet <ECameraPoseMode> excludes,
                              VehicleContext vehicleContext,
                              FreeMoveContext freeMoveContext

                              )
        {
            _modeId = (short)modeId;

            this.excludes = new HashSet <short>();
            foreach (var e in excludes)
            {
                this.excludes.Add((short)e);
            }

            _config = config;

            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.Pose, (int)modeId,
                                          (player, state) =>
            {
                if (player.IsOnVehicle())
                {
                    var vehicle = vehicleContext.GetEntityWithEntityKey(player.controlledVehicle.EntityKey);
                    player.controlledVehicle.CameraAnchorOffset    = vehicle.vehicleAssetInfo.CameraAnchorOffset;
                    player.controlledVehicle.CameraDistance        = vehicle.vehicleAssetInfo.CameraDistance;
                    player.controlledVehicle.CameraRotationDamping = vehicle.vehicleAssetInfo.CameraRotationDamping;
                }

                var cameraEulerAngle = player.cameraFinalOutputNew.EulerAngle;

                var carEulerAngle = player.cameraArchor.ArchorEulerAngle;

                var t           = cameraEulerAngle - carEulerAngle;
                state.FreeYaw   = t.y;
                state.FreePitch = t.x;
            });
            CameraActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.Pose, (int)modeId,
                                          (player, state) =>
            {
                var rotation             = player.cameraFinalOutputNew.EulerAngle;
                player.orientation.Yaw   = YawPitchUtility.Normalize(rotation.y);
                player.orientation.Pitch = YawPitchUtility.Normalize(rotation.x);

                state.LastFreePitch = 0;
                state.LastFreeYaw   = 0;
                state.FreeYaw       = 0f;
                state.FreePitch     = 0f;
            });
        }
Exemplo n.º 8
0
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            _cmdSeq = cmd.Seq;
            PlayerEntity player = owner.OwnerEntity as PlayerEntity;

            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }

            DummyCameraMotorState.Convert(player.cameraStateNew, _state);
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;
            var archotRotation           = player.cameraArchor.ArchorEulerAngle;

            _input.Generate(player, cmd, archotRotation.y, archotRotation.x);

            //if (_input.IsChange(player.cameraStateNew.LastCameraMotorInput))
            {
                foreach (SubCameraMotorType i in _subCameraMotorTypeArray)
                {
                    var type = i;
                    SetNextMotor(player, type, _state, _input);
                }
            }

            CameraActionManager.OnAction(player, _state);

            player.cameraStateUpload.EnterActionCode = CameraActionManager.GetActionCode(CameraActionType.Enter);
            player.cameraStateUpload.LeaveActionCode = CameraActionManager.GetActionCode(CameraActionType.Leave);
            CameraActionManager.ClearActionCode();

            player.cameraStateNew.CameraMotorInput     = player.cameraStateNew.LastCameraMotorInput;
            player.cameraStateNew.LastCameraMotorInput = _input;

            CalcFinalOutput(player, (DummyCameraMotorInput)player.cameraStateNew.LastCameraMotorInput,
                            player.cameraStateOutputNew);
            DummyCameraMotorState.Convert(_state, player.cameraStateNew);

            CopyStateToUploadComponent(player.cameraStateNew, player.cameraStateUpload);
            player.cameraStateUpload.ArchorType = (Byte)player.cameraArchor.ArchorType;
        }
Exemplo n.º 9
0
        public void ExecuteUserCmd(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = owner.OwnerEntity as PlayerEntity;

            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }

            CopyClientStateToComponent(player.cameraStateUpload, player.cameraStateNew);
            player.cameraArchor.ArchorType = (ECameraArchorType)player.cameraStateUpload.ArchorType;

            CameraActionManager.CopyActionCode(CameraActionType.Enter, player.cameraStateUpload.EnterActionCode);
            CameraActionManager.CopyActionCode(CameraActionType.Leave, player.cameraStateUpload.LeaveActionCode);
            CameraActionManager.OnAction(player, _state);
        }
Exemplo n.º 10
0
        public GunSightMotor()
        {
            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) =>
            {
                if (player.hasAppearanceInterface)
                {
                    if (!player.appearanceInterface.Appearance.IsFirstPerson)
                    {
                        player.appearanceInterface.Appearance.SetFirstPerson();
                        player.characterBoneInterface.CharacterBone.SetFirstPerson();
                    }
                    var speed = player.weaponLogic.Weapon.GetFocusSpeed();
                    player.stateInterface.State.SetSight(speed);
                }
            });

            CameraActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId,
                                          (player, state) =>
            {
                var speed = player.weaponLogic.Weapon.GetFocusSpeed();
                player.stateInterface.State.CancelSight(speed);
            });
        }
Exemplo n.º 11
0
        public GunSightMotor(Contexts contexts)
        {
            _contexts = contexts;
            CameraActionManager.AddAction(CameraActionType.Enter, SubCameraMotorType.View, (int)ModeId, (player, state) =>
            {
                if (player.hasAppearanceInterface)
                {
                    if (!player.appearanceInterface.Appearance.IsFirstPerson)
                    {
                        player.appearanceInterface.Appearance.SetFirstPerson();
                        player.characterBoneInterface.CharacterBone.SetFirstPerson();
                    }
                    var speed = player.WeaponController().HeldWeaponAgent.FocusSpeed;
                    player.stateInterface.State.SetSight(speed);
                }
            });

            CameraActionManager.AddAction(CameraActionType.Leave, SubCameraMotorType.View, (int)ModeId,
                                          (player, state) =>
            {
                var speed = player.WeaponController().HeldWeaponAgent.FocusSpeed;
                player.stateInterface.State.CancelSight(speed);
            });
        }