public void GameplayUpdate(float dt) { if (world == null) { return; } updateAccumulator += dt; if (updateAccumulator >= TickRate) { updateAccumulator -= TickRate; server.PollEvents(); foreach (ServerPj pj in world.Pjs.Values ?? Enumerable.Empty <Pj>()) { pj.AnimationMachine.Update(TickRate); long lastInput = pj.LastProcessedInput; if (lastInput > pj.LastSentSnapshot) { pj.LastSentSnapshot = lastInput; StatePacket statePacket = new StatePacket(lastInput, pj); server.SendToAll(statePacket.Serialize(), SendOptions.Unreliable); } List <int> buffsToRemove = new List <int>(); foreach (KeyValuePair <int, Buff> kvp in pj.Buffs) { Buff buff = kvp.Value; buff.Update(TickRate); if (buff.ToBeRemoved) { buffsToRemove.Add(kvp.Key); } } foreach (int buffId in buffsToRemove) { RemoveBuff(pj, buffId); } } List <int> dropsToRemove = new List <int>(); foreach (KeyValuePair <int, Drop> kvp in world.Drops) { Drop drop = kvp.Value; foreach (Pj pj in world.Pjs.Values) { if (drop.AabbAabbIntersectionTest(pj)) { drop.Callback(pj, this); dropsToRemove.Add(kvp.Key); } } } foreach (int index in dropsToRemove) { RemoveDrop(index); } List <int> tintaSplashesToRemove = new List <int>(); foreach (KeyValuePair <int, TintaSplash> kvp in world.TintaSplashes) { TintaSplash splash = kvp.Value; splash.Update(TickRate); if (splash.ToBeRemoved) { tintaSplashesToRemove.Add(kvp.Key); } } foreach (int index in tintaSplashesToRemove) { RemoveTintaSplash(index); } } }