Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PistonElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public int m_lastLength = -1;
6
7 public PistonElectricElement(SubsystemElectricity subsystemElectricity, Point3 point) : base(
8 subsystemElectricity,
9 new List<CellFace> {
10 new(point.X, point.Y, point.Z, 0),
11 new(point.X, point.Y, point.Z, 1),
12 new(point.X, point.Y, point.Z, 2),
13 new(point.X, point.Y, point.Z, 3),
14 new(point.X, point.Y, point.Z, 4),
15 new(point.X, point.Y, point.Z, 5)
16 }
17 ) { }
18
19 public override bool Simulate() {
20 float num = 0f;
21 foreach (ElectricConnection connection in Connections) {
22 if (connection.ConnectorType != ElectricConnectorType.Output
23 && connection.NeighborConnectorType != 0) {
25 }
26 }
27 int num2 = MathUtils.Max((int)(num * 15.999f) - 7, 0);
28 if (num2 != m_lastLength) {
29 m_lastLength = num2;
30 SubsystemElectricity.Project.FindSubsystem<SubsystemPistonBlockBehavior>(true).AdjustPiston(CellFaces[0].Point, num2);
31 }
32 return false;
33 }
34 }
35}
static int Max(int x1, int x2)
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
SubsystemElectricity SubsystemElectricity
virtual float GetOutputVoltage(int face)
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
List< ElectricConnection > Connections
ReadOnlyList< CellFace > CellFaces
PistonElectricElement(SubsystemElectricity subsystemElectricity, Point3 point)