Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SRLatchElectricElement.cs
浏览该文件的文档.
1namespace Game {
3 public bool m_setAllowed = true;
4
5 public bool m_resetAllowed = true;
6
7 public bool m_clockAllowed = true;
8
9 public float m_voltage;
10
11 public SRLatchElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) {
12 float? num = subsystemElectricity.ReadPersistentVoltage(cellFace.Point);
13 if (num.HasValue) {
14 m_voltage = num.Value;
15 }
16 }
17
18 public override float GetOutputVoltage(int face) => m_voltage;
19
20 public override bool Simulate() {
21 float voltage = m_voltage;
22 bool flag = false;
23 bool flag2 = false;
24 bool flag3 = false;
25 bool flag4 = false;
26 int rotation = Rotation;
27 foreach (ElectricConnection connection in Connections) {
28 if (connection.ConnectorType != ElectricConnectorType.Output
29 && connection.NeighborConnectorType != 0) {
31 CellFaces[0].Face,
32 rotation,
33 connection.ConnectorFace
34 );
35 if (connectorDirection.HasValue) {
36 if (connectorDirection == ElectricConnectorDirection.Right) {
38 }
39 else if (connectorDirection == ElectricConnectorDirection.Left) {
41 }
42 else if (connectorDirection == ElectricConnectorDirection.Bottom) {
44 flag4 = true;
45 }
46 }
47 }
48 }
49 if (flag4) {
50 if (flag3 && m_clockAllowed) {
51 m_clockAllowed = false;
52 if (flag && flag2) {
54 }
55 else if (flag) {
56 m_voltage = 1f;
57 }
58 else if (flag2) {
59 m_voltage = 0f;
60 }
61 }
62 }
63 else if (flag && m_setAllowed) {
64 m_setAllowed = false;
65 m_voltage = 1f;
66 }
67 else if (flag2 && m_resetAllowed) {
68 m_resetAllowed = false;
69 m_voltage = 0f;
70 }
71 if (!flag3) {
72 m_clockAllowed = true;
73 }
74 if (!flag) {
75 m_setAllowed = true;
76 }
77 if (!flag2) {
78 m_resetAllowed = true;
79 }
80 if (m_voltage != voltage) {
82 return true;
83 }
84 return false;
85 }
86 }
87}
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
static bool IsSignalHigh(float voltage)
virtual float GetOutputVoltage(int face)
List< ElectricConnection > Connections
ReadOnlyList< CellFace > CellFaces
RotateableElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
SRLatchElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
override float GetOutputVoltage(int face)
static ? ElectricConnectorDirection GetConnectorDirection(int mountingFace, int rotation, int connectorFace)
void WritePersistentVoltage(Point3 point, float voltage)