Skip to content

Commit d008202

Browse files
sarbianLisias
authored andcommitted
Workaround for 1.6.0 PartDatabase rebuild
1 parent 1a500ea commit d008202

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

Source/ModuleManager/Fix16.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System.Collections;
2+
3+
namespace ModuleManager
4+
{
5+
class Fix16 : LoadingSystem
6+
{
7+
private void Awake()
8+
{
9+
if (Instance != null)
10+
{
11+
DestroyImmediate(this);
12+
return;
13+
}
14+
15+
Instance = this;
16+
DontDestroyOnLoad(gameObject);
17+
}
18+
19+
private static Fix16 Instance { get; set; }
20+
21+
private bool ready;
22+
23+
private int count;
24+
25+
private int current;
26+
27+
private const int yieldStep = 20;
28+
29+
public override bool IsReady()
30+
{
31+
return ready;
32+
}
33+
34+
public override string ProgressTitle()
35+
{
36+
return "Fix 1.6.0 " + current + "/" + count;
37+
}
38+
39+
public override float ProgressFraction()
40+
{
41+
return (float) current / count;
42+
}
43+
44+
public override void StartLoad()
45+
{
46+
ready = false;
47+
48+
count = PartLoader.LoadedPartsList.Count;
49+
50+
StartCoroutine(DoFix());
51+
}
52+
53+
private IEnumerator DoFix()
54+
{
55+
int yieldCounter = 0;
56+
for (current = 0; current < count; current++)
57+
{
58+
AvailablePart avp = PartLoader.LoadedPartsList[current];
59+
if (avp.partPrefab.dragModel == Part.DragModel.CUBE && !avp.partPrefab.DragCubes.Procedural &&
60+
!avp.partPrefab.DragCubes.None && avp.partPrefab.DragCubes.Cubes.Count == 0)
61+
{
62+
DragCubeSystem.Instance.LoadDragCubes(avp.partPrefab);
63+
}
64+
65+
if (yieldCounter++ >= yieldStep)
66+
{
67+
yieldCounter = 0;
68+
yield return null;
69+
}
70+
}
71+
72+
ready = true;
73+
yield return null;
74+
}
75+
76+
public override float LoadWeight()
77+
{
78+
return 0.1f;
79+
}
80+
}
81+
}

Source/ModuleManager/ModuleManager.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ internal void Awake()
118118

119119
int gameDatabaseIndex = list.FindIndex(s => s is GameDatabase);
120120
list.Insert(gameDatabaseIndex + 1, loader);
121+
122+
// Workaround for 1.6.0 Editor bug after a PartDatabase rebuild.
123+
if (Versioning.version_major == 1 && Versioning.version_minor == 6 && Versioning.Revision == 0)
124+
{
125+
Fix16 fix16 = aGameObject.AddComponent<Fix16>();
126+
list.Add(fix16);
127+
}
121128
}
122129

123130
bool foolsDay = (DateTime.Now.Month == 4 && DateTime.Now.Day == 1);

Source/ModuleManager/ModuleManager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<ConsolePause>False</ConsolePause>
3333
</PropertyGroup>
3434
<ItemGroup>
35+
<Compile Include="Fix16.cs" />
3536
<Compile Include="Cats\CatAnimator.cs" />
3637
<Compile Include="Cats\CatManager.cs" />
3738
<Compile Include="Cats\CatMover.cs" />

0 commit comments

Comments
 (0)