示例#1
0
        private void OnGetReceiveLockstepMsg <T>(int frame, NetDataReader reader) where T : LockFrameCommand
        {
            var cmd = Pool.SP.Get <T>();

            cmd.Frame = frame;
            cmd.Deserialize(reader);
            _frames.Add(cmd);
        }
 public static void Distribute(byte[] data)
 {
     if (SimulateNetworking)
     {
         ServerSimulator.Receive(data);
     }
     else
     {
         if (isConnected)
         {
             SendMessageToServer(MessageType.Input, data);
         }
         else
         {
             bufferedSendData.Add(data);
         }
     }
 }
示例#3
0
        public static void LateSimulate()
        {
            //TODO: Look into this
            int inactiveFrameThreshold = LockstepManager.FrameRate * 8;


            for (int i = 0; i < RanCollisionPairs.PeakCount; i++)
            {
                if (RanCollisionPairs.arrayAllocation[i])
                {
                    var instancePair = RanCollisionPairs[i];
                    var pair         = RanCollisionPairs[i].Pair;

                    if (instancePair.Version != instancePair.Pair._Version)
                    {
                        //pair is removed at Deactivate so no longer possible
                    }
                    else
                    {
                        if (pair._ranIndex >= 0)
                        {
                            RanCollisionPairs.RemoveAt(pair._ranIndex);
                            pair._ranIndex = -1;
                            InactiveCollisionPairs.Add(instancePair);
                        }
                    }
                }
            }

            //Clear the buffer of collision pairs to turn off and pool
            while (InactiveCollisionPairs.Count > 0)
            {
                var instancePair = InactiveCollisionPairs.Peek();
                var pair         = instancePair.Pair;

                if (pair.Active)
                {
                    //It's active again! Get it out of inactives and move on to the next guy.
                    InactiveCollisionPairs.Remove();
                }

                var passedFrames = LockstepManager.FrameCount - pair.LastFrame;
                if (passedFrames >= inactiveFrameThreshold)
                {
                    InactiveCollisionPairs.Remove();
                    FullDeactivateCollisionPair(pair);
                }
                else
                {
                    break;
                }
            }

            for (int i = 0; i < DynamicSimObjects.PeakCount; i++)
            {
                LSBody b1 = DynamicSimObjects.innerArray[i];
                if (b1.IsNotNull())
                {
                    b1.Simulate();
                }
            }
            ResetAccumulation = true;
        }