Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
RandomGeneratorElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public bool m_clockAllowed = true;
6
7 public float m_voltage;
8
9 public static Random s_random = new();
10
11 public RandomGeneratorElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) {
13 m_voltage = num ?? GetRandomVoltage();
14 }
15
16 public override float GetOutputVoltage(int face) => m_voltage;
17
18 public override bool Simulate() {
19 float voltage = m_voltage;
20 bool flag = false;
21 bool flag2 = false;
22 _ = Rotation;
23 foreach (ElectricConnection connection in Connections) {
24 if (connection.ConnectorType != ElectricConnectorType.Output
25 && connection.NeighborConnectorType != 0) {
27 if (m_clockAllowed) {
28 flag = true;
29 m_clockAllowed = false;
30 }
31 }
32 else {
33 m_clockAllowed = true;
34 }
35 flag2 = true;
36 }
37 }
38 if (flag2) {
39 if (flag) {
41 }
42 }
43 else {
46 this,
47 SubsystemElectricity.CircuitStep + MathUtils.Max((int)(s_random.Float(0.25f, 0.75f) / 0.01f), 1)
48 );
49 }
50 if (m_voltage != voltage) {
52 return true;
53 }
54 return false;
55 }
56
57 public static float GetRandomVoltage() => s_random.Int(0, 15) / 15f;
58 }
59}
static int Max(int x1, int x2)
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
static bool IsSignalHigh(float voltage)
virtual float GetOutputVoltage(int face)
List< ElectricConnection > Connections
ReadOnlyList< CellFace > CellFaces
RandomGeneratorElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
RotateableElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
void WritePersistentVoltage(Point3 point, float voltage)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)