Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
4 public abstract class ElectricElement {
6
7 public ReadOnlyList<CellFace> CellFaces { get; set; }
8
9 public List<ElectricConnection> Connections { get; set; }
10
11 public ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable<CellFace> cellFaces) {
12 SubsystemElectricity = subsystemElectricity;
13 CellFaces = new ReadOnlyList<CellFace>(new List<CellFace>(cellFaces));
14 Connections = [];
15 }
16
17 public ElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : this(
18 subsystemElectricity,
19 new List<CellFace> { cellFace }
20 ) { }
21
22 public virtual float GetOutputVoltage(int face) => 0f;
23
24 public virtual bool Simulate() => false;
25
26 public virtual void OnAdded() { }
27
28 public virtual void OnRemoved() { }
29
30 public virtual void OnNeighborBlockChanged(CellFace cellFace, int neighborX, int neighborY, int neighborZ) { }
31
32 public virtual bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) => false;
33
34 public virtual void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody) { }
35
36 public virtual void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) { }
37
38 public virtual void OnConnectionsChanged() { }
39
40 public static bool IsSignalHigh(float voltage) => voltage >= 0.5f;
41
43 int num = 0;
44 foreach (ElectricConnection connection in Connections) {
45 if (connection.ConnectorType != ElectricConnectorType.Output
46 && connection.NeighborConnectorType != 0
48 num++;
49 }
50 }
51 return num;
52 }
53 }
54}
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
virtual void OnNeighborBlockChanged(CellFace cellFace, int neighborX, int neighborY, int neighborZ)
virtual void OnConnectionsChanged()
virtual void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
SubsystemElectricity SubsystemElectricity
ElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
static bool IsSignalHigh(float voltage)
virtual float GetOutputVoltage(int face)
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
virtual bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
List< ElectricConnection > Connections
virtual void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
ReadOnlyList< CellFace > CellFaces