Advertisement
Alloydinius

Untitled

Feb 6th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. const int One = 1;
  2.  
  3. int seconds = 0;
  4.  
  5. void Main(string argument) {
  6.         if (seconds < 100)
  7.         {
  8.         //putShipIntoStorage();
  9.         takeShipFromStorage();
  10.         }
  11.        
  12. }
  13.  
  14. void takeShipFromStorage() {
  15.     seconds++;
  16.    
  17.     IMyPistonBase pistonY = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston_Y");
  18.     IMyMotorAdvancedStator rotorPad =  (IMyMotorAdvancedStator)GridTerminalSystem.GetBlockWithName("Rotor_Pad");
  19.     List<IMyTerminalBlock> pistonsX =  new List<IMyTerminalBlock>();
  20.     GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(pistonsX, ShouldIncludePistons);
  21.    
  22.     if (seconds == One)
  23.     {
  24.         ApplyActionToAllBlocks(pistonsX, "Reverse");
  25.     }
  26.     if (seconds == One + 10)
  27.     {
  28.         ApplyActionToBlock(rotorPad, "Reverse");
  29.     }
  30.     if (seconds == One + 20 + 10)
  31.     {
  32.         ApplyActionToBlock(pistony, "Reverse");
  33.     }
  34. }  
  35.  
  36. void putShipIntoStorage() {
  37.     seconds++;
  38.    
  39.     IMyPistonBase pistonY = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston_Y");
  40.     IMyMotorAdvancedStator rotorPad =  (IMyMotorAdvancedStator)GridTerminalSystem.GetBlockWithName("Rotor_Pad");
  41.     List<IMyTerminalBlock> pistonsX =  new List<IMyTerminalBlock>();
  42.     GridTerminalSystem.GetBlocksOfType<IMyPistonBase>(pistonsX, ShouldIncludePistons);
  43.    
  44.     if (seconds == One)
  45.     {
  46.         ApplyActionToBlock(pistonY, "Reverse");
  47.     }
  48.     if (seconds == One + 20)
  49.     {
  50.         ApplyActionToBlock(rotorPad, "Reverse");
  51.     }
  52.     if (seconds == One + 20 + 10)
  53.     {
  54.         ApplyActionToAllBlocks(pistonsX, "Reverse");
  55.     }
  56. }
  57.  
  58. void ApplyActionToBlock(IMyTerminalBlock block, string action)
  59. {
  60.         block.GetActionWithName(action).Apply(block);
  61. }
  62.  
  63. bool ShouldIncludePistons (IMyTerminalBlock block)    
  64. {    
  65.     return (block.CustomName).Contains("Piston_X");    
  66. }
  67.  
  68. void ApplyActionToAllBlocks(List<IMyTerminalBlock> blocks, string action)
  69. {
  70.     for (int i = 0; i < blocks.Count; i++)
  71.     {
  72.         blocks[i].GetActionWithName(action).Apply(blocks[i]);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement