Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SignElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public bool m_isMessageAllowed = true;
6
7 public double? m_lastMessageTime;
8
9 public SignElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace) : base(subsystemElectricity, cellFace) { }
10
11 public override bool Simulate() {
12 bool flag = CalculateHighInputsCount() > 0;
13 if (flag
15 && (!m_lastMessageTime.HasValue || SubsystemElectricity.SubsystemTime.GameTime - m_lastMessageTime.Value > 0.5)) {
16 m_isMessageAllowed = false;
17 m_lastMessageTime = SubsystemElectricity.SubsystemTime.GameTime;
18 SignData signData = SubsystemElectricity.Project.FindSubsystem<SubsystemSignBlockBehavior>(true)
19 .GetSignData(new Point3(CellFaces[0].X, CellFaces[0].Y, CellFaces[0].Z));
20 if (signData != null) {
21 string text = string.Join("\n", signData.Lines);
22 text = text.Trim('\n');
23 text = text.Replace("\\\n", "");
24 Color color = signData.Colors[0] == Color.Black ? Color.White : signData.Colors[0];
25 color *= 255f / MathUtils.Max(color.R, color.G, color.B);
26 foreach (ComponentPlayer componentPlayer in SubsystemElectricity.Project.FindSubsystem<SubsystemPlayers>(true).ComponentPlayers) {
27 componentPlayer.ComponentGui.DisplaySmallMessage(text, color, true, true);
28 }
29 }
30 }
31 if (!flag) {
32 m_isMessageAllowed = true;
33 }
34 return false;
35 }
36 }
37}
static int Max(int x1, int x2)
virtual void DisplaySmallMessage(string text, Color color, bool blinking, bool playNotificationSound)
SubsystemElectricity SubsystemElectricity
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
ReadOnlyList< CellFace > CellFaces
SignElectricElement(SubsystemElectricity subsystemElectricity, CellFace cellFace)
ReadOnlyList< ComponentPlayer > ComponentPlayers