temp
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,12 +31,10 @@ namespace Octopus.Simulator
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
Debug.Log("1");
|
|
||||||
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
||||||
logicUIManager.onLogicItemSelected += SetConnectedDataItem;
|
logicUIManager.onLogicItemSelected += SetConnectedDataItem;
|
||||||
logicUIManager.onLogicItemDeSelected += UnsetConnectedDataItem;
|
logicUIManager.onLogicItemDeSelected += UnsetConnectedDataItem;
|
||||||
FindAnyObjectByType<Panel_PlacedObject>(FindObjectsInactive.Include).onPlacedObjectSelected += SetConnectedDataItem;
|
FindAnyObjectByType<Panel_PlacedObject>(FindObjectsInactive.Include).onPlacedObjectSelected += SetConnectedDataItem;
|
||||||
Debug.Log("2");
|
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class SimulationModelMove : SimulationModel
|
|||||||
Vector3 dir = transform.position - prevPos;
|
Vector3 dir = transform.position - prevPos;
|
||||||
dir.y = 0;
|
dir.y = 0;
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
transform.forward = dir;
|
//transform.forward = dir;
|
||||||
prevPos = transform.position;
|
prevPos = transform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ public class SimulationModelProcess : SimulationModel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
//Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ public class SimulationModelStore : SimulationModel
|
|||||||
public string storeType = "fifo";
|
public string storeType = "fifo";
|
||||||
public List<Transform> transporterPositions = new List<Transform>();
|
public List<Transform> transporterPositions = new List<Transform>();
|
||||||
|
|
||||||
private void Awake()
|
protected override void init()
|
||||||
{
|
{
|
||||||
|
base.init();
|
||||||
maxCapacity = storePositions.Count;
|
maxCapacity = storePositions.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreProduct(GameObject product)
|
public void StoreProduct(GameObject product)
|
||||||
{
|
{
|
||||||
product.transform.parent = transform;
|
product.transform.parent = transform;
|
||||||
@@ -54,7 +56,7 @@ public class SimulationModelStore : SimulationModel
|
|||||||
product.transform.localRotation = Quaternion.identity;
|
product.transform.localRotation = Quaternion.identity;
|
||||||
storedProducts.Add(product);
|
storedProducts.Add(product);
|
||||||
if (storedProducts.Count > maxCapacity) { }
|
if (storedProducts.Count > maxCapacity) { }
|
||||||
//Debug.LogWarning("Max Capacity " + maxCapacity + " Reached on : " + nodeID);
|
//Debug.LogWarning("Max Capacity " + maxCapacity + " Reached on : " + nodeID);
|
||||||
}
|
}
|
||||||
public GameObject GetProduct()
|
public GameObject GetProduct()
|
||||||
{
|
{
|
||||||
@@ -83,40 +85,82 @@ public class SimulationModelStore : SimulationModel
|
|||||||
|
|
||||||
void AdjustStore(StoreStatusUpdateData Store)
|
void AdjustStore(StoreStatusUpdateData Store)
|
||||||
{
|
{
|
||||||
Debug.Log(Store.statistics.current_length);
|
int current = storedProducts.Count;
|
||||||
storedProducts.Clear();
|
int target = Store.statistics.current_length;
|
||||||
GameObject product = ProductManager.Instance.SpawnProduct();
|
if (current < target)
|
||||||
product.transform.parent = transform;
|
|
||||||
for (int i = 0; i < Store.statistics.current_length; i++)
|
|
||||||
{
|
{
|
||||||
if(i>= storePositions.Count)
|
if (current > storePositions.Count)
|
||||||
{
|
{
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
Transform storePos = storePositions[i];
|
int spawnCount = Mathf.Min(target - current, storePositions.Count - current);
|
||||||
if (storePos.childCount == 0)
|
for (int k = 0; k < spawnCount; k++)
|
||||||
{
|
{
|
||||||
product.transform.parent = storePos;
|
GameObject prod = ProductManager.Instance.SpawnProduct();
|
||||||
|
|
||||||
|
Transform emptySlot = storePositions
|
||||||
|
.FirstOrDefault(slot => slot.childCount == 0);
|
||||||
|
prod.transform.SetParent(emptySlot, false);
|
||||||
|
|
||||||
|
storedProducts.Add(prod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (current > target)
|
||||||
|
{
|
||||||
|
if (current > storePositions.Count)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int removeCount = current - target;
|
||||||
|
for (int k = 0; k < removeCount; k++)
|
||||||
|
{
|
||||||
|
GameObject prod = (storeType == "fifo")
|
||||||
|
? storedProducts[0]
|
||||||
|
: storedProducts[storedProducts.Count - 1];
|
||||||
|
|
||||||
|
storedProducts.Remove(prod);
|
||||||
|
Destroy(prod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueStore(QueueStatusUpdateData Queue)
|
void AdjustQueue(QueueStatusUpdateData Queue)
|
||||||
{
|
{
|
||||||
Debug.Log(Queue.statistics.current_length);
|
int current = storedProducts.Count;
|
||||||
storedProducts.Clear();
|
int target = Queue.statistics.current_length;
|
||||||
GameObject product = ProductManager.Instance.SpawnProduct();
|
if (current < target)
|
||||||
product.transform.parent = transform;
|
|
||||||
for (int i = 0; i < Queue.statistics.current_length; i++)
|
|
||||||
{
|
{
|
||||||
if (i >= storePositions.Count)
|
if (current > storePositions.Count)
|
||||||
{
|
{
|
||||||
break ;
|
return;
|
||||||
}
|
}
|
||||||
Transform storePos = storePositions[i];
|
int spawnCount = Mathf.Min(target - current, storePositions.Count - current);
|
||||||
if (storePos.childCount == 0)
|
for (int k = 0; k < spawnCount; k++)
|
||||||
{
|
{
|
||||||
product.transform.parent = storePos;
|
GameObject prod = ProductManager.Instance.SpawnProduct();
|
||||||
|
|
||||||
|
Transform emptySlot = storePositions
|
||||||
|
.FirstOrDefault(slot => slot.childCount == 0);
|
||||||
|
prod.transform.SetParent(emptySlot, false);
|
||||||
|
|
||||||
|
storedProducts.Add(prod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (current > target)
|
||||||
|
{
|
||||||
|
if (current > storePositions.Count)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int removeCount = current - target;
|
||||||
|
for (int k = 0; k < removeCount; k++)
|
||||||
|
{
|
||||||
|
GameObject prod = (storeType == "fifo")
|
||||||
|
? storedProducts[0]
|
||||||
|
: storedProducts[storedProducts.Count - 1];
|
||||||
|
|
||||||
|
storedProducts.Remove(prod);
|
||||||
|
Destroy(prod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +174,7 @@ public class SimulationModelStore : SimulationModel
|
|||||||
AdjustStore(JsonConvert.DeserializeObject<StoreStatusUpdateData>(wrapclass.data.ToString()));
|
AdjustStore(JsonConvert.DeserializeObject<StoreStatusUpdateData>(wrapclass.data.ToString()));
|
||||||
break;
|
break;
|
||||||
case "queue_status_update":
|
case "queue_status_update":
|
||||||
QueueStore(JsonConvert.DeserializeObject<QueueStatusUpdateData>(wrapclass.data.ToString()));
|
AdjustQueue(JsonConvert.DeserializeObject<QueueStatusUpdateData>(wrapclass.data.ToString()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user