40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using RTG;
|
|
public class SimulationModelStore : SimulationModel
|
|
{
|
|
public List<Transform> storePositions = new List<Transform>();
|
|
public int maxCapacity;
|
|
public List<GameObject> storedProducts = new List<GameObject>();
|
|
public string storeType = "fifo";
|
|
public void StoreProduct(GameObject product)
|
|
{
|
|
List<Transform> list = storePositions.FindAll(t => t.childCount == 0);
|
|
product.transform.parent = list[UnityEngine.Random.Range(0, list.Count)];
|
|
product.transform.localPosition = Vector3.zero;
|
|
product.transform.localRotation = Quaternion.identity;
|
|
storedProducts.Add(product);
|
|
if (storedProducts.Count > maxCapacity)
|
|
Debug.LogWarning("Max Capacity Reached on : " + nodeID);
|
|
}
|
|
public GameObject GetProduct()
|
|
{
|
|
if (storedProducts.Count == 0)
|
|
return null;
|
|
if (storeType.Contains("fifo"))
|
|
{
|
|
GameObject product = storedProducts[0];
|
|
storedProducts.Remove(product);
|
|
return product;
|
|
}
|
|
else if (storeType.Contains("lifo"))
|
|
{
|
|
GameObject product = storedProducts[storedProducts.Count - 1];
|
|
storedProducts.Remove(product);
|
|
return product;
|
|
}
|
|
return null;
|
|
}
|
|
}
|