From e1700f926ed7cdc1258dddbbadca1da13427ded3 Mon Sep 17 00:00:00 2001 From: lwj Date: Thu, 29 May 2025 16:00:12 +0900 Subject: [PATCH] fix move model --- .../SimulationModels/SimulationModelMove.cs | 77 ++++++++++--------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/Assets/Scripts/SimulationModels/SimulationModelMove.cs b/Assets/Scripts/SimulationModels/SimulationModelMove.cs index d62dd3d1..68033639 100644 --- a/Assets/Scripts/SimulationModels/SimulationModelMove.cs +++ b/Assets/Scripts/SimulationModels/SimulationModelMove.cs @@ -89,49 +89,20 @@ public class SimulationModelMove : SimulationModel string[] originalTimeKey = { "data", "original" }; string[] adjustedTimeKey = { "data", "adjusted" }; string[] inputQueueKey = { "data", "input", "queues" }; + string[] inputStoreKey = { "data", "input", "stores" }; string[] outputQueueKey = { "data", "output", "queue" }; string[] outputStoreKey = { "data", "output", "store" }; string[] sourceQueueKey = { "data", "source_queues" }; string[] sourceStoreKey = { "data", "source_stores" }; string[] loadCountKey = { "data", "loaded_count" }; - string[] unloadQueueKey = { "data", "output_queue" }; + string[] unloadQueueKey = { "data", "queue_name" }; + string[] unloadStoreKey = { "data", "store_name" }; if (currentData.ContainsKey(eventKey)) { string value = currentData[eventKey].ToString(); - //if (value.Contains(eventMove)) - //{ - // Debug.Log("MoveeventIncomming"); - - // elapsedTime = 0; - // arrivalTime = GetJsonFloatValue(currentData, arrivalTimeKey); - // originalPos = transform.position; - // prevPos = transform.position; - // JArray originQueues = GetJsonArray(currentData, inputQueueKey); - // string arrivalQueue = GetJsonValue(currentData, outputQueueKey)?.ToString(); - - // if ( string.IsNullOrEmpty(arrivalQueue)) - // { - // arrivalQueue = GetJsonValue(currentData, outputStoreKey)?.ToString(); - // } - - // if (originQueues != null && originQueues.HasValues) - // { - // string queueID = originQueues[0].ToString(); - // SimulationModel model = DataManager.I.GetModel(queueID); - // SimulationModelStore storeModel = (SimulationModelStore)model; - // origin = storeModel.GetTransporterPosition(); - // } - // if (arrivalQueue != null) - // { - // SimulationModel model = DataManager.I.GetModel(arrivalQueue); - // SimulationModelStore storeModel = (SimulationModelStore)model; - // destination = storeModel.GetTransporterPosition(); - // } - //} - if (value.Contains(eventLoading)) { yield return null; @@ -174,6 +145,7 @@ public class SimulationModelMove : SimulationModel product.transform.parent = productPos; product.transform.localPosition = Vector3.zero; product.transform.localRotation = Quaternion.identity; + listProducts.Add(product); } } } @@ -186,7 +158,10 @@ public class SimulationModelMove : SimulationModel originalPos = transform.position; prevPos = transform.position; JArray originQueues = GetJsonArray(currentData, inputQueueKey); + JArray originStores = GetJsonArray(currentData, inputStoreKey); string arrivalQueue = GetJsonValue(currentData, outputQueueKey)?.ToString(); + string arrivalStore = GetJsonValue(currentData, outputStoreKey)?.ToString(); + if (originQueues != null && originQueues.HasValues) { string queueID = originQueues[0].ToString(); @@ -194,20 +169,52 @@ public class SimulationModelMove : SimulationModel SimulationModelStore storeModel = (SimulationModelStore)model; origin = storeModel.GetTransporterPosition(); } - if (arrivalQueue != null) + else if ( originStores != null&& originStores.HasValues) + { + string storeID = originStores[0].ToString(); + SimulationModel model = DataManager.I.GetModel(storeID); + SimulationModelStore storeModel = (SimulationModelStore)model; + origin = storeModel.GetTransporterPosition(); + } + + if (!string.IsNullOrEmpty(arrivalQueue)) { SimulationModel model = DataManager.I.GetModel(arrivalQueue); SimulationModelStore storeModel = (SimulationModelStore)model; destination = storeModel.GetTransporterPosition(); } + else if (!string.IsNullOrEmpty(arrivalStore)) + { + SimulationModel model = DataManager.I.GetModel(arrivalStore); + SimulationModelStore storeModel = (SimulationModelStore)model; + destination = storeModel.GetTransporterPosition(); + } } else if (value.Contains(eventUnloading)) { yield return null; - string queueID = GetJsonValue(currentData, unloadQueueKey)?.ToString(); - SimulationModel model = DataManager.I.GetModel(queueID); + string targetID = ""; + + if ( value.Contains("unloading_store")) + { + targetID = GetJsonValue(currentData, unloadStoreKey)?.ToString(); + } + else if ( value.Contains("unloading_queue")) + { + targetID = GetJsonValue(currentData, unloadQueueKey)?.ToString(); + } + else + { + string[] tmpValue = { "data", "output_queue" }; + + targetID = GetJsonValue(currentData, tmpValue)?.ToString(); + } + + SimulationModel model = new SimulationModel(); + model = DataManager.I.GetModel(targetID); SimulationModelStore storeModel = (SimulationModelStore)model; + if (listProducts.Count > 0) { GameObject product = listProducts[0];