Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PressurePlateElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public float m_voltage;
6
8
9 public float m_pressure;
10
11 public PressurePlateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
12
13 public void Press(float pressure) {
15 if (pressure > m_pressure) {
16 m_pressure = pressure;
17 CellFace cellFace = CellFaces[0];
19 "Audio/BlockPlaced",
20 1f,
21 0.3f,
22 new Vector3(cellFace.X, cellFace.Y, cellFace.Z),
23 2.5f,
24 true
25 );
27 }
28 }
29
30 public override float GetOutputVoltage(int face) => m_voltage;
31
32 public override bool Simulate() {
33 float voltage = m_voltage;
34 if (m_pressure > 0f
38 }
39 else {
41 CellFace cellFace = CellFaces[0];
43 "Audio/BlockPlaced",
44 0.6f,
45 -0.1f,
46 new Vector3(cellFace.X, cellFace.Y, cellFace.Z),
47 2.5f,
48 true
49 );
50 }
51 m_voltage = 0f;
52 m_pressure = 0f;
53 }
54 return m_voltage != voltage;
55 }
56
57 public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody) {
58 Press(componentBody.Mass);
59 componentBody.ApplyImpulse(new Vector3(0f, -2E-05f, 0f));
60 }
61
62 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) {
63 int num = Terrain.ExtractContents(worldItem.Value);
64 Block block = BlocksManager.Blocks[num];
65 Press(1f * block.GetDensity(worldItem.Value));
66 }
67
68 public static float PressureToVoltage(float pressure) {
69 if (pressure <= 0f) {
70 return 0f;
71 }
72 if (pressure < 1f) {
73 return 8f / 15f;
74 }
75 if (pressure < 2f) {
76 return 0.6f;
77 }
78 if (pressure < 5f) {
79 return 2f / 3f;
80 }
81 if (pressure < 25f) {
82 return 11f / 15f;
83 }
84 if (pressure < 100f) {
85 return 0.8f;
86 }
87 if (pressure < 250f) {
88 return 13f / 15f;
89 }
90 if (pressure < 500f) {
91 return 14f / 15f;
92 }
93 return 1f;
94 }
95 }
96}
Engine.Vector3 Vector3
static int FrameIndex
定义 Time.cs:26
virtual float GetDensity(int value)
virtual void ApplyImpulse(Vector3 impulse)
static bool IsSignalHigh(float voltage)
ReadOnlyList< CellFace > CellFaces
MountedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
PressurePlateElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
void PlaySound(string name, float volume, float pitch, float pan, float delay)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)
static int ExtractContents(int value)