Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ButtonFurnitureElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public float m_voltage;
6
7 public bool m_wasPressed;
8
9 public ButtonFurnitureElectricElement(SubsystemElectricity subsystemElectricity, Point3 point) : base(subsystemElectricity, point) { }
10
11 public void Press() {
12 if (!m_wasPressed
14 m_wasPressed = true;
15 CellFace cellFace = CellFaces[0];
16 SubsystemElectricity.SubsystemAudio.PlaySound("Audio/Click", 1f, 0f, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 2f, true);
18 }
19 }
20
21 public override float GetOutputVoltage(int face) => m_voltage;
22
23 public override bool Simulate() {
24 float voltage = m_voltage;
25 if (m_wasPressed) {
26 m_wasPressed = false;
27 m_voltage = 1f;
29 }
30 else {
31 m_voltage = 0f;
32 }
33 return m_voltage != voltage;
34 }
35
36 public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) {
37 Press();
38 return true;
39 }
40
41 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) {
42 Press();
43 }
44 }
45}
Engine.Vector3 Vector3
override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
ButtonFurnitureElectricElement(SubsystemElectricity subsystemElectricity, Point3 point)
static bool IsSignalHigh(float voltage)
ReadOnlyList< CellFace > CellFaces
FurnitureElectricElement(SubsystemElectricity subsystemElectricity, Point3 point)
void PlaySound(string name, float volume, float pitch, float pan, float delay)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)