This commit is contained in:
lwj
2025-05-29 09:25:40 +09:00
parent f25c610782
commit 8a75eaa23e
13 changed files with 963 additions and 64 deletions

View File

@@ -25,6 +25,9 @@ public class SimulationModelMove : SimulationModel
float elapsedTime = 0;
Vector3 originalPos;
Vector3 prevPos;
bool isRewind = false;
void Update()
{
int interval = 0;
@@ -41,6 +44,7 @@ public class SimulationModelMove : SimulationModel
if (destination != null)
{
elapsedTime += Time.deltaTime;
if (elapsedTime / arrivalTime > 1.0f)
{
transform.position = destination.position;
@@ -55,7 +59,8 @@ public class SimulationModelMove : SimulationModel
dir.Normalize();
transform.forward = dir;
prevPos = transform.position;
}
}
}
}
protected override IEnumerator RunSimulationCoroutine()
@@ -85,6 +90,7 @@ public class SimulationModelMove : SimulationModel
string[] adjustedTimeKey = { "data", "adjusted" };
string[] inputQueueKey = { "data", "input", "queues" };
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" };
@@ -93,11 +99,46 @@ public class SimulationModelMove : SimulationModel
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))
{
JArray sourceQueues = GetJsonArray(currentData, sourceQueueKey);
JArray sourceStores = GetJsonArray(currentData, sourceStoreKey);
int loadCount = GetJsonIntValue(currentData, loadCountKey);
yield return null;
JArray sourceQueues = GetJsonArray(currentData, sourceQueueKey);
JArray sourceStores = GetJsonArray(currentData, sourceStoreKey);
int loadCount = GetJsonIntValue(currentData, loadCountKey);
if (sourceQueues != null && sourceQueues.HasValues)
{
string queueID = sourceQueues[0].ToString();
@@ -106,9 +147,11 @@ public class SimulationModelMove : SimulationModel
for (int i = 0; i < loadCount; i++)
{
GameObject product = null;
yield return new WaitUntil(() => {
yield return new WaitUntil(() =>
{
product = storeModel.GetProduct();
return product != null; });
return product != null;
});
product.transform.parent = productPos;
product.transform.localPosition = Vector3.zero;
product.transform.localRotation = Quaternion.identity;
@@ -123,7 +166,8 @@ public class SimulationModelMove : SimulationModel
for (int i = 0; i < loadCount; i++)
{
GameObject product = null;
yield return new WaitUntil(() => {
yield return new WaitUntil(() =>
{
product = storeModel.GetProduct();
return product != null;
});
@@ -135,8 +179,10 @@ public class SimulationModelMove : SimulationModel
}
else if (value.Contains(eventMove))
{
Debug.Log("MoveeventIncomming");
elapsedTime = 0;
arrivalTime = GetJsonFloatValue(currentData, arrivalTimeKey);
arrivalTime = GetJsonFloatValue(currentData, arrivalTimeKey);
originalPos = transform.position;
prevPos = transform.position;
JArray originQueues = GetJsonArray(currentData, inputQueueKey);
@@ -146,17 +192,19 @@ public class SimulationModelMove : SimulationModel
string queueID = originQueues[0].ToString();
SimulationModel model = DataManager.I.GetModel(queueID);
SimulationModelStore storeModel = (SimulationModelStore)model;
origin = storeModel.GetTransporterPosition();
origin = storeModel.GetTransporterPosition();
}
if (arrivalQueue != null)
{
{
SimulationModel model = DataManager.I.GetModel(arrivalQueue);
SimulationModelStore storeModel = (SimulationModelStore)model;
destination = storeModel.GetTransporterPosition();
destination = storeModel.GetTransporterPosition();
}
}
else if (value.Contains(eventUnloading))
{
{
yield return null;
string queueID = GetJsonValue(currentData, unloadQueueKey)?.ToString();
SimulationModel model = DataManager.I.GetModel(queueID);
SimulationModelStore storeModel = (SimulationModelStore)model;
@@ -176,7 +224,7 @@ public class SimulationModelMove : SimulationModel
float originalTime = GetJsonFloatValue(currentData, originalTimeKey);
float adjustedTime = GetJsonFloatValue(currentData, adjustedTimeKey);
arrivalTime += adjustedTime - originalTime;
elapsedTime = 0;
elapsedTime = 0;
originalPos = transform.position;
prevPos = transform.position;
}