Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
MulticoloredLedElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
6
7 public float m_voltage;
8
10
11 public MulticoloredLedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) =>
12 m_subsystemGlow = subsystemElectricity.Project.FindSubsystem<SubsystemGlow>(true);
13
14 public override void OnAdded() {
15 m_glowPoint = m_subsystemGlow.AddGlowPoint();
16 CellFace cellFace = CellFaces[0];
17 int mountingFace = MulticoloredLedBlock.GetMountingFace(
19 );
20 Vector3 v = new(cellFace.X + 0.5f, cellFace.Y + 0.5f, cellFace.Z + 0.5f);
21 m_glowPoint.Position = v - 0.4375f * CellFace.FaceToVector3(mountingFace);
22 m_glowPoint.Forward = CellFace.FaceToVector3(mountingFace);
23 m_glowPoint.Up = mountingFace < 4 ? Vector3.UnitY : Vector3.UnitX;
24 m_glowPoint.Right = Vector3.Cross(m_glowPoint.Forward, m_glowPoint.Up);
25 m_glowPoint.Color = Color.Transparent;
26 m_glowPoint.Size = 0.0324f;
27 m_glowPoint.FarSize = 0.0324f;
28 m_glowPoint.FarDistance = 0f;
29 m_glowPoint.Type = GlowPointType.Square;
30 }
31
32 public override void OnRemoved() {
33 m_subsystemGlow.RemoveGlowPoint(m_glowPoint);
34 }
35
36 public override bool Simulate() {
37 float voltage = m_voltage;
38 m_voltage = 0f;
39 foreach (ElectricConnection connection in Connections) {
40 if (connection.ConnectorType != ElectricConnectorType.Output
41 && connection.NeighborConnectorType != 0) {
43 }
44 }
45 if (m_voltage != voltage) {
46 int num = (int)MathF.Round(m_voltage * 15f);
47 m_glowPoint.Color = num >= 8 ? LedBlock.LedColors[Math.Clamp(num - 8, 0, 7)] : Color.Transparent;
48 }
49 return false;
50 }
51 }
52}
static int Max(int x1, int x2)
ElectricConnectorType ConnectorType
ElectricConnectorType NeighborConnectorType
virtual float GetOutputVoltage(int face)
List< ElectricConnection > Connections
ReadOnlyList< CellFace > CellFaces
static readonly Color[] LedColors
MountedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
MulticoloredLedElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) override void OnAdded()
virtual int GetCellValue(int x, int y, int z)
static int ExtractData(int value)
static Color Transparent
定义 Color.cs:5
static Vector3 Cross(Vector3 v1, Vector3 v2)
static readonly Vector3 UnitX
static Vector3 FaceToVector3(int face)