Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Program() {Runtime.UpdateFrequency = UpdateFrequency.Update1;}
- IMyTerminalBlock _(string s){return GridTerminalSystem.GetBlockWithName(s);}
- public void Main() {
- //подключаем именованные блоки
- var m = (IMyTextPanel)_("airlock_mon") ?? Me.GetSurface(0);
- var d1 = (IMyDoor)_("airlock_door_in");
- var d2 = (IMyDoor)_("airlock_door_out");
- var s0 = (IMySensorBlock)_("airlock_sensor");
- var v0 = (IMyAirVent)_("airlock_vent");
- var v1 = (IMyAirVent)_("airlock_vent_in");
- var v2 = (IMyAirVent)_("airlock_vent_out");
- var t0 = (IMyGasTank)_("airlock_tank");
- //настраиваем параметры дисплея
- m.FontColor = Color.Gray;
- m.BackgroundColor = new Color(0,0,7);
- m.FontSize = 26.4f/(27);
- m.Font = "Monospace";
- m.Alignment =TextAlignment.LEFT;
- m.ContentType = ContentType.TEXT_AND_IMAGE;
- m.TextPadding = 0;
- //объявляем функции преобразователи
- Func<IMySensorBlock,char>c_s=s=>"∙☺"[s==null?0:s.Enabled?s.IsActive?3:2:1];
- Func<IMyDoor,char>c_d=d=>"∙ ₪"[d==null?0:d.Enabled?2+(int)d.Status:1];
- Func<IMyAirVent,char>c_v=v=>"∙"[v==null?0:v.Enabled?v.CanPressurize?v.Depressurize?4:3:2:1];
- Func<IMyAirVent,string>s_v=v=>new string('●',(int)((v?.GetOxygenLevel()??0)*10)).PadRight(10,'∙');
- Func<IMyGasTank,string>s_t=t=>$"{(t?.FilledRatio??0)*100:000}{"∙%"[t==null?0:t.Enabled?t.Stockpile?3:2:1]}";
- //выводим информацию
- m.WriteText($"{System.DateTime.Now:T} ┌{c_v(v1)} {s_v(v1)} ├{c_d(d1)}┤\n",false);
- m.WriteText($" ▄▀▀▀▀▄ ├{c_v(v0)} {s_v(v0)} ≡{c_s(s0)}│\n",true);
- m.WriteText($" ▌{s_t(t0)}▐──┴{c_v(v2)} {s_v(v2)} ├{c_d(d2)}┤\n",true);
- //сюда, при желании, добавляем логику работы шлюза используя подключенные блоки
- m.WriteText($"\n{ t0.DetailedInfo }" ,true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement