public void UseDirectPickBan() { //Ignore same mode requests if (connectionMode == ClientConnectorMode.DIRECT) { return; } if (EventQueue.Count != 0) { Logging.Warn("Disabled Champ Select Delay while P&B was still active! This might cause some errors"); EventQueue.Keys.ToList().ForEach(e => { EmbedIOServer.socketServer.SendEventToAllAsync(e); }); EventQueue.Clear(); } //Swap out queue for direct events State.Client.State.StateUpdate -= AddToQueue; State.Client.State.StateUpdate += SendDirect; State.Client.State.NewAction -= AddToQueue; State.Client.State.NewAction += SendDirect; State.Client.State.ChampSelectStarted -= AddStartToQueue; State.Client.State.ChampSelectStarted += SendStartDirect; State.Client.State.ChampSelectEnded -= AddEndToQueue; State.Client.State.ChampSelectEnded += SendEndDirect; BroadcastHubController.ToTick.Remove(this); connectionMode = ClientConnectorMode.DIRECT; Logging.Info("Using direct PickBan"); }
public void UseDelayPickBan() { //Ignore same mode requests if (connectionMode == ClientConnectorMode.DELAYED) { return; } if (State.Client.State.data.champSelectActive) { Logging.Warn("Tried enabling Champ Select Delay while active. Enable this while not in P&B!"); ActiveSettings.current.DelayPickBan = false; return; } //Elegant code :) But it works, swap out direct events for queue State.Client.State.StateUpdate -= SendDirect; State.Client.State.StateUpdate += AddToQueue; State.Client.State.NewAction -= SendDirect; State.Client.State.NewAction += AddToQueue; State.Client.State.ChampSelectStarted -= SendStartDirect; State.Client.State.ChampSelectStarted += AddStartToQueue; State.Client.State.ChampSelectEnded -= SendEndDirect; State.Client.State.ChampSelectEnded += AddEndToQueue; BroadcastHubController.ToTick.Add(this); connectionMode = ClientConnectorMode.DELAYED; Logging.Info("Using delayed PickBan"); }