Example #1
0
        private void UpdateCamera(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = owner.OwnerEntity as PlayerEntity;

            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }
//            var finalOutput = player.cameraStateOutputNew;
            DummyCameraMotorState.Convert(player.cameraStateNew, _state);


            var archotRotation = player.cameraArchor.ArchorEulerAngle;

            if (player.cameraStateNew.CameraMotorInput == null)
            {
                player.cameraStateNew.CameraMotorInput = new DummyCameraMotorInput();
            }
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(player, cmd, archotRotation.y, archotRotation.x);
            foreach (SubCameraMotorType i in _subCameraMotorTypeArray)
            {
                var type = i;
                PreProcessInput(player, _input, _motors.GetDict(type), _state.Get(type), _state);
            }

            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
        }
Example #2
0
        private void Handle(PlayerEntity player, IUserCmd cmd)
        {
            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }

            DummyCameraMotorState.Convert(player.cameraStateNew, _state);

            var archotRotation = player.cameraArchor.ArchorEulerAngle;

            if (player.cameraStateNew.CameraMotorInput == null)
            {
                player.cameraStateNew.CameraMotorInput = new DummyCameraMotorInput();
            }
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

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

            for (int i = 0; i < (int)SubCameraMotorType.End; i++)
            {
                var type = (SubCameraMotorType)i;
                PreProcessInput(player, _input, _motors.GetDict(type), _state.Get(type), _state);
            }
            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
        }
Example #3
0
        private void Handle(PlayerEntity player, IUserCmd cmd)
        {
            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }
            if (player.cameraStateNew.CameraMotorInput == null)
            {
                player.cameraStateNew.CameraMotorInput = new DummyCameraMotorInput();
            }

            DummyCameraMotorState.Convert(player.cameraStateNew, _state);
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

            _input.Generate(player, cmd, _state, LockView);

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

            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
        }
 public CameraPreUpdateSystem(Contexts contexts, Motors m)
 {
     _vehicleContext  = contexts.vehicle;
     _freeMoveContext = contexts.freeMove;
     _contexts        = contexts;
     _motors          = m;
     _state           = new DummyCameraMotorState(m);
 }
Example #5
0
 public ClientCameraPreUpdateSystem(VehicleContext vehicleContext, FreeMoveContext freeMoveContext, PlayerContext playerContext, Motors m)
 {
     _vehicleContext          = vehicleContext;
     _freeMoveContext         = freeMoveContext;
     _motors                  = m;
     _playerContext           = playerContext;
     _state                   = new DummyCameraMotorState(m);
     _subCameraMotorTypeArray = Enum.GetValues(typeof(SubCameraMotorType));
 }
Example #6
0
 public ClientCameraPreUpdateSystem(Contexts contexts, Motors m)
 {
     _vehicleContext          = contexts.vehicle;
     _freeMoveContext         = contexts.freeMove;
     _motors                  = m;
     _playerContext           = contexts.player;
     _contexts                = contexts;
     _state                   = new DummyCameraMotorState(m);
     _subCameraMotorTypeArray = Enum.GetValues(typeof(SubCameraMotorType));
 }
Example #7
0
 public CameraPreUpdateSystem(VehicleContext vehicleContext, FreeMoveContext freeMoveContext, Motors m)
 {
     _vehicleContext  = vehicleContext;
     _freeMoveContext = freeMoveContext;
     _motors          = m;
     _state           = new DummyCameraMotorState(m);
     foreach (SubCameraMotorType value in Enum.GetValues(typeof(SubCameraMotorType)))
     {
         _subCameraMotorTypeArray.Add(value);
     }
 }
 public static void Convert(CameraStateNewComponent inData, DummyCameraMotorState outData)
 {
     outData.FreePitch       = inData.FreePitch;
     outData.FreeYaw         = inData.FreeYaw;
     outData.LastFreeYaw     = inData.LastFreeYaw;
     outData.LastFreePitch   = inData.LastFreePitch;
     outData.LastPeekPercent = inData.LastPeekPercent;
     outData.Dict[(int)SubCameraMotorType.Free].Set(inData.FreeNowMode, inData.FreeLastMode, inData.FreeModeTime);
     outData.Dict[(int)SubCameraMotorType.Pose].Set(inData.MainNowMode, inData.MainLastMode, inData.MainModeTime);
     outData.Dict[(int)SubCameraMotorType.Peek].Set(inData.PeekNowMode, inData.PeekLastMode, inData.PeekModeTime);
     outData.Dict[(int)SubCameraMotorType.View].Set(inData.ViewNowMode, inData.ViewLastMode, inData.ViewModeTime);
 }
