|
1 | 1 | using System.Linq; |
| 2 | +using System.Threading.Tasks; |
2 | 3 | using NGPT; |
3 | 4 | using UnityEngine; |
4 | 5 | using UnityEngine.UI; |
@@ -27,10 +28,20 @@ public static void initializeButtons(UIGalaxySelect instance) |
27 | 28 | { |
28 | 29 | // backButton.onClick.RemoveAllListeners(); |
29 | 30 | randomButton.onClick.RemoveAllListeners(); |
| 31 | + randomButton.onClick.m_PersistentCalls.Clear(); |
| 32 | + startButton.onClick.RemoveAllListeners(); |
| 33 | + startButton.onClick.m_PersistentCalls.Clear(); |
30 | 34 | // backButton.onClick.AddListener(() => OnBackClick(instance)); |
| 35 | + startButton.onClick.AddListener(() => OnStartClick(instance)); |
31 | 36 | randomButton.onClick.AddListener(() => OnRandomClick(instance)); |
32 | 37 | } |
33 | 38 |
|
| 39 | + static void OnStartClick(UIGalaxySelect instance) |
| 40 | + { |
| 41 | + Debug.Log("Start Clicked"); |
| 42 | + Modeler.Reset(); |
| 43 | + Bootstrap.WaitUntil(()=>Modeler.Idle, ()=>PatchOnUIGalaxySelect.EnterGame(ref instance.gameDesc)); |
| 44 | + } |
34 | 45 | public static void ResetView() |
35 | 46 | { |
36 | 47 | GameCamera.instance.transform.localPosition = Vector3.zero; |
@@ -183,10 +194,24 @@ public static void OnBackClick(UIGalaxySelect instance) |
183 | 194 |
|
184 | 195 | public static void OnRandomClick(UIGalaxySelect instance) |
185 | 196 | { |
186 | | - instance.Rerand(); |
187 | | - ShowStarMap(instance.starmap); |
| 197 | + // await Modeler.KillPlanetCompute(); |
| 198 | + // Task.WaitAll( Modeler.RestartPlanetCalcThread(),Modeler.RestartPlanetComputeThread()); |
| 199 | + Modeler.Reset(); |
| 200 | + GS2.Log("A"); |
| 201 | + GS2.Warn(Modeler.processing.Count.ToString()); |
| 202 | + // instance.Rerand(); |
| 203 | + // ShowStarMap(instance.starmap); |
| 204 | + // PlanetModelingManager.StartPlanetCalculateThread(); |
| 205 | + Bootstrap.WaitUntil(()=>Modeler.Idle, () => |
| 206 | + { |
| 207 | + GS2.Log("Idle, restarting sysdisp"); |
| 208 | + instance.Rerand(); |
| 209 | + ShowStarMap(instance.starmap); |
| 210 | + }); |
| 211 | + |
188 | 212 | } |
189 | 213 |
|
| 214 | + |
190 | 215 | public static void OnStarMapClick(UIVirtualStarmap starmap, int starIndex) |
191 | 216 | { |
192 | 217 | // GS2.Warn($"StarmapClick { starIndex}"); |
@@ -357,6 +382,7 @@ public static void OnSolarSystemPlanetClick(UIVirtualStarmap starmap, int clickI |
357 | 382 | HideStarCount(); |
358 | 383 | pData.RunCalculateThread(); |
359 | 384 | ShowPlanetDetail(pData); |
| 385 | + GS2.Warn($"calculated:{pData.calculated} calculating:{pData.calculating}"); |
360 | 386 | } |
361 | 387 |
|
362 | 388 | public static void OnSolarSystemPlanetRightClick(UIVirtualStarmap starmap, int clickIndex) |
@@ -454,13 +480,13 @@ public static void ShowSolarSystem(UIVirtualStarmap starmap, int starIndex) |
454 | 480 | inSystemDisplay = true; |
455 | 481 | GS2.Warn("ShowSolarSystem"); |
456 | 482 | // start planet compute thread if not done already |
457 | | - // Modeler.aborted = false; |
458 | | - PlanetModelingManager.StartPlanetComputeThread(); |
459 | | - |
| 483 | + // Modeler.shouldAbort = false; |
| 484 | + // PlanetModelingManager.StartPlanetComputeThread(); |
| 485 | + // await Modeler.RestartPlanetCalcThread(); |
460 | 486 | // add star |
461 | 487 | var starData = starmap._galaxyData.StarById(starIndex + 1); // because StarById() decrements by 1 |
462 | 488 | AddStarToStarmap(starmap, starData); |
463 | | - |
| 489 | + starData.RunCalculateThread(); |
464 | 490 | var starScale = starmap.starPool[0].starData.radius / 40f * GS2.Config.VirtualStarmapStarScaleFactor; //This is RadiusAU |
465 | 491 | // var starScale = starmap.starPool[0].starData.radius * GS2.Config.VirtualStarmapStarScaleFactor; |
466 | 492 |
|
|
0 commit comments