Exemple #1
0
        private void switchToNextPosition()
        {
            LocomotionActionEvent locomotionActionEvent = positionTimeline.Dequeue();
            LocomotionController  currentController     = locomotionTracker.GetCurrentController();
            Vector3 vector       = ((currentController != null) ? currentController.GetPosition() : base.transform.position);
            Vector3 wsSteerInput = locomotionActionEvent.Position - vector;

            wsSteerInput.y = 0f;
            if (locomotionActionEvent.Direction.HasValue)
            {
                wsSteerInput = locomotionActionEvent.Direction.Value;
                if (locomotionActionEvent.Type.IsMovement())
                {
                    lastStickDirection = wsSteerInput;
                }
            }
            if (currentController != null && !(currentController is SlideController))
            {
                if (locomotionActionEvent.Type.IsMovement())
                {
                    currentController.Steer(wsSteerInput);
                }
                else if (locomotionActionEvent.Type == LocomotionAction.Rotate)
                {
                    currentController.SteerRotation(wsSteerInput);
                }
            }
            desiredStartEvent  = desiredTargetEvent;
            desiredTargetEvent = locomotionActionEvent;
            startPosition      = vector;
            startFacing        = ((currentController != null) ? currentController.GetFacing() : base.transform.forward);
            state = SyncState.INTERPOLATION;
        }
Exemple #2
0
    private void sendLocomotionUpdate(Vector3 direction, LocomotionAction type)
    {
        LocomotionActionEvent action = default(LocomotionActionEvent);

        action.Type      = type;
        action.Position  = getCurrentPosition();
        action.Direction = direction;
        LocomotionController currentController = locomotionTracker.GetCurrentController();

        if (currentController is SlideController)
        {
            action.Velocity = currentController.GetFacing();
        }
        if (broadcastingDisabledEvents == 0)
        {
            networkService.PlayerActionService.LocomotionAction(action, droppable: true);
        }
        AvatarDataHandle component = GetComponent <AvatarDataHandle>();

        if (!(component == null) && broadcastingDisabledEvents == 0 && Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PositionData component2))
        {
            component2.Position = action.Position;
            if (!Service.Get <CPDataEntityCollection>().TryGetComponent(component.Handle, out PausedStateData component3))
            {
                component3 = Service.Get <CPDataEntityCollection>().AddComponent <PausedStateData>(component.Handle);
            }
            component3.Position = component2.Position;
        }
    }