protected virtual void OnFirstBlood(LeagueEventArgs args) => FirstBlood?.Invoke(this, args);
protected virtual void OnGameEnd(LeagueEventArgs args) => GameEnd?.Invoke(this, args);
protected virtual void OnMultiKill(LeagueEventArgs args) => MultiKill?.Invoke(this, args);
protected virtual void OnAce(LeagueEventArgs args) => Ace?.Invoke(this, args);
protected virtual void OnBaronKill(LeagueEventArgs args) => BaronKill?.Invoke(this, args);
protected virtual void OnChampionKill(LeagueEventArgs args) => ChampionKill?.Invoke(this, args);
protected virtual void OnInhibKill(LeagueEventArgs args) => InhibKill?.Invoke(this, args);
protected virtual void OnHeraldKill(LeagueEventArgs args) => HeraldKill?.Invoke(this, args);
protected virtual void OnTurretKill(LeagueEventArgs args) => TurretKill?.Invoke(this, args);
protected virtual void OnMinionsFirstSpawn(LeagueEventArgs args) => MinionsFirstSpawn?.Invoke(this, args);
protected virtual void OnGameStart(LeagueEventArgs args) => GameStart?.Invoke(this, args);
protected virtual void OnLeagueEventHappened(LeagueEventArgs args) => LeagueEventHappened?.Invoke(this, args);
private async void ListenLeagueEvent(object sender, DoWorkEventArgs e) { while (!workerLeagueEvent.CancellationPending) { Task endLoop = Task.Delay(delayLeagueEvent); LeagueEvent leagueEvent = await api.GetLastEvent(); if (leagueEvent != null && leagueEvent.id != lastLeagueEventIndex) { int thisEventIndex = leagueEvent.id; //If only one event has happened since the last check. if (thisEventIndex == lastLeagueEventIndex + 1) { RaiseEvent(leagueEvent); } //If more than one event happened since the last check, get all events and trigger all events from [last + 1] until the last one. else { LeagueEvent[] allGameEvents = await api.GetEvents(); for (int i = lastLeagueEventIndex + 1; i <= thisEventIndex; i++) { RaiseEvent(allGameEvents[i]); } } lastLeagueEventIndex = leagueEvent.id; } await endLoop; } void RaiseEvent(LeagueEvent thisEvent) { LeagueEventArgs args = new LeagueEventArgs(thisEvent); OnLeagueEventHappened(args); if (thisEvent is Event_GameStart) { OnGameStart(args); } else if (thisEvent is Event_MinionsFirstSpawn) { OnMinionsFirstSpawn(args); } else if (thisEvent is Event_FirstTurretKill) { OnFirstTurretKill(args); } else if (thisEvent is Event_TurretKill) { OnTurretKill(args); } else if (thisEvent is Event_InhibKill) { OnInhibKill(args); } else if (thisEvent is Event_DragonKill) { OnDragonKill(args); } else if (thisEvent is Event_HeraldKill) { OnHeraldKill(args); } else if (thisEvent is Event_BaronKill) { OnBaronKill(args); } else if (thisEvent is Event_ChampionKill) { OnChampionKill(args); } else if (thisEvent is Event_MultiKill) { OnMultiKill(args); } else if (thisEvent is Event_Ace) { OnAce(args); } else if (thisEvent is Event_FirstBlood) { OnFirstBlood(args); } else if (thisEvent is Event_GameEnd) { OnGameEnd(args); } } }