Skip to content

Commit

Permalink
simplify checks
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Nov 27, 2023
1 parent 115b915 commit d807d58
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ public bool AddItemPosition(Item item, Vector2Int position)
private bool AddStoredItem(StoredItem newItem)
{
if (!CanContainItem(newItem.Item)) return false;
if (newItem.Item.Container != null && newItem.Item.Container != this) return false;

if (FindItem(newItem.Item, out int itemIndex))
{
Expand All @@ -395,11 +396,6 @@ private bool AddStoredItem(StoredItem newItem)
ReplaceStoredItem(newItem, itemIndex);
return true;
}
else if(newItem.Item.Container != null)
{
return false;
}


_storedItems.Add(newItem);
newItem.Item.SetContainer(this);
Expand Down Expand Up @@ -556,8 +552,6 @@ private bool CanHoldItem(Item item)
/// custom storage conditions if they exists, which are scripts put on the same game object as this container and
/// implementing IStorageCondition.
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool CanContainItem(Item item)
{
return CanStoreItem(item)
Expand Down

0 comments on commit d807d58

Please sign in to comment.