private SyncedData UpdateData() { bool flag = this.replayMode == ReplayMode.LOAD_REPLAY; SyncedData result; if (flag) // 加载回放模式 { result = null; } else // 非加载回放模式 { SyncedData @new = SyncedData.pool.GetNew(); // 从池中获取 @new.Init(this.localPlayer.ID, this.ticks); this.GetLocalData(@new.inputData); // 把玩家操作数据放入SyncedData实例中 this.localPlayer.AddData(@new); // 把SyncedData实例放入本地玩家的操作数据字典中 bool flag2 = this.communicator != null; if (flag2) // 有通信器 { this.localPlayer.GetSendData(this.ticks, this._syncedDataCacheUpdateData); // 把最新的操作数据放入_syncedDataCacheUpdateData中 this.communicator.OpRaiseEvent(199, SyncedData.Encode(this._syncedDataCacheUpdateData), true, this.auxActivePlayersIds); // 发送操作数据 } result = @new; } return(result); }
private void DropLagPlayers() { List <FPPlayer> list = new List <FPPlayer>(); int refTick = this.GetRefTick(this.GetSyncedDataTick()); bool flag = refTick >= 0; if (flag) { int i = 0; int count = this.activePlayers.Count; while (i < count) { FPPlayer tSPlayer = this.activePlayers[i]; bool flag2 = !tSPlayer.IsDataReady(refTick); if (flag2) { tSPlayer.dropCount++; list.Add(tSPlayer); } i++; } } int j = 0; int count2 = list.Count; while (j < count2) { FPPlayer p = list[j]; this.CheckDrop(p); bool sendDataForDrop = list[j].GetSendDataForDrop(this.localPlayer.ID, this._syncedDataCacheDrop); if (sendDataForDrop) { this.communicator.OpRaiseEvent(199, SyncedData.Encode(this._syncedDataCacheDrop), true, null); SyncedData.pool.GiveBack(this._syncedDataCacheDrop[0]); } j++; } }