// TODO : REFACTOR TO OPTIMIZE public virtual void RemoveItem(ObservableInfo itemInfo) { int index = ItemsCollection.IndexOf(itemInfo); if (index >= 0 && index < ItemsCount) { RemoveItemAt(index); } }
// TODO : Refactor and return something GO or ObservableComponent public virtual void AddItem(ObservableInfo newItem) { ItemsCollection.Add(newItem); if (!gameObject.activeInHierarchy) { return; } if (ListCount < maxListSize) { SpawnItem().GetComponent <ObservableComponent>().Info = newItem; } }
public virtual void AddItemAt(ObservableInfo newItem, int position) { if (position > -1 && position < firstItemIndex) { ItemsCollection.Insert(position, newItem); firstItemIndex++; } else if (position < LastItemIndex) { ItemsCollection.Insert(position, newItem); } else if (position <= ItemsCount) { ItemsCollection.Insert(position, newItem); } }