Merge branch 'main' of http://220.90.135.190:3000/UVCXR/Simulation
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()
|
||||
{
|
||||
Debug.Log("1");
|
||||
var logicUIManager = FindAnyObjectByType<LogicUIManager>();
|
||||
logicUIManager.onLogicItemSelected += SetConnectedDataItem;
|
||||
logicUIManager.onLogicItemDeSelected += UnsetConnectedDataItem;
|
||||
FindAnyObjectByType<Panel_PlacedObject>(FindObjectsInactive.Include).onPlacedObjectSelected += SetConnectedDataItem;
|
||||
Debug.Log("2");
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public class SimulationModelMove : SimulationModel
|
||||
Vector3 dir = transform.position - prevPos;
|
||||
dir.y = 0;
|
||||
dir.Normalize();
|
||||
transform.forward = dir;
|
||||
//transform.forward = dir;
|
||||
prevPos = transform.position;
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ public class SimulationModelProcess : SimulationModel
|
||||
}
|
||||
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 List<Transform> transporterPositions = new List<Transform>();
|
||||
|
||||
private void Awake()
|
||||
protected override void init()
|
||||
{
|
||||
base.init();
|
||||
maxCapacity = storePositions.Count;
|
||||
}
|
||||
|
||||
public void StoreProduct(GameObject product)
|
||||
{
|
||||
product.transform.parent = transform;
|
||||
@@ -54,7 +56,7 @@ public class SimulationModelStore : SimulationModel
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
storedProducts.Add(product);
|
||||
if (storedProducts.Count > maxCapacity) { }
|
||||
//Debug.LogWarning("Max Capacity " + maxCapacity + " Reached on : " + nodeID);
|
||||
//Debug.LogWarning("Max Capacity " + maxCapacity + " Reached on : " + nodeID);
|
||||
}
|
||||
public GameObject GetProduct()
|
||||
{
|
||||
@@ -71,7 +73,7 @@ public class SimulationModelStore : SimulationModel
|
||||
GameObject product = storedProducts[storedProducts.Count - 1];
|
||||
storedProducts.Remove(product);
|
||||
return product;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Transform GetTransporterPosition()
|
||||
@@ -83,40 +85,82 @@ public class SimulationModelStore : SimulationModel
|
||||
|
||||
void AdjustStore(StoreStatusUpdateData Store)
|
||||
{
|
||||
Debug.Log(Store.statistics.current_length);
|
||||
storedProducts.Clear();
|
||||
GameObject product = ProductManager.Instance.SpawnProduct();
|
||||
product.transform.parent = transform;
|
||||
for (int i = 0; i < Store.statistics.current_length; i++)
|
||||
int current = storedProducts.Count;
|
||||
int target = Store.statistics.current_length;
|
||||
if (current < target)
|
||||
{
|
||||
if(i>= storePositions.Count)
|
||||
if (current > storePositions.Count)
|
||||
{
|
||||
break;
|
||||
return;
|
||||
}
|
||||
Transform storePos = storePositions[i];
|
||||
if (storePos.childCount == 0)
|
||||
int spawnCount = Mathf.Min(target - current, storePositions.Count - current);
|
||||
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);
|
||||
storedProducts.Clear();
|
||||
GameObject product = ProductManager.Instance.SpawnProduct();
|
||||
product.transform.parent = transform;
|
||||
for (int i = 0; i < Queue.statistics.current_length; i++)
|
||||
int current = storedProducts.Count;
|
||||
int target = Queue.statistics.current_length;
|
||||
if (current < target)
|
||||
{
|
||||
if (i >= storePositions.Count)
|
||||
if (current > storePositions.Count)
|
||||
{
|
||||
break ;
|
||||
return;
|
||||
}
|
||||
Transform storePos = storePositions[i];
|
||||
if (storePos.childCount == 0)
|
||||
int spawnCount = Mathf.Min(target - current, storePositions.Count - current);
|
||||
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()));
|
||||
break;
|
||||
case "queue_status_update":
|
||||
QueueStore(JsonConvert.DeserializeObject<QueueStatusUpdateData>(wrapclass.data.ToString()));
|
||||
AdjustQueue(JsonConvert.DeserializeObject<QueueStatusUpdateData>(wrapclass.data.ToString()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user