Skip to content

Commit 9180958

Browse files
committed
2.7.6
1 parent 2194b08 commit 9180958

File tree

16 files changed

+561
-638
lines changed

16 files changed

+561
-638
lines changed

Bootstrap.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System.Collections;
2+
using System.IO;
23
using System.Reflection;
34
using BepInEx;
45
using BepInEx.Logging;
56
using HarmonyLib;
7+
using UnityEngine;
68

79
namespace GalacticScale
810
{
@@ -12,16 +14,18 @@ public partial class GS2
1214
}
1315

1416

15-
[BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.7.5")]
17+
[BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.7.6")]
1618
[BepInDependency("space.customizing.console", BepInDependency.DependencyFlags.SoftDependency)]
1719
[BepInDependency("dsp.nebula-multiplayer-api", BepInDependency.DependencyFlags.SoftDependency)]
1820
public class Bootstrap : BaseUnityPlugin
1921
{
22+
public static Bootstrap instance;
2023
public new static ManualLogSource Logger;
2124
public static Queue buffer = new();
2225

2326
internal void Awake()
2427
{
28+
instance = this;
2529
InitializeLogger();
2630
InitializeComponents();
2731
ApplyHarmonyPatches();
@@ -139,5 +143,19 @@ public static void Debug(object data)
139143
{
140144
Debug(data, LogLevel.Message, true);
141145
}
146+
147+
public static void WaitUntil(TestFunction t, TestThen u)
148+
{
149+
instance.StartCoroutine(WaitUntilRoutine(t, u));
150+
}
151+
public static IEnumerator WaitUntilRoutine(TestFunction t, TestThen u)
152+
{
153+
yield return new WaitUntil(()=>t());
154+
u();
155+
}
142156
}
157+
158+
public delegate bool TestFunction();
159+
160+
public delegate void TestThen();
143161
}

GalacticScale3.csproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
<TargetFramework>net472</TargetFramework>
55
<RootNamespace>GalacticScale</RootNamespace>
66
</PropertyGroup>
7-
<Import Project="$(DevEnvLoc)" Condition="Exists('$(DevEnvLoc)')"/>
7+
<Import Project="$(DevEnvLoc)" Condition="Exists('$(DevEnvLoc)')" />
88
<PropertyGroup>
99
<AssemblyName>GalacticScale</AssemblyName>
1010
<Description>Galaxy Customization for Dyson Sphere Program</Description>
11-
<Version>2.7.5</Version>
11+
<Version>2.7.6</Version>
1212
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1313
<LangVersion>9.0</LangVersion>
1414
<OutDir>bin/$(Configuration)</OutDir>
1515
<OutDir Condition="Exists($(PluginDir))">$(PluginDir)\Galactic_Scale-GalacticScale\</OutDir>
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all"/>
20-
<PackageReference Include="BepInEx.Core" Version="5.*"/>
21-
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*"/>
22-
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile"/>
23-
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.9.26.13026-r.0" IncludeAssets="compile"/>
24-
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="*" IncludeAssets="compile"/>
19+
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
20+
<PackageReference Include="BepInEx.Core" Version="5.*" />
21+
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
22+
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
23+
<PackageReference Include="DysonSphereProgram.GameLibs" Version="0.9.26.13026-r.0" IncludeAssets="compile" />
24+
<PackageReference Include="DysonSphereProgram.Modding.NebulaMultiplayerModApi" Version="*" IncludeAssets="compile" />
2525
</ItemGroup>
2626

2727
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
28-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all"/>
28+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
2929
</ItemGroup>
3030

3131
<ItemGroup>
@@ -45,7 +45,7 @@
4545
</ItemGroup>
4646

4747
<ItemGroup>
48-
<None Remove="Assets\galaxy.json"/>
49-
<EmbeddedResource Include="Assets\galaxy.json"/>
48+
<None Remove="Assets\galaxy.json" />
49+
<EmbeddedResource Include="Assets\galaxy.json" />
5050
</ItemGroup>
5151
</Project>

Package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# BACKUP YOUR SAVES. SERIOUSLY.
44

5+
- Version 2.7.6 - Fix errors when starting/ending game while still calculating veins
56
- Version 2.7.5 - Fix error when loading game while planets are calculating
67
- Version 2.7.4 - Combine Gas/Liquid Items in Star Detail again. Fix System view UI. Fix Sandbox toggle in newgame and
78
load game.

Scripts/Editor/SystemDisplay.cs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using System.Threading.Tasks;
23
using NGPT;
34
using UnityEngine;
45
using UnityEngine.UI;
@@ -27,10 +28,20 @@ public static void initializeButtons(UIGalaxySelect instance)
2728
{
2829
// backButton.onClick.RemoveAllListeners();
2930
randomButton.onClick.RemoveAllListeners();
31+
randomButton.onClick.m_PersistentCalls.Clear();
32+
startButton.onClick.RemoveAllListeners();
33+
startButton.onClick.m_PersistentCalls.Clear();
3034
// backButton.onClick.AddListener(() => OnBackClick(instance));
35+
startButton.onClick.AddListener(() => OnStartClick(instance));
3136
randomButton.onClick.AddListener(() => OnRandomClick(instance));
3237
}
3338

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+
}
3445
public static void ResetView()
3546
{
3647
GameCamera.instance.transform.localPosition = Vector3.zero;
@@ -183,10 +194,24 @@ public static void OnBackClick(UIGalaxySelect instance)
183194

184195
public static void OnRandomClick(UIGalaxySelect instance)
185196
{
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+
188212
}
189213

214+
190215
public static void OnStarMapClick(UIVirtualStarmap starmap, int starIndex)
191216
{
192217
// GS2.Warn($"StarmapClick { starIndex}");
@@ -357,6 +382,7 @@ public static void OnSolarSystemPlanetClick(UIVirtualStarmap starmap, int clickI
357382
HideStarCount();
358383
pData.RunCalculateThread();
359384
ShowPlanetDetail(pData);
385+
GS2.Warn($"calculated:{pData.calculated} calculating:{pData.calculating}");
360386
}
361387

362388
public static void OnSolarSystemPlanetRightClick(UIVirtualStarmap starmap, int clickIndex)
@@ -454,13 +480,13 @@ public static void ShowSolarSystem(UIVirtualStarmap starmap, int starIndex)
454480
inSystemDisplay = true;
455481
GS2.Warn("ShowSolarSystem");
456482
// 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();
460486
// add star
461487
var starData = starmap._galaxyData.StarById(starIndex + 1); // because StarById() decrements by 1
462488
AddStarToStarmap(starmap, starData);
463-
489+
starData.RunCalculateThread();
464490
var starScale = starmap.starPool[0].starData.radius / 40f * GS2.Config.VirtualStarmapStarScaleFactor; //This is RadiusAU
465491
// var starScale = starmap.starPool[0].starData.radius * GS2.Config.VirtualStarmapStarScaleFactor;
466492

Scripts/Patches/GameLoader/FixedUpdate.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ public static bool FixedUpdate(ref GameLoader __instance)
4141
// GS2.Warn($"{GameMain.localStar?.name}");
4242
if (GameMain.mainPlayer != null && GameMain.gameTick == 0L && GS2.Config.SkipPrologue)
4343
{
44-
//GS2.Warn($"Setting uPosition");
44+
// GS2.Warn($"Setting uPosition");
4545
GameMain.mainPlayer.uPosition = GameMain.localPlanet.uPosition;
4646
}
4747

48-
GS2.Warn($"{GameMain.localPlanet == null}");
48+
// GS2.Warn($"{GameMain.localPlanet == null}");
4949
GameMain.localPlanet?.Load();
5050
GameMain.localStar?.Load();
5151
}
5252

5353
if (__instance.frame >= 7)
5454
{
55-
//GS2.Warn("FRAME 7");
55+
// GS2.Warn("FRAME 7");
5656
// if (!GS2.Config.SkipPrologue) if (GameMain.localStar != null && !GameMain.localStar.loaded) __instance.frame = 7;
5757
// else
5858
// {
@@ -68,7 +68,7 @@ public static bool FixedUpdate(ref GameLoader __instance)
6868
{
6969
if (GameMain.data == null)
7070
{
71-
GS2.Warn("GameMain.data null");
71+
// GS2.Warn("GameMain.data null");
7272
return false;
7373
}
7474

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using HarmonyLib;
2+
3+
namespace GalacticScale
4+
{
5+
public partial class PatchOnPlanetAlgorithm
6+
{
7+
8+
9+
[HarmonyPrefix]
10+
[HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateVeins")]
11+
public static bool PlanetAlgorithm13_GenerateVeins(PlanetAlgorithm13 __instance)
12+
{
13+
GS2.Log("Running GenerateVeins on PA13");
14+
if (__instance.planet == null || __instance.planet.data == null) return false;
15+
return true;
16+
}
17+
18+
[HarmonyPrefix]
19+
[HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateVeins")]
20+
public static bool PlanetAlgorithm12_GenerateVeins(PlanetAlgorithm12 __instance)
21+
{
22+
if (__instance.planet == null || __instance.planet.data == null) return false;
23+
return true;
24+
}
25+
26+
[HarmonyPrefix]
27+
[HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateVeins")]
28+
public static bool PlanetAlgorithm11_GenerateVeins(PlanetAlgorithm11 __instance)
29+
{
30+
if (__instance.planet == null || __instance.planet.data == null) return false;
31+
return true;
32+
}
33+
34+
35+
36+
37+
[HarmonyPrefix]
38+
[HarmonyPatch(typeof(PlanetAlgorithm7), "GenerateVeins")]
39+
public static bool PlanetAlgorithm7_GenerateVeins(PlanetAlgorithm7 __instance)
40+
{
41+
if (__instance.planet == null || __instance.planet.data == null) return false;
42+
return true;
43+
}
44+
45+
46+
47+
48+
49+
50+
[HarmonyPrefix]
51+
[HarmonyPatch(typeof(PlanetAlgorithm), "GenerateVeins")]
52+
public static bool PlanetAlgorithm_GenerateVeins(PlanetAlgorithm __instance)
53+
{
54+
if (__instance.planet == null || __instance.planet.data == null) return false;
55+
return true;
56+
}
57+
58+
[HarmonyPrefix]
59+
[HarmonyPatch(typeof(PlanetAlgorithm0), "GenerateVeins")]
60+
public static bool PlanetAlgorithm0_GenerateVeins(PlanetAlgorithm0 __instance)
61+
{
62+
if (__instance.planet == null || __instance.planet.data == null) return false;
63+
return true;
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)