Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
TargetElectricElement.cs
浏览该文件的文档.
1namespace Game {
3 public float m_voltage;
4
5 public int m_score;
6
7 public TargetElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
8
9 public override float GetOutputVoltage(int face) => m_voltage;
10
11 public override bool Simulate() {
12 float voltage = m_voltage;
13 if (m_score > 0) {
14 m_voltage = (m_score + 7) / 15f;
15 m_score = 0;
17 }
18 else {
19 m_voltage = 0f;
20 }
21 return m_voltage != voltage;
22 }
23
24 public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) {
25 if (m_score == 0
27 if (cellFace.Face == 0
28 || cellFace.Face == 2) {
29 float num = worldItem.Position.X - cellFace.X - 0.5f;
30 float num2 = worldItem.Position.Y - cellFace.Y - 0.5f;
31 float num3 = MathF.Sqrt(num * num + num2 * num2);
32 m_score = Math.Clamp((int)MathF.Round(8f * (1f - num3 / 0.707f)), 1, 8);
33 }
34 else {
35 float num4 = worldItem.Position.Z - cellFace.Z - 0.5f;
36 float num5 = worldItem.Position.Y - cellFace.Y - 0.5f;
37 float num6 = MathF.Sqrt(num4 * num4 + num5 * num5);
38 m_score = Math.Clamp((int)MathF.Round(8f * (1f - num6 / 0.5f)), 1, 8);
39 }
41 }
42 }
43 }
44}
static bool IsSignalHigh(float voltage)
MountedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)
TargetElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem)
override float GetOutputVoltage(int face)