예제 #1
0
 public void Update()
 {
     for (int i = 0; i < UpdatesPerFrame; i++)
     {
         m_subsystemTime.NextFrame();
         bool flag = false;
         foreach (KeyValuePair <IUpdateable, bool> item in m_toAddOrRemove)
         {
             if (item.Value)
             {
                 m_updateables.Add(item.Key, new UpdateableInfo
                 {
                     UpdateOrder = item.Key.UpdateOrder
                 });
                 flag = true;
             }
             else
             {
                 m_updateables.Remove(item.Key);
                 flag = true;
             }
         }
         m_toAddOrRemove.Clear();
         foreach (KeyValuePair <IUpdateable, UpdateableInfo> updateable in m_updateables)
         {
             UpdateOrder updateOrder = updateable.Key.UpdateOrder;
             if (updateOrder != updateable.Value.UpdateOrder)
             {
                 flag = true;
                 updateable.Value.UpdateOrder = updateOrder;
             }
         }
         if (flag)
         {
             m_sortedUpdateables.Clear();
             foreach (IUpdateable key in m_updateables.Keys)
             {
                 m_sortedUpdateables.Add(key);
             }
             m_sortedUpdateables.Sort(Comparer.Instance);
         }
         float dt = MathUtils.Clamp(m_subsystemTime.GameTimeDelta, 0f, 0.1f);
         foreach (IUpdateable sortedUpdateable in m_sortedUpdateables)
         {
             try
             {
                 sortedUpdateable.Update(dt);
             }
             catch (Exception)
             {
             }
         }
     }
 }