-
Notifications
You must be signed in to change notification settings - Fork 2
/
RCSFuelTank.cs
75 lines (67 loc) · 2.13 KB
/
RCSFuelTank.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
73
74
75
using UnityEngine;
namespace MajiirKerbalLib
{
public class RCSFuelTank : global::RCSFuelTank
{
[KSPField]
private bool allowFlow = true;
[KSPField(guiActive = true, guiName = "RCS Fuel", guiUnits = "L", guiFormat = "F1", isPersistant = false)]
public float displayFuel;
protected override void onPartStart()
{
this.started = true;
base.onPartStart();
}
protected override void onPartFixedUpdate()
{
if ((this.state == PartStates.DEACTIVATED) && (this.fuel > 0))
{
this.state = PartStates.ACTIVE;
}
if (this.state == PartStates.ACTIVE)
{
this.stackIcon.SetIconColor(XKCDColors.LightPeriwinkle);
}
base.onPartFixedUpdate();
this.displayFuel = this.fuel;
}
public override bool RequestRCS(float amount, int earliestStage)
{
var commander = VesselCommander.GetInstance(this.vessel);
if (!commander.ReturnRealRCS)
{
commander.RequestedRCS += amount;
return true;
}
if (!allowFlow)
{
foreach (var part in this.children)
{
if (part.RequestRCS(amount, earliestStage))
{
return true;
}
}
return false;
}
return base.RequestRCS(amount, earliestStage);
}
[KSPEvent(guiActive = false, guiName = "Enable flow")]
private void AllowFlow()
{
this.allowFlow = true;
UpdateGui();
}
[KSPEvent(guiActive = true, guiName = "Disable flow")]
private void DenyFlow()
{
this.allowFlow = false;
UpdateGui();
}
private void UpdateGui()
{
Events["AllowFlow"].guiActive = Events["AllowFlow"].active = !this.allowFlow;
Events["DenyFlow"].guiActive = Events["DenyFlow"].active = this.allowFlow;
}
}
}