Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SwitchElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public float m_voltage;
6
7 public SwitchElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace, int value) : base(subsystemElectricity, cellFace) {
8 int voltageLevel = SwitchBlock.GetVoltageLevel(Terrain.ExtractData(value));
9 m_voltage = SwitchBlock.GetLeverState(value) ? voltageLevel / 15f : 0f;
10 }
11
12 public override float GetOutputVoltage(int face) => m_voltage;
13
14 public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner) {
15 CellFace cellFace = CellFaces[0];
16 int cellValue = SubsystemElectricity.SubsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z);
17 int value = SwitchBlock.SetLeverState(cellValue, !SwitchBlock.GetLeverState(cellValue));
18 SubsystemElectricity.SubsystemTerrain.ChangeCell(cellFace.X, cellFace.Y, cellFace.Z, value);
19 SubsystemElectricity.SubsystemAudio.PlaySound("Audio/Click", 1f, 0f, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 2f, true);
20 return true;
21 }
22 }
23}
Engine.Vector3 Vector3
ReadOnlyList< CellFace > CellFaces
MountedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
void PlaySound(string name, float volume, float pitch, float pan, float delay)
virtual void ChangeCell(int x, int y, int z, int value, bool updateModificationCounter=true, MovingBlock movingBlock=null)
static int SetLeverState(int value, bool state)
static int GetVoltageLevel(int data)
static bool GetLeverState(int value)
override float GetOutputVoltage(int face)
override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
SwitchElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace, int value)
virtual int GetCellValue(int x, int y, int z)
static int ExtractData(int value)