Advertisement
klassekatze

Untitled

Jan 1st, 2025
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. List<IMyJumpDrive> jumpDrives = new List<IMyJumpDrive>();
  2. public Program()
  3. {
  4.     Runtime.UpdateFrequency = UpdateFrequency.Update100;
  5.     jumpDrives.Clear();
  6.     GridTerminalSystem.GetBlocksOfType<IMyJumpDrive>(jumpDrives, b => b.CubeGrid == Me.CubeGrid);
  7. }
  8.  
  9. public void Save()
  10. {
  11. }
  12.  
  13. int freq = 3;
  14. int c = 0;
  15.  
  16. bool sequentialJumpDriveCharging = false;
  17.  
  18. public void Main(string argument, UpdateType updateSource)
  19. {
  20.     c++;
  21.     if(c % freq == 0)
  22.     {
  23.         IMyJumpDrive lastCharged = null;
  24.         IMyJumpDrive lastCharging = null;
  25.  
  26.         foreach (IMyJumpDrive jj in jumpDrives)
  27.         {
  28.             if (jj.CurrentStoredPower < jj.MaxStoredPower) lastCharging = jj;
  29.             else lastCharged = jj;
  30.         }
  31.         if(lastCharging != null)
  32.         {
  33.             foreach (IMyJumpDrive jj in jumpDrives)
  34.             {
  35.                 if (jj != lastCharging) jj.Enabled = false;
  36.             }
  37.             lastCharging.Enabled = true;
  38.         }else if(lastCharged != null)
  39.         {
  40.             foreach (IMyJumpDrive jj in jumpDrives)
  41.             {
  42.                 if (jj != lastCharged) jj.Enabled = false;
  43.             }
  44.             lastCharged.Enabled = true;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement