forked from Nivekk/KOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVesselSensors.cs
More file actions
68 lines (62 loc) · 2.46 KB
/
Copy pathVesselSensors.cs
File metadata and controls
68 lines (62 loc) · 2.46 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kOS
{
public class VesselSensors : SpecialValue
{
Vector acceleration = new Vector(0, 0, 0);
Single pressure = 0;
Single temperature = 0;
Vector geeForce = new Vector(0, 0, 0);
Single KerbolExposure = 0;
public VesselSensors(Vessel target)
{
foreach (Part part in target.Parts)
{
if (part.State == PartStates.ACTIVE || part.State == PartStates.IDLE)
{
foreach (PartModule module in part.Modules)
{
if (module is ModuleEnviroSensor)
{
switch (module.Fields.GetValue("sensorType").ToString())
{
case "ACC":
acceleration = new Vector(FlightGlobals.getGeeForceAtPosition(part.transform.position) - target.acceleration);
break;
case "PRES":
pressure = (Single)FlightGlobals.getStaticPressure();
break;
case "TEMP":
temperature = part.temperature;
break;
case "GRAV":
geeForce = new Vector(FlightGlobals.getGeeForceAtPosition(part.transform.position));
break;
}
}
foreach (ModuleDeployableSolarPanel c in part.FindModulesImplementing<ModuleDeployableSolarPanel>())
{
KerbolExposure += (Single)c.sunAOA;
}
}
}
}
}
public override object GetSuffix(string suffixName)
{
if (suffixName == "ACC") return acceleration;
if (suffixName == "PRES") return pressure;
if (suffixName == "TEMP") return temperature;
if (suffixName == "GRAV") return geeForce;
if (suffixName == "LIGHT") return KerbolExposure;
return base.GetSuffix(suffixName);
}
public override string ToString()
{
return base.ToString();
}
}
}