Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
RealTimeClockElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
6
7 public int m_lastClockValue = -1;
8
9 public const int m_periodsPerDay = 4096;
10
11 public RealTimeClockElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) =>
13
14 public override float GetOutputVoltage(int face) {
16 if (connectorDirection.HasValue) {
17 if (connectorDirection.Value == ElectricConnectorDirection.Top) {
18 return (GetClockValue() & 0xF) / 15f;
19 }
20 if (connectorDirection.Value == ElectricConnectorDirection.Right) {
21 return ((GetClockValue() >> 4) & 0xF) / 15f;
22 }
23 if (connectorDirection.Value == ElectricConnectorDirection.Bottom) {
24 return ((GetClockValue() >> 8) & 0xF) / 15f;
25 }
26 if (connectorDirection.Value == ElectricConnectorDirection.Left) {
27 return ((GetClockValue() >> 12) & 0xF) / 15f;
28 }
29 if (connectorDirection.Value == ElectricConnectorDirection.In) {
30 return ((GetClockValue() >> 16) & 0xF) / 15f;
31 }
32 }
33 return 0f;
34 }
35
36 public override bool Simulate() {
37 double day = m_subsystemTimeOfDay.Day;
38 int num = (int)(((Math.Ceiling(day * 4096.0) + 0.5) / 4096.0 - day) * m_subsystemTimeOfDay.DayDuration / 0.0099999997764825821);
41 int clockValue = GetClockValue();
42 if (clockValue != m_lastClockValue) {
43 m_lastClockValue = clockValue;
44 return true;
45 }
46 return false;
47 }
48
49 public int GetClockValue() => (int)(m_subsystemTimeOfDay.Day * 4096.0);
50 }
51}
static int Max(int x1, int x2)
ReadOnlyList< CellFace > CellFaces
RealTimeClockElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) override float GetOutputVoltage(int face)
RotateableElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
static ? ElectricConnectorDirection GetConnectorDirection(int mountingFace, int rotation, int connectorFace)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)