Files
industrialize-unity/Assets/Scripts/ProductionObjects/IOPort.cs
Janis 44461ff955 io
2022-06-07 19:10:55 +02:00

42 lines
911 B
C#

using System.Collections.Generic;
using UnityEngine;
public class IOPort : MonoBehaviour
{
public bool isInput;
public ItemSO item;
public int itemCount = 0;
private int maxItemCount = 100;
public int IncreaseItemCount(int value) // Returns rest of value
{
int restOfValue = 0;
if (itemCount + value > maxItemCount)
{
restOfValue = value - (maxItemCount - itemCount);
itemCount = maxItemCount;
}
else
{
itemCount += value;
}
return restOfValue;
}
public int DecreaseItemCount(int value) // Returns rest of value
{
int restOfValue = 0;
if (itemCount - value < 0)
{
restOfValue = value - itemCount;
itemCount = 0;
}
else
{
itemCount -= value;
}
return restOfValue;
}
}