Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
BaseDelayGateElectricElement.cs
浏览该文件的文档.
1namespace Game {
3 public float m_voltage;
4
5 public float m_lastStoredVoltage;
6
7 public Dictionary<int, float> m_voltagesHistory = [];
8
9 public abstract int DelaySteps { get; }
10
11 public BaseDelayGateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
12
13 public override float GetOutputVoltage(int face) => m_voltage;
14
15 public override bool Simulate() {
16 float voltage = m_voltage;
17 int delaySteps = DelaySteps;
18 float num = 0f;
19 foreach (ElectricConnection connection in Connections) {
20 if (connection.ConnectorType != ElectricConnectorType.Output
21 && connection.NeighborConnectorType != 0) {
23 break;
24 }
25 }
26 if (delaySteps > 0) {
27 if (m_voltagesHistory.TryGetValue(SubsystemElectricity.CircuitStep, out float value)) {
28 m_voltage = value;
30 }
31 if (num != m_lastStoredVoltage) {
33 if (m_voltagesHistory.Count < 300) {
36 }
37 }
38 }
39 else {
40 m_voltage = num;
41 }
42 return m_voltage != voltage;
43 }
44 }
45}
BaseDelayGateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
virtual float GetOutputVoltage(int face)
List< ElectricConnection > Connections
RotateableElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)