mirror of
https://github.com/DerTyp7/industrialize-unity.git
synced 2025-10-29 12:32:12 +01:00
io
This commit is contained in:
@@ -8,15 +8,35 @@ public class IOPort : MonoBehaviour
|
||||
public int itemCount = 0;
|
||||
private int maxItemCount = 100;
|
||||
|
||||
public void IncreaseItemCount(int value)
|
||||
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 void DecreaseItemCount(int value)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user