forked from RemoteTechnologiesGroup/RemoteTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProtoSignalProcessor.cs
More file actions
54 lines (47 loc) · 2.48 KB
/
Copy pathProtoSignalProcessor.cs
File metadata and controls
54 lines (47 loc) · 2.48 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
using System;
using UnityEngine;
namespace RemoteTech.Modules
{
public class ProtoSignalProcessor : ISignalProcessor
{
public String Name { get { return String.Format("ProtoSignalProcessor({0})", VesselName); } }
public bool Visible { get { return MapViewFiltering.CheckAgainstFilter(mVessel); } }
public CelestialBody Body { get { return mVessel.mainBody; } }
public Vector3 Position { get { return mVessel.GetWorldPos3D(); } }
public String VesselName { get { return mVessel.vesselName; } set { mVessel.vesselName = value; } }
public bool VesselLoaded { get { return false; } }
public bool Powered { get; private set; }
public bool IsCommandStation { get; private set; }
public Guid Guid { get { return mVessel.id; } }
public Vessel Vessel { get { return mVessel; } }
public FlightComputer.FlightComputer FlightComputer { get { return null; } }
public bool IsMaster { get { return true; } }
private readonly Vessel mVessel;
public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
{
mVessel = v;
Powered = ppms.GetBool("IsRTPowered");
// get the crew count from the vessel
int crewcount = v.GetVesselCrew().Count;
// when the crewcount is eq 0 than look into the protoVessel
if (crewcount == 0 && v.protoVessel.GetVesselCrew() != null)
crewcount = v.protoVessel.GetVesselCrew().Count;
RTLog.Notify("ProtoSignalProcessor crew count of {0} is {1}", v.vesselName, crewcount);
try {
IsCommandStation = Powered && v.HasCommandStation() && crewcount >= ppms.GetInt("RTCommandMinCrew");
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
Powered, v.HasCommandStation(), crewcount, ppms.GetInt("RTCommandMinCrew"));
} catch (ArgumentException argexeception) {
// I'm assuming this would get thrown by ppms.GetInt()... do the other functions have an exception spec?
IsCommandStation = false;
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
Powered, v.HasCommandStation(), crewcount);
RTLog.Notify("ProtoSignalProcessor ", argexeception);
}
}
public override String ToString()
{
return Name;
}
}
}