Exemple #1
0
        /// <summary>
        /// Sets the latest input from the given peer.
        /// </summary>
        /// <returns>The latest input.</returns>
        /// <param name="input">Input.</param>
        /// <param name="peerId">Peer identifier.</param>
        public void SetInput(TInput input, PeerId peerId, FrameIndex frameIndex)
        {
            if (!m_frames.ContainsKey(frameIndex))
            {
                m_frames [frameIndex] = new SimulationFrame();
            }

            m_frames [frameIndex].Inputs [peerId] = input;
        }
Exemple #2
0
 public void SetOrExtendFrame(FrameIndex frameIndex, SimulationFrame value)
 {
     // If the frame already exists, extend the current simulation frame with the provided frame
     if (m_frames.ContainsKey(frameIndex))
     {
         var currentFrame = m_frames [frameIndex];
         foreach (var inputData in value.Inputs)
         {
             currentFrame.Inputs [inputData.Key] = inputData.Value;
         }
     }
     else
     {
         m_frames [frameIndex] = value;
     }
 }
Exemple #3
0
        /// <summary>
        /// Gets a simulation frame data structure for the given frame
        /// </summary>
        /// <returns>The simulation frame.</returns>
        /// <param name="forFrame">For frame.</param>
        public SimulationFrame GetSimulationFrame(FrameIndex forFrame, bool removePreviousFrames = true)
        {
            var simulationFrame = new SimulationFrame();

            simulationFrame.Inputs = new Dictionary <int, Input> ();
            var frame = m_frames [forFrame];

            foreach (var data in frame.data)
            {
                simulationFrame.Inputs [data.Key] = data.Value.input;
            }
            if (removePreviousFrames)
            {
                var i = -1;
                while (m_frames.ContainsKey(forFrame + i))
                {
                    m_frames.Remove(forFrame + i);
                    i--;
                }
            }
            return(simulationFrame);
        }