public void Items(ref MyPhysObjectSmallShipConfigItem[] items) { if (items.Length < m_items.Length) { items = new MyPhysObjectSmallShipConfigItem[m_items.Length]; } int count = 0; foreach (var item in m_items) { items[count] = item.Enable ? item : null; count++; } }
public void Items(int first, ref MyPhysObjectSmallShipConfigItem[] items, ref int count) { int enabledCount = 0; foreach (var item in m_items) if (item.Enable) ++enabledCount; // Try get as much items as possible int last = Math.Max(enabledCount - items.Length, 0); if (last < first) { first = last; } count = 0; foreach (var item in m_items) { if (!item.Enable) continue; if (first <= count && items.Length > count - first) { items[count - first] = item; } count++; } for (int i = count - first; i < items.Length; i++) { items[i] = null; } }