/// <summary> /// Sends the state deltas to the clients. /// </summary> void SendStateChanges(double dt) { if (TimeSinceLastCorrection >= GameMatch.STATE_UPDATE_INTERVAL.TotalSeconds) { foreach (NetConnection connection in Clients.Keys) { SendCommand( connection, ServerCommand.StateUpdate, RemarkableEvents.Count == 0 ? NetDeliveryMethod.UnreliableSequenced : NetDeliveryMethod.ReliableUnordered, (msg) => FillStateUpdateMessage(msg, connection)); } RemarkableEvents.Clear(); TimeSinceLastCorrection = 0.0; } TimeSinceLastCorrection += dt; }
void ApplyRemarkableEvents() { RemarkableEvents.ForEach(r => { switch (r.Command) { case ServerCommand.SpellCast: OnCastSpell((SpellCastEventData)r); break; case ServerCommand.SpellDisappear: OnRemoveSpell((SpellDisappearEventData)r); break; case ServerCommand.StatsChanged: OnChangeStats((StatsChangedEventData)r); break; case ServerCommand.ChampionDied: OnChampionDied((ChampionDiedEventData)r); break; case ServerCommand.StructureStatsChanged: OnStructureStatsChanged((StructureStatsChangedEventData)r); break; case ServerCommand.StructureDestroyed: OnStructureDestroyed((StructureDestroyedEventData)r); break; case ServerCommand.EndOfGame: OnEndOfGame((EndOfGameEventData)r); break; case ServerCommand.TowerPreparingToShoot: OnTowerPreparingToShoot((TowerPreparingToShootEventData)r); break; default: Debug.Fail("Unknown server command (unknown remarkable event)."); break; } }); RemarkableEvents.Clear(); }