Example #9
0
        protected override void InternalExecute()
        {
            var player = _playerContext.flagSelfEntity;

            if (player == null)
            {
                return;
            }
            if (!player.hasFirstPersonModel)
            {
                return;
            }
            if (!player.hasThirdPersonModel)
            {
                return;
            }
            if (!player.hasUserCmd)
            {
                return;
            }
            if (player.userCmd.UserCmdStepList.Count == 0)
            {
                return;
            }
            if (!player.hasCameraStateNew)
            {
                return;
            }
            if (!player.hasCameraStateOutputNew)
            {
                return;
            }

            var cmd = (UserCmd)player.userCmd.UserCmdStepList.Last();

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

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

            foreach (int i in _subCameraMotorTypeArray)
            {
                var type = (SubCameraMotorType)i;
                PreProcessInput(player, _input, _motors.GetDict(type), _state.Get(type), _state);
            }
            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
        }
        private void UpdateCamera(IUserCmdOwner owner, IUserCmd cmd)
        {
            PlayerEntity player = owner.OwnerEntity as PlayerEntity;

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

            //观战玩家时,摄像机方向由被观战玩家决定
            if (player.gamePlay.IsObserving())
            {
                int objId  = player.gamePlay.CameraEntityId;
                var entity = _contexts.player.GetEntityWithEntityKey(new EntityKey(objId, (short)EEntityType.Player));
                if (entity != null)
                {
                    return;
                }
            }

            DummyCameraMotorState.Convert(player.cameraStateNew, _state);

            var archotRotation = player.cameraArchor.ArchorEulerAngle;

            if (player.cameraStateNew.CameraMotorInput == null)
            {
                player.cameraStateNew.CameraMotorInput = new DummyCameraMotorInput();
            }
            DummyCameraMotorInput _input = (DummyCameraMotorInput)player.cameraStateNew.CameraMotorInput;

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

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

            DummyCameraMotorState.Convert(_state, player.cameraStateNew);
        }
        public static void Convert(DummyCameraMotorState inData, CameraStateNewComponent outData)
        {
            outData.FreePitch       = inData.FreePitch;
            outData.FreeYaw         = inData.FreeYaw;
            outData.LastFreeYaw     = inData.LastFreeYaw;
            outData.LastFreePitch   = inData.LastFreePitch;
            outData.LastPeekPercent = inData.LastPeekPercent;
            outData.FreeNowMode     = inData.Dict[(int)SubCameraMotorType.Free].NowMode;
            outData.FreeLastMode    = inData.Dict[(int)SubCameraMotorType.Free].LastMode;
            outData.FreeModeTime    = inData.Dict[(int)SubCameraMotorType.Free].ModeTime;

            outData.MainNowMode  = inData.Dict[(int)SubCameraMotorType.Pose].NowMode;
            outData.MainLastMode = inData.Dict[(int)SubCameraMotorType.Pose].LastMode;
            outData.MainModeTime = inData.Dict[(int)SubCameraMotorType.Pose].ModeTime;

            outData.ViewNowMode  = inData.Dict[(int)SubCameraMotorType.View].NowMode;
            outData.ViewLastMode = inData.Dict[(int)SubCameraMotorType.View].LastMode;
            outData.ViewModeTime = inData.Dict[(int)SubCameraMotorType.View].ModeTime;

            outData.PeekNowMode  = inData.Dict[(int)SubCameraMotorType.Peek].NowMode;
            outData.PeekLastMode = inData.Dict[(int)SubCameraMotorType.Peek].LastMode;
            outData.PeekModeTime = inData.Dict[(int)SubCameraMotorType.Peek].ModeTime;
            outData.CanFire      = !inData.IsFree() && inData.GetMainConfig().CanFire;
        }
Example #12
0
        private void PreProcessInput(PlayerEntity player, DummyCameraMotorInput input,
                                     Dictionary <int, ICameraNewMotor> dict, SubCameraMotorState subState, DummyCameraMotorState state)
        {
            if (!dict.ContainsKey(subState.NowMode))
            {
                return;
            }
            if (!dict.ContainsKey(subState.LastMode))
            {
                return;
            }
            var oldMotor = dict[subState.LastMode];
            var nowMotor = dict[subState.NowMode];

            nowMotor.PreProcessInput(player, input, state);
        }
Example #13
0
 public CameraPreUpdateSystem(Contexts contexts, Motors m) : base(contexts)
 {
     _motors = m;
     _state  = new DummyCameraMotorState(m);
 }