Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string
- timerDangerName = "alert",
- timerSafeName = "safe";
- public bool active = false;
- public Program()
- {
- Runtime.UpdateFrequency = UpdateFrequency.Update100;
- }
- public void Save() { }
- public void Main(string argument, UpdateType updateSource)
- {
- List<IMyTerminalBlock> blockList = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyLargeTurretBase>(blockList, b => ((IMyLargeTurretBase)b).HasTarget);
- bool tempActive = blockList.Count > 0;
- if (tempActive != active)
- {
- active = tempActive;
- if (active) TriggerTimers(timerDangerName);
- else TriggerTimers(timerSafeName);
- }
- }
- public void TriggerTimers(string timerKeyword)
- {
- List<IMyTerminalBlock> blockList = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyTimerBlock>(blockList, b => b.CustomName.ToLower().Contains(timerKeyword.ToLower()));
- for (int i = 0; i < blockList.Count; i++)
- ((IMyTimerBlock)blockList[i]).Trigger();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement