forked from JDPKSP/RemoteTechLegacy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRelayPath.cs
More file actions
70 lines (62 loc) · 1.66 KB
/
RelayPath.cs
File metadata and controls
70 lines (62 loc) · 1.66 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
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace RemoteTech
{
public class RelayPath
{
//nodes through which the signal is relayed
public List<RelayNode> nodes = new List<RelayNode>();
public RelayPath(List<RelayNode> nodes)
{
this.nodes = nodes;
}
public double Length
{
get
{
double length = 0;
for (int i = 1; i < nodes.Count; i++)
{
length += (nodes[i].Position - nodes[i - 1].Position).magnitude;
}
return length;
}
}
public double ControlDelay
{
get
{
return (2 * this.Length / RTGlobals.speedOfLight);
}
}
public override String ToString()
{
String ret;
if (nodes.Count > 0) ret = nodes[nodes.Count - 1].ToString();
else ret = "empty path???????";
for (int i = nodes.Count - 2; i >= 0; i--)
{
ret += " → " + nodes[i].ToString();
}
return ret;
}
// NK add last leg info
public float lastLeg()
{
if (nodes.Count > 1)
return RelayNetwork.nodeDistance(nodes[0], nodes[1]);
else
return 0f;
}
public float lastLegMax()
{
if (nodes.Count > 1)
return RelayNetwork.maxDistance(nodes[0], nodes[1]) * 1000f;
else
return 0f;
}
}
}