Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ThermometerElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
6
7 public float m_voltage;
8
9 public const float m_pollingPeriod = 0.5f;
10
11 public ThermometerElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) =>
13
14 public override float GetOutputVoltage(int face) => m_voltage;
15
16 public override bool Simulate() {
17 float voltage = m_voltage;
18 CellFace cellFace = CellFaces[0];
19 m_voltage = MathUtils.Saturate(m_subsystemMetersBlockBehavior.GetThermometerReading(cellFace.X, cellFace.Y, cellFace.Z) / 15f);
20 float num = m_pollingPeriod * (0.9f + 0.0002f * (GetHashCode() % 1000));
21 SubsystemElectricity.QueueElectricElementForSimulation(this, SubsystemElectricity.CircuitStep + MathUtils.Max((int)(num / 0.01f), 1));
22 return m_voltage != voltage;
23 }
24 }
25}
static float Saturate(float x)
static int Max(int x1, int x2)
SubsystemElectricity SubsystemElectricity
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
ReadOnlyList< CellFace > CellFaces
ThermometerElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) override float GetOutputVoltage(int face)
SubsystemMetersBlockBehavior m_subsystemMetersBlockBehavior