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
62 lines (54 loc) · 2.33 KB
/
Copy pathProtoSignalProcessor.cs
File metadata and controls
62 lines (54 loc) · 2.33 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
using System;
using UnityEngine;
namespace RemoteTech.Modules
{
public class ProtoSignalProcessor : ISignalProcessor
{
public string Name { get { return $"ProtoSignalProcessor({VesselName})"; } }
public bool Visible => MapViewFiltering.CheckAgainstFilter(Vessel);
public CelestialBody Body => Vessel.mainBody;
public Vector3 Position => Vessel.GetWorldPos3D();
public string VesselName
{
get { return Vessel.vesselName; }
set { Vessel.vesselName = value; }
}
public bool VesselLoaded => false;
public bool Powered { get; }
public bool IsCommandStation { get; }
public Guid VesselId => Vessel.id;
public Vessel Vessel { get; }
public FlightComputer.FlightComputer FlightComputer => null;
public bool IsMaster => true;
public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
{
Vessel = v;
Powered = ppms.GetBool("IsRTPowered");
// get the crew count from the vessel
var crewcount = v.GetVesselCrew().Count;
// when the crew count is equal to 0 then 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);
int ppmsMinCrew;
//try to get the RTCommandMinCrew value in the ProtoPartModuleSnapshot
if (ppms.GetInt("RTCommandMinCrew", out ppmsMinCrew))
{
IsCommandStation = Powered && v.HasCommandStation() && crewcount >= ppmsMinCrew;
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2}/{3})",
Powered, v.HasCommandStation(), crewcount, ppmsMinCrew);
}
else
{
// there was no RTCommandMinCrew member in the ProtoPartModuleSnapshot
IsCommandStation = false;
RTLog.Notify("ProtoSignalProcessor(Powered: {0}, HasCommandStation: {1}, Crew: {2})",
Powered, v.HasCommandStation(), crewcount);
}
}
public override string ToString()
{
return Name;
}
}
}