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