Пример #1
0
        bool FuncTest(IMySmallMissileLauncherReload block)
        {
            //Reloadable Rocket Launcher
            //Interface name: IMySmallMissileLauncherReload
            //Parent: IMyFunctionalBlock
            //Fields:
            bool UseConveyorSystem = block.UseConveyorSystem;

            return(true);
        }
Пример #2
0
 void Initialize()        // Handles the initialization of blocks. Is run at the end of each loop to ensure everything is there.
 {
     inventories.Clear(); // This must be done to avoid memory leaks.
     refineries.Clear();
     furnaces.Clear();
     assemblers.Clear();
     reactors.Clear();
     gasGenerators.Clear();
     gatlings.Clear();
     missileLaunchers.Clear();
     lcds.Clear();
     if (!Me.CustomName.ToLower().Contains(TAG.ToLower())) // If we have no tag at all.
     {
         Me.CustomName += " " + TAG;                       // Add a tag.
     }//
     else if (!Me.CustomName.Contains(TAG))                // We know we have a tag, but run this when the tag isn't exactly equal.
     {
         string customName = Me.CustomName;                // Replacing the incorrect tag with the proper version.
         int    index      = customName.ToLower().IndexOf(TAG.ToLower());
         customName    = customName.Remove(index, TAG.Length);
         customName    = customName.Insert(index, TAG);
         Me.CustomName = customName;
     }//
     GridTerminalSystem.SearchBlocksOfName(TAG, blocks);
     foreach (IMyTerminalBlock block in blocks)
     {
         if (!block.CustomName.Contains(TAG))// If the tag doesn't match up exactly, correct the tag.
         {
             string customName = block.CustomName;
             int    index      = customName.ToLower().IndexOf(TAG.ToLower());
             customName       = customName.Remove(index, TAG.Length);
             customName       = customName.Insert(index, TAG);
             block.CustomName = customName;
         }//
         IMyRefinery refinery = block as IMyRefinery;// This will return null if the block isn't a refinery block.
         if (refinery != null)
         {
             if (refinery.BlockDefinition.SubtypeId.Equals(FURNACE_TYPE_ID))// Both Refinieries and Arc Furnaces are refineries. Seperate them by subtype.
             {
                 furnaces.Add(refinery);
             }
             else
             {
                 refineries.Add(refinery);
             }
             continue;
         }//
         IMyAssembler assembler = block as IMyAssembler;
         if (assembler != null)
         {
             assemblers.Add(assembler);
             continue;
         }//
         IMyReactor reactor = block as IMyReactor;
         if (reactor != null)
         {
             reactors.Add(reactor);
             continue;
         }//
         IMyGasGenerator gasGenerator = block as IMyGasGenerator;
         if (gasGenerator != null)
         {
             gasGenerators.Add(gasGenerator);
             continue;
         }//
         IMyLargeGatlingTurret gatlingTurret = block as IMyLargeGatlingTurret;
         IMySmallGatlingGun    gatlingGun    = block as IMySmallGatlingGun;
         if ((gatlingTurret != null) | (gatlingGun != null))
         {
             gatlings.Add(block);
             continue;
         }//
         IMyLargeMissileTurret         missileTurret       = block as IMyLargeMissileTurret;
         IMySmallMissileLauncherReload smallLauncherReload = block as IMySmallMissileLauncherReload;
         if ((missileTurret != null) | (smallLauncherReload != null))
         {
             missileLaunchers.Add(block);
             continue;
         }//
         IMySmallMissileLauncher missileLauncher = block as IMySmallMissileLauncher;
         if ((missileLauncher != null) & (block.BlockDefinition.SubtypeId.Equals("LargeMissileLauncher")))
         {
             missileLaunchers.Add(block);
             continue;
         }//
         IMyProgrammableBlock programmableBlock = block as IMyProgrammableBlock;
         if (programmableBlock != null)
         {
             if (!programmableBlock.Equals(Me) & programmableBlock.IsWorking)                     // If the programmable block isn't the one running this instance and it is working.
             {
                 if (programmableBlock.CustomName.ToLower().Contains(CONNECTED_PB_TAG.ToLower())) // Check if it has the connected PB tag.
                 {
                     if (!programmableBlock.CustomName.Contains(CONNECTED_PB_TAG))
                     {
                         string customName = programmableBlock.CustomName;
                         int    index      = customName.ToLower().IndexOf(CONNECTED_PB_TAG.ToLower());
                         customName = customName.Remove(index, CONNECTED_PB_TAG.Length);
                         customName = customName.Insert(index, CONNECTED_PB_TAG);
                         programmableBlock.CustomName = customName;
                     }//
                     connectedPBs.Add(programmableBlock);
                     continue;
                 }    //
                 else // Assume this PB is running the same script.
                 {
                     if (programmableBlock.CubeGrid.EntityId == Me.CubeGrid.EntityId)
                     {
                         Echo("ERROR: MORE THAN ONE IAN ON ONE GRID");
                         active = false;// Both PBs will disable themselves and show an error.
                         continue;
                     }//
                     else if (programmableBlock.CubeGrid.GridSize > Me.CubeGrid.GridSize)// The PB with the biggest grid size will be dominant.
                     {
                         active = false;
                         continue;
                     }
                     active = true;// None of the exceptions have occured, so we are free to resume functioning. This will ensure IAN plays nice with it's double.
                     continue;
                 }//
             } //
         }     //
         IMyTextPanel panel = block as IMyTextPanel;
         if (panel != null)
         {
             lcds.Add(panel);
         }
     } //
 }     //