-
Notifications
You must be signed in to change notification settings - Fork 4
/
KESterling.cs
58 lines (53 loc) · 1.86 KB
/
KESterling.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ModuleKELights
{
class KESterlingEngine : PartModule
{
[KSPField]
public string resourceName = null;
[KSPField]
public double resourceAmt = 0.001f;
[KSPField]
public bool actRad = false;
[KSPField(guiActive = true, guiName = "Electric Charge")]
public double transAmt = 0.0;
public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight)
{
return;
}
double kw = Math.Abs(this.part.thermalRadiationFlux);
Part rPart = KEFunctions.GetResourcePart(FlightGlobals.ActiveVessel, resourceName);
if (rPart != null)
{
int id = KEFunctions.GetResourceID(rPart, resourceName);
double rTotal = KEFunctions.GetVesselResourceAmount(FlightGlobals.ActiveVessel, resourceName);
double rMax = KEFunctions.GetVesselResourceMax(FlightGlobals.ActiveVessel, resourceName);
transAmt = resourceAmt * kw;
if (actRad == true) // look for active radiator
{
for (int i = this.part.Modules.Count - 1; i >= 0; --i)
{
PartModule M = this.part.Modules[i];
if (M is ModuleActiveRadiator)
{
if ((M as ModuleActiveRadiator).IsCooling)
{
rPart.TransferResource(id, transAmt);
}
}
}
}
else
{
rPart.TransferResource(id, transAmt);
}
}
}
}
}