/
Notes_CheckListMonoBehaviour.cs
72 lines (57 loc) · 1.41 KB
/
Notes_CheckListMonoBehaviour.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BetterNotes.Framework;
using UnityEngine;
namespace BetterNotes.NoteClasses.CheckListHandler
{
public class Notes_CheckListMonoBehaviour : Notes_MBE
{
private static Notes_CheckListMonoBehaviour instance;
public static Notes_CheckListMonoBehaviour Instance
{
get { return instance; }
}
protected override void Start()
{
instance = this;
}
protected override void OnDestroy()
{
}
public void startBlastOffWatcher(Vessel v, Notes_CheckListItem n)
{
StartCoroutine(blastOffWatcher(v, n));
}
private IEnumerator blastOffWatcher(Vessel v, Notes_CheckListItem n)
{
float timer = 0;
double targetAlt = 0;
if (v.mainBody.atmosphere)
targetAlt = v.mainBody.atmosphereDepth / 20;
else
targetAlt = v.mainBody.Radius / 200;
while (timer < 300)
{
switch (v.situation)
{
case Vessel.Situations.LANDED:
case Vessel.Situations.SPLASHED:
yield break;
default:
if (v.altitude >= targetAlt)
{
n.setComplete();
yield break;
}
timer += TimeWarp.deltaTime;
n.Text = string.Format("Take off from {0}\n(Achieve {1:F0}m within {2:F0}sec)", n.TargetBody.theName, targetAlt, timer);
yield return null;
break;
}
}
n.Text = string.Format("Take off from {0}", n.TargetBody.theName);
}
}
}