public static void Simulate() { if (IterationCount == 0) { switch (sendState) { case SendState.Autosend: ReceivedBytes.AddRange(BitConverter.GetBytes(LockstepManager.FrameCount)); for (i = 0; i < OutCommands.Count; i++) { ReceivedBytes.AddRange(OutCommands [i].Serialized); } break; } if (ReceivedBytes.Count < 4) { return; } int frameCount = BitConverter.ToInt32(ReceivedBytes.innerArray, 0); Index = 4; FrameManager.EnsureCapacity(frameCount + 1); Frame frame; if (!FrameManager.HasFrame [frameCount]) { ReceivedFrameCount++; if (ReceivedBytes.Count > 4) { RecordedBytes.AddRange(BitConverter.GetBytes((ushort)ReceivedBytes.Count)); RecordedBytes.AddRange(ReceivedBytes); LastRecordedFrame = ReceivedFrameCount; } frame = new Frame(); FrameManager.AddFrame(frameCount, frame); while (Index < ReceivedBytes.Count) { Command com = new Command(); Index += com.Reconstruct(ReceivedBytes.innerArray, Index); frame.AddCommand(com); } } ReceivedBytes.FastClear(); OutCommands.FastClear(); IterationCount = LockstepManager.NetworkingIterationSpread - 1; } else { IterationCount--; FrameManager.AddFrame(LockstepManager.FrameCount, new Frame()); } }
public static void Simulate() { if (Offline) { ReceivedBytes.AddRange(BitConverter.GetBytes(LockstepManager.FrameCount)); for (i = 0; i < OutCommands.Count; i++) { ReceivedBytes.AddRange(OutCommands [i].Serialized); } AllReceivedBytes.AddRange(BitConverter.GetBytes(ReceivedBytes.Count)); AllReceivedBytes.AddRange(ReceivedBytes); } else { } int frameCount = BitConverter.ToInt32(ReceivedBytes.innerArray, 0); Index = 4; FrameManager.EnsureCapacity(frameCount + 1); Frame frame; if (!FrameManager.HasFrame [frameCount]) { frame = new Frame(); FrameManager.AddFrame(frameCount, frame); while (Index < ReceivedBytes.Count) { Command com = new Command(); Index += com.Reconstruct(ReceivedBytes.innerArray, Index); frame.AddCommand(com); } } ReceivedBytes.FastClear(); OutCommands.FastClear(); }