void MakeHub() { Objects.Hub hub = Objects.Hub.New(); var pos = new Vector3(Screen.width / 2, Screen.height / 2, 0); var pos2 = hub.transform.position; pos = Selectable.Cam.ScreenToWorldPoint(pos); pos2.x = pos.x + Random.Range(-1, 1); pos2.y = 500; pos2.z = pos.z + Random.Range(-1, 1); hub.transform.position = pos2; }
private IEnumerator HubLog(Objects.Hub hub) { if (!IsLogging) { yield break; } yield return(new WaitUntil(() => TimeKeeper.TimeSpeed != TimeSpeed.Pause)); if (!Directory.Exists(_logPath)) { Directory.CreateDirectory(_logPath); } if (!File.Exists(hub.logPath)) { string[] headers = { "Timestamp", "time (s)", "Total Drones", "Active Drones", "Crashed Drones", "Total Batteries", "Charging Batteries", "Job Queue Length", "Jobs Delayed in Queue", "Jobs Completed", "Completed Jobs Delayed", "Jobs Failed", "Income ($)", "Delay (s)", "Audibility (s)", "Energy (kWh)" }; WriteTupleToMemory(ref hub.dataCache, headers); Flush(hub.logPath, ref hub.dataCache); } var time = TimeKeeper.Chronos.Get(); var wait = new WaitUntil(() => time.Timer() > LoggingPeriod); while (true) { hub.GetData(this, time); WriteTupleToMemory(ref hub.dataCache, _hubData); yield return(wait); time.Now(); } }
public static void LogHub(Objects.Hub hub) { _instance.StartCoroutine(_instance.HubLog(hub)); }