mirror of
				https://github.com/DerTyp7/industrialize-unity.git
				synced 2025-10-30 21:07:11 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			42 lines
		
	
	
		
			911 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			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;
 | |
|     }
 | |
| } | 
