public void SendSnapshot(int interval, SnapshotFactory snapshotFactory, Dictionary <INetworkChannel, PlayerEntity> channelToPlayer) { var sessionObjects = _contexts.session.serverSessionObjects; Bin2DConfig bin2DConfig = sessionObjects.Bin2DConfig; IBin2DManager bin = sessionObjects.Bin2dManager; int snapshotSeq = sessionObjects.GetNextSnapshotSeq(); int vehicleSimulationTime = sessionObjects.SimulationTimer.CurrentTime; int serverTime = _contexts.session.currentTimeObject.CurrentTime; _sendSnapshotTasks.Clear(); var freeMoveEntitys = _globalFreeMoveEntities.GetEntities(); var weaponEntities = _globalWeaponEntities.GetEntities(); foreach (var entry in channelToPlayer) { INetworkChannel channel = entry.Key; PlayerEntity player = entry.Value; if (player.hasStage && player.stage.CanSendSnapshot() && channel.IsConnected && !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime)) { var p = ObjectAllocatorHolder <CreateSnapshotParams> .Allocate().Build(snapshotFactory, player, bin2DConfig, bin, serverTime, snapshotSeq, vehicleSimulationTime, channel); var entitys = p.PreEnitys; AddTeamPlayers(player, entitys, _contexts); AddGlobalFreeMove(player, entitys, freeMoveEntitys); AddWeapon(player, entitys, weaponEntities); _sendSnapshotTasks.Add(p); } else { player.network.NetworkChannel.Serializer.MessageTypeInfo.IncSendSnapShot(); _logger.DebugFormat("channel:{2} skip SendSnapshot :{0} {1}!", channel.IsConnected, !player.network.NetworkChannel.Serializer.MessageTypeInfo.SkipSendSnapShot(serverTime), channel.IdInfo()); } } if (SharedConfig.MutilThread) { #if ENABLE_NEW_SENDSNAPSHOT_THREAD ConsumerExecute(); #else MutilExecute(); #endif } else { MainExecute(); } _logger.DebugFormat("SendSnapshot Threads Done;"); }