public static void ProcessFrame(int frameCount, Frame frame) { if (FrameManager.HasFrame(frameCount) == false) { FrameManager.AddFrame(frameCount, frame); } }
public static void ProcessPacket(FastList <byte> packet) { if (packet == null || packet.Count < 4) { throw new System.Exception("Packet is null or not valid length"); } int frameCount = BitConverter.ToInt32(packet.innerArray, 0); int index = 4; if (FrameManager.HasFrame(frameCount) == false) { Frame frame = new Frame(); if (packet.Count > 4) { RecordedBytes.AddRange(BitConverter.GetBytes((ushort)packet.Count)); RecordedBytes.AddRange(packet); while (index < packet.Count) { Command com = new Command(); index += com.Reconstruct(packet.innerArray, index); frame.AddCommand(com); } if (frameCount > LastCommandedFrameCount) { LastCommandedFrameCount = frameCount; } } FrameManager.AddFrame(frameCount, frame); } else { } }
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(); }