Example #1
0
        public FNetworkPredictionData_Client_Character(UECharacterMovementController ClientMovement)
        {
            ClientUpdateTime  = 0.0f;
            CurrentTimeStamp  = 0.0f;
            PendingMove       = null;
            LastAckedMove     = null;
            MaxFreeMoveCount  = 96;
            MaxSavedMoveCount = 96;
            bUpdatePosition   = false;
            //bSmoothNetUpdates = false; // Deprecated
            OriginalMeshTranslationOffset = Vector3.zero;        // (ForceInitToZero)
            MeshTranslationOffset         = Vector3.zero;
            OriginalMeshRotationOffset    = Quaternion.identity; //(FQuat::Identity)
            MeshRotationOffset            = Quaternion.identity; //(FQuat::Identity)
            MeshRotationTarget            = Quaternion.identity; //(FQuat::Identity)
            LastCorrectionDelta           = 0.0f;
            LastCorrectionTime            = 0.0f;
            SmoothingServerTimeStamp      = 0.0f;
            SmoothingClientTimeStamp      = 0.0f;
            // CurrentSmoothTime(0.f) // Deprecated
            //bUseLinearSmoothing = false; // Deprecated
            MaxSmoothNetUpdateDist      = 0.0f;
            NoSmoothNetUpdateDist       = 0.0f;
            SmoothNetUpdateTime         = 0.0f;
            SmoothNetUpdateRotationTime = 0.0f;
            //MaxResponseTime(0.125f) // Deprecated, use MaxMoveDeltaTime instead
            MaxMoveDeltaTime       = 0.125f;
            LastSmoothLocation     = Vector3.zero;
            LastServerLocation     = Vector3.zero;
            SimulatedDebugDrawTime = 0.0f;
            {
                MaxSmoothNetUpdateDist = ClientMovement.NetworkMaxSmoothUpdateDistance;
                NoSmoothNetUpdateDist  = ClientMovement.NetworkNoSmoothUpdateDistance;

                const bool bIsListenServer = (ClientMovement.isServer == NM_ListenServer);
                SmoothNetUpdateTime         = (bIsListenServer ? ClientMovement.ListenServerNetworkSimulatedSmoothLocationTime : ClientMovement.NetworkSimulatedSmoothLocationTime);
                SmoothNetUpdateRotationTime = (bIsListenServer ? ClientMovement.ListenServerNetworkSimulatedSmoothRotationTime : ClientMovement.NetworkSimulatedSmoothRotationTime);


                NetworkManager GameNetworkManager =
                    AGameNetworkManager * GameNetworkManager = AGameNetworkManager::StaticClass()->GetDefaultObject <AGameNetworkManager>();
                if (GameNetworkManager)
                {
                    MaxMoveDeltaTime = GameNetworkManager->MaxMoveDeltaTime;  // =0.125f
                }

                MaxResponseTime = MaxMoveDeltaTime; // MaxResponseTime is deprecated, use MaxMoveDeltaTime instead

                if (ClientMovement.GetOwnerRole() == ROLE_AutonomousProxy)
                {
                    SavedMoves.Reserve(MaxSavedMoveCount);
                    FreeMoves.Reserve(MaxFreeMoveCount);
                }
            }
        }
Example #2
0
        public void DragCardsBetweenPiles(int toPileIndex, int fromPileIndex, int fromCardIndex)
        {
#if DEBUG
            if (fromPileIndex == toPileIndex)
            {
                throw new ArgumentException("Cannot drag cards to the same pile");
            }
#endif

            List <CardAction> actions  = new List <CardAction>();
            List <Card>       fromPile = PlayPiles[fromPileIndex];
            List <Card>       toPile   = PlayPiles[toPileIndex];

            // Keep the play piles consistent by moving the cards into
            // a holding list instead of moving them one at a time.
            List <Card> dragPile = fromPile.GetRange(fromCardIndex, fromPile.Count - fromCardIndex);

            fromPile.RemoveRange(fromCardIndex, dragPile.Count);

            for (int i = 0; i < dragPile.Count; i++)
            {
                Card card = dragPile[i];

                toPile.Add(card);
                actions.Add(
                    new CardAction(card, CardActionType.Move, card.Location,
                                   card.Location = new CardLocation(PileType.Play, toPileIndex, toPile.Count - 1)));
            }

            bool flippedAfterDrag = FlipBottomCardFaceUp(fromPileIndex, actions);

            // Remove cards to discard pile?
            bool flippedAfterDiscard;
            bool discardedCards = TryAndDiscardCards(toPileIndex, actions, out flippedAfterDiscard);

            SavedMoves.Push(new DragMove(this.Score, fromPileIndex, toPileIndex, dragPile.Count,
                                         (flippedAfterDrag ? DragMoveSideEffects.FlipAfterDrag : DragMoveSideEffects.None) |
                                         (discardedCards ? DragMoveSideEffects.DiscardedAfterDrag : DragMoveSideEffects.None) |
                                         (flippedAfterDiscard ? DragMoveSideEffects.FlipAfterDiscard : DragMoveSideEffects.None)));

            NumMoves++;
            Score--;

            if (GameBoardEvents != null)
            {
                GameBoardEvents.DragMoveComplete(new ReadOnlyCollection <CardAction>(actions));
            }
        }
Example #3
0
        public void UndoLastMove()
        {
            while (SavedMoves.Count > 0)
            {
                Move move = SavedMoves.Pop();

                if (move is DragMove)
                {
                    UndoDragMove((DragMove)move);
                    break;
                }
                else if (move is DrawMove)
                {
                    UndoDrawMove((DrawMove)move);
                    break;
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
Example #4
0
 public void ClearUndoStack()
 {
     SavedMoves.Clear();
 }