Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Main()
- {
- // Set threshold for countdown timer. 5 is 5%, 10 is 10% and so on.
- var lowFuel = 5;
- // Set the number of seconds for the Warheads to detonate. (Default is 5 Seconds)
- float countdownTimer = 5;
- var blocks = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyOxygenTank>(blocks, t => t.CubeGrid == Me.CubeGrid);
- double fuel = 0; int tanks = 0;
- for (int i = blocks.Count; --i >= 0; )
- {
- var b = blocks[i];
- var tank = b as IMyOxygenTank;
- if (tank.BlockDefinition.SubtypeId.Contains("Hydrogen"))
- {
- fuel += tank.GetOxygenLevel();
- ++tanks;
- }
- }
- var maxTanks = 0;
- maxTanks = Math.Max(maxTanks, tanks);
- var fill = (float)(fuel / maxTanks);
- if (tanks == 0) fill = 0;
- var roundfill = (int)Math.Round(fill * 100.0);
- var log = "Hydrogen " + (roundfill.ToString()) + "%";
- Echo(log);
- var bombs = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyWarhead>(bombs, t => t.CubeGrid == Me.CubeGrid);
- for (int j = bombs.Count; --j >=0; )
- {
- var b = bombs[j];
- var warHeads = b as IMyWarhead;
- if (roundfill <= lowFuel)
- {
- Echo("Countdown Started");
- warHeads.ApplyAction("StartCountdown");
- }
- else
- {
- warHeads.ApplyAction("StopCountdown");
- warHeads.SetValue("DetonationTime", countdownTimer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment