Beispiel #1
0
 bool FuncTest(IMyShipMergeBlock block)
 {
     //Merge Block
     //Interface name: IMyShipMergeBlock
     //Parent: IMyFunctionalBlock
     return(true);
 }
        public Program()
        {
            Load();

            // Grinder Arm Blocks
            _grindArmRotor            = GetBlockOrThrow <IMyMotorStator>("Grinder Rotor");
            _grindArmHinge            = GetBlockOrThrow <IMyMotorStator>("Grinder Hinge");
            _grindArmPistonVert       = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Vert");
            _grindArmPistonHoriz      = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Horiz");
            _grindArmPistonPark       = GetBlockOrThrow <IMyPistonBase>("Grinder Park Piston");
            _grindArmLandingGearGroup = GetGroupOrThrow("Grinder Landing Gear");

            // Drill Blocks
            _drillPistonGroup       = GetGroupOrThrow("Drill Pistons");
            _drillGroup             = GetGroupOrThrow("Drills");
            _drillWelderGroup       = GetGroupOrThrow("Welders");
            _drillMergeBlock        = GetBlockOrThrow <IMyShipMergeBlock>("Drill Merge Block");
            _drillConnector         = GetBlockOrThrow <IMyShipConnector>("Drill Connector");
            _drillSupportMergeBlock = GetBlockOrThrow <IMyShipMergeBlock>("Support Merge Block");
            _drillProjector         = GetBlockOrThrow <IMyProjector>("Drill Projector");

            // LCD setup
            _lcd = GetBlockOrThrow <IMyTextPanel>("Drill Rig LCD");
            if (_lcd != null)
            {
                Echo("Found LCD");
                _lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                _lcd.FontSize    = 0.5f;
                _lcd.FontColor   = new Color(200, 200, 200); // less bright white is also less blurry
                _lcd.Alignment   = TextAlignment.LEFT;
                _lcd.WriteText("Drill Rig Debug Logs");      // Clear all text
            }
        }
        bool CollectAllPartsLandpedo(IMyTerminalBlock block)
        {
            if (block == Me)
            {
                return(false);
            }
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }
            if (block is IMyProgrammableBlock)
            {
                return(false);
            }
            if (block is IMyShipMergeBlock)
            {
                Base = (IMyShipMergeBlock)block;
            }
            if (block is IMyProjector)
            {
                Projector = (IMyProjector)block;
            }
            if (block is IMyShipConnector)
            {
                Connector = (IMyShipConnector)block;
            }

            PartsOfInterest.Add(block);

            return(false);
        }
Beispiel #4
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            this.objectBuilder = objectBuilder;

            this.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
            mergeblock        = Entity as IMyShipMergeBlock;
        }
Beispiel #5
0
        public void Init(IMyGridTerminalSystem gridTerminalSystem)
        {
            List <IMyTerminalBlock> blockList = new List <IMyTerminalBlock> ();

            gridTerminalSystem.GetBlocksOfType <IMyTerminalBlock> (blockList, searchItem => searchItem.CustomName.Contains(m_missileTag));

            foreach (IMyTerminalBlock block in blockList)
            {
                if ((block is IMyGyro) && (m_gyroBlock == null))
                {
                    m_gyroBlock = ( IMyGyro )block;
                }
                //else if (( block is IMyLargeTurretBase ) && ( m_remoteTurretBlock == null ))
                //{
                //   m_remoteTurretBlock = ( IMyLargeTurretBase ) block;
                //}
                else if ((block is IMyShipMergeBlock) && (m_mergeBlock == null))
                {
                    m_mergeBlock = ( IMyShipMergeBlock )block;
                }
                else if (block is IMyPowerProducer)
                {
                    m_powerBlock.Add(( IMyPowerProducer )block);
                }
                else if (block is IMyThrust)
                {
                    m_thrusterBlockList.Add(( IMyThrust )block);
                }
                else if (block is IMyWarhead)
                {
                    m_warheadBlockList.Add(( IMyWarhead )block);
                }
            }
        }
Beispiel #6
0
        public static bool CheckHummingbirdComponents(IMyShipMergeBlock baseplate, ref IMyShipConnector connector, ref IMyMotorStator turretRotor, ref List <IMyTerminalBlock> PartsScratchpad, ref string status)
        {
            var releaseOther = GridTerminalHelper.OtherMergeBlock(baseplate);

            if (releaseOther == null || !releaseOther.IsFunctional || !releaseOther.Enabled)
            {
                return(false);
            }

            PartsScratchpad.Clear();

            var gotParts = GridTerminalHelper.Base64BytePosToBlockList(releaseOther.CustomData, releaseOther, ref PartsScratchpad);

            if (!gotParts)
            {
                return(false);
            }

            foreach (var block in PartsScratchpad)
            {
                if (!block.IsFunctional)
                {
                    return(false);
                }
                if (block is IMyMotorStator)
                {
                    turretRotor = (IMyMotorStator)block;
                }
                if (block is IMyShipConnector)
                {
                    connector = (IMyShipConnector)block;
                }
            }
            return(true);
        }
Beispiel #7
0
            bool TryLockInMerge(double distance)
            {
                IMyShipMergeBlock clamp = Reference as IMyShipMergeBlock;

                clamp.Enabled = true;
                return(clamp.IsConnected);
            }
Beispiel #8
0
            /// <summary>
            /// Calculates position and approach vector to dock on specific merge block.
            /// </summary>
            /// <param name="merger">Merge block to use.</param>
            /// <param name="pos">Merge block's position.</param>
            /// <param name="approach">Approach direction.</param>
            public static void CalculateApproach(IMyShipMergeBlock merger, out Vector3D pos, out Vector3D approach)
            {
                MatrixD wm = merger.WorldMatrix;

                pos      = wm.Translation;
                approach = -wm.GetDirectionVector(Base6Directions.Direction.Right);
            }
Beispiel #9
0
            bool IsMergeBlockConnected(IMyShipMergeBlock SourceMB, IMyGridTerminalSystem gts)
            // due to a bug making IMyShipMergeBlock.isConnected show info only about yellow state (not green)
            // copied from user Martin R Wolfe @ https://forum.keenswh.com/threads/1-176-002-dev-imyshipmergeblock-isconnected.7393234/ and changed a bit
            {
                bool        Result   = SourceMB.Enabled;
                IMyCubeGrid CubeGrid = SourceMB.CubeGrid;
                Quaternion  aQuaternion;
                Vector3I    TargetMbLoc;
                List <IMyShipMergeBlock> TargetMBs = new List <IMyShipMergeBlock>();

                //Find target location
                SourceMB.Orientation.GetQuaternion(out aQuaternion);
                TargetMbLoc = SourceMB.Position + Vector3I.Transform(new Vector3I(1, 0, 0), aQuaternion);
                //Find TargetMB will only be found if powered and on same grid as source
                gts.GetBlocksOfType <IMyShipMergeBlock>(TargetMBs,
                                                        x => ((x.CubeGrid == CubeGrid) && (x.Enabled == true) && (x.Position == TargetMbLoc)));
                if (TargetMBs.Count != 0)
                {//We have a powered MB at source merge location
                 //Find target's merge location
                    TargetMBs[0].Orientation.GetQuaternion(out aQuaternion);
                    TargetMbLoc = TargetMBs[0].Position + Vector3I.Transform(new Vector3I(1, 0, 0), aQuaternion);
                    //Check that targets merge location is source's location
                    Result &= (TargetMbLoc == SourceMB.Position);
                }
                else
                {
                    Result = false;   //no target found
                }
                return(Result);
            }
        bool IsMerged(IMyShipMergeBlock mrg1)
        {
            //Find direction that block merges to
            Matrix mat;

            mrg1.Orientation.GetMatrix(out mat);
            Vector3I right1 = new Vector3I(mat.Right);

            //Check if there is a block in front of merge face
            IMySlimBlock sb = mrg1.CubeGrid.GetCubeBlock(mrg1.Position + right1);

            if (sb == null)
            {
                return(false);
            }

            //Check if the other block is actually a merge block
            IMyShipMergeBlock mrg2 = sb.FatBlock as IMyShipMergeBlock;

            if (mrg2 == null)
            {
                return(false);
            }

            //Check that other block is correctly oriented
            mrg2.Orientation.GetMatrix(out mat);
            Vector3I right2 = new Vector3I(mat.Right);

            var result = right2 == -right1;

            _log.AppendLine("Block is " + (result ? "" : "NOT ") + "merged.");

            return(result);
        }
Beispiel #11
0
            private IMyGridTerminalSystem gts; //needed only because keen messed up in IMyShipMergeBlock.IsConnected()

            public PistonAndMergeBlockExtendAndMerge(IMyPistonBase piston, IMyShipMergeBlock mergeBlock, IMyGridTerminalSystem gts)
            {
                this.piston     = piston;
                this.mergeBlock = mergeBlock;
                this.gts        = gts;

                this.StartMovement();
            }
Beispiel #12
0
 public Thruster(Program program)
 {
     Program     = program;
     MergeBlock1 = Program.GridTerminalSystem.GetBlockWithName("0 Merge Block") as IMyShipMergeBlock;
     MergeBlock2 = Program.GridTerminalSystem.GetBlockWithName("0 Merge Block 2") as IMyShipMergeBlock;
     Connector1  = Program.GridTerminalSystem.GetBlockWithName("0 Connector") as IMyShipConnector;
     Connector2  = Program.GridTerminalSystem.GetBlockWithName("0 Connector 2") as IMyShipConnector;
     Piston      = Program.GridTerminalSystem.GetBlockWithName("0 Piston") as IMyPistonBase;
     Motor       = Program.GridTerminalSystem.GetBlockWithName("0 Rotor") as IMyMotorStator;
 }
        /// отключаем соединитель
        private void mergeUnlock()
        {
            IMyShipMergeBlock merge = GridTerminalSystem.GetBlockWithName(NAME_MERGE_BLOCK) as IMyShipMergeBlock;

            if (!merge.Enabled)
            {
                merge.Enabled = true;
            }
            merge.Enabled = false;
        }
Beispiel #14
0
        bool CollectParts(IMyTerminalBlock block)
        {
            if (!block.IsSameConstructAs(Me))
            {
                return(false);
            }
            //if (!block.CustomName.Contains(Me.CustomName.Last())) return false;
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Small Hinge"))
            {
                SmallHinge = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Large Hinge"))
            {
                LargeHinge = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorAdvancedStator && block.CustomName.Contains("Elevation"))
            {
                Elevation = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyMotorStator && block.CustomName.Contains("Sweeper"))
            {
                Sweeper = (IMyMotorStator)block;
            }

            if (block is IMyProjector && block.CustomName.Contains("Base Projector"))
            {
                BaseProjector = (IMyProjector)block;
            }
            if (block is IMyProjector && block.CustomName.Contains("Top Projector"))
            {
                TopProjector = (IMyProjector)block;
            }

            if (block is IMyShipMergeBlock && block.CustomName.Contains("Top Release"))
            {
                TopMerge = (IMyShipMergeBlock)block;
            }
            if (block is IMyShipMergeBlock && block.CustomName.Contains("Base Release"))
            {
                BaseMerge = (IMyShipMergeBlock)block;
            }

            if (block is IMyShipWelder)
            {
                Welders.Add((IMyShipWelder)block);
            }
            if (block is IMyTextPanel)
            {
                Display = (IMyTextPanel)block;
            }

            return(false);
        }
Beispiel #15
0
        private bool TryGetClosestMergeblock(IMyShipMergeBlock mergeblock, ref EntityCache search, out IMyFunctionalBlock closest)
        {
            int x = 0;
            int y = 0;
            int z = 0;

            for (x = -1; x < 2; x++)
            {
                for (y = -1; y < 2; y++)
                {
                    for (z = -1; z < 2; z++)
                    {
                        if (x == 0 && y == 0 && z == 0)
                        {
                            continue;
                        }
                        EntityCache Cache;
                        BlockCache.TryGetValue(lastpos + new Vector3I(x, y, z), out Cache);
                        if (Cache != null)
                        {
                            search.Copy(Cache);
                        }
                    }
                }
            }
            double dist = double.MaxValue;

            closest = null;
            foreach (var block in search)
            {
                if (block == null || block.MarkedForClose || block.Closed)
                {
                    continue;
                }

                if (block.CubeGrid == mergeblock.CubeGrid)
                {
                    continue;
                }
                if (Vector3D.Distance(block.WorldMatrix.Translation, mergeblock.WorldMatrix.Translation) < dist)
                {
                    dist    = Vector3D.Distance(block.WorldMatrix.Translation, mergeblock.WorldMatrix.Translation);
                    closest = block;
                }
            }
            if (closest != null)
            {
                return(true);
            }
            return(false);
        }
        bool CollectAllParts(IMyTerminalBlock block)
        {
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }
            if (block is IMyProgrammableBlock)
            {
                return(false);
            }
            PartsOfInterest.Add(block);
            if (block is IMyShipMergeBlock && block.CustomName.Contains("<BASE>"))
            {
                Base = (IMyShipMergeBlock)block;
            }

            return(false);
        }
Beispiel #17
0
        double GetPos(IMyShipMergeBlock _Merge) //get x, y, or z position, based on named merge blocks. Thank you, JoeTheDestroyer, for posting this in 2016.
        {
            if (_Merge.IsConnected)
            {
                //Find direction that block merges to
                Matrix mat;
                _Merge.Orientation.GetMatrix(out mat);
                Vector3I right1 = new Vector3I(mat.Right);

                //Check if there is a block in front of merge face
                IMySlimBlock _Sb = _Merge.CubeGrid.GetCubeBlock(_Merge.Position + right1);
                if (_Sb == null)
                {
                    output.Append("No Blocks in front of Merge Block\n");
                }

                //Check if the other block is actually a merge block
                IMyShipMergeBlock _Mb = _Sb.FatBlock as IMyShipMergeBlock;
                if (_Mb == null)
                {
                    output.Append("Not A Merge Block\n");
                }

                //Check that other block is correctly oriented
                if (_Mb != null)
                {
                    _Mb.Orientation.GetMatrix(out mat);
                    Vector3I right2 = new Vector3I(mat.Right);
                    int      pos    = Convert.ToInt32(_Mb.CustomName.Split(new char[] { 'X', 'Y', 'Z' }).Last()); // remove the letter
                    pos = pos - 1;
                    return(pos);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-1);
            }
        }
        public Program()
        {
            mergeBlock = GridTerminalSystem.GetBlockWithName(NAME_MERGE_BLOCK) as IMyShipMergeBlock;

            if (mergeBlock != null)
            {
                Echo("init OK");
                Echo("CustomName: " + mergeBlock.CustomName);
                Echo("IsConnected: " + mergeBlock.IsConnected);
                mergeBlock.GetActions(resultList);
                foreach (var item in resultList)
                {
                    Echo("  action: " + item.Name.ToString());
                }
            }
            else
            {
                Echo("init ERROR");
            }
        }
Beispiel #19
0
        void Init()
        {
            rdsaRotors = new List <IMyMotorStator>();
            GridTerminalSystem.GetBlocksOfType(rdsaRotors, block => { return(block.CustomName.IndexOf(rotorTag, StringComparison.OrdinalIgnoreCase) >= 0); });

            if (rdsaRotors.Count > 0)
            {
                List <IMyShipMergeBlock> mergeBlocks = new List <IMyShipMergeBlock>();
                GridTerminalSystem.GetBlocksOfType(mergeBlocks, block => { return(block.CustomName.IndexOf(mergeBlockTag, StringComparison.OrdinalIgnoreCase) >= 0); });
                if (mergeBlocks.Count > 0)
                {
                    mergeBlock = mergeBlocks[0];

                    foreach (IMyMotorStator rotor in rdsaRotors)
                    {
                        rotor.SetValueBool("ShareInertiaTensor", true);
                    }

                    state = 0;
                    init  = true;
                }
            }

            if (init)
            {
                Echo("----- System Online -----");

                Echo("\n--[ RDSA Rotors ]--");
                foreach (IMyMotorStator rotor in rdsaRotors)
                {
                    Echo(rotor.CustomName);
                }

                Echo("\n--[ Projectile Holder Merge Block ]--");
                Echo(mergeBlock.CustomName);
            }
            else
            {
                Echo("No RDSA Rotors Or Projectile Holder\nMerge Block Found");
            }
        }
        public void Init()
        {
            #region fetchblocks
            GridTerminalSystemUtils GTS = new GridTerminalSystemUtils(Me, GridTerminalSystem);
            control    = GTS.GetBlockWithNameOnGrid(controllerName) as IMyShipController;
            mergeBlock = GTS.GetBlockWithNameOnGrid(mergeBlockName) as IMyShipMergeBlock;

            var antennas = new List <IMyRadioAntenna>();
            GTS.GetBlocksOfTypeOnGrid(antennas);
            #endregion

            #region initModules
            if (antennas.Count > 0)
            {
                commsHandler = new CommsHandler(this, antennas.First());
            }
            else
            {
                commsHandler = new CommsHandler(this, null);
            }

            var commands = new Commands(this, commsHandler);
            commands.RegisterCommands();

            EntityTracking_Module.refExpSettings refExp = EntityTracking_Module.refExpSettings.Sensor | EntityTracking_Module.refExpSettings.Turret;
            targetTracker = new EntityTracking_Module(GTS, control, null, refExp);
            targetTracker.onEntityDetected += OnTargetFound;

            controlModule = new ControlModule(GTS, control);
            proNav        = new ProNav(controlModule, 30);

            missionScheduler = new Scheduler();

            payload = new Payload(GTS, backupDetonationEngageDist);
            #endregion

            mode = CurrentMode.Idle;

            initialized             = true;
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
 public LauncherSegment(IMyShipMergeBlock merger = null, List <IMyGravityGenerator> accelerators = null, List <IMyShipWelder> constructors = null)
 {
     this.merger       = merger;
     this.accelEnabled = true;
     this.busy         = false;
     if (accelerators != null)
     {
         this.accelerators = accelerators;
     }
     else
     {
         this.accelerators = new List <IMyGravityGenerator>();
     }
     if (constructors != null)
     {
         this.constructors = constructors;
     }
     else
     {
         this.constructors = new List <IMyShipWelder>();
     }
 }
        bool CollectParts(IMyTerminalBlock block)
        {
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }

            if (DummyTube.AddTorpedoPart(block))
            {
                PartsOfInterest.Add(block);
            }
            if (block is IMyRadioAntenna)
            {
                PartsOfInterest.Add(block);
            }
            if (block is IMyShipMergeBlock && block.CustomName.Contains("<BASE>"))
            {
                Base = (IMyShipMergeBlock)block;
            }

            return(false);
        }
Beispiel #23
0
        public static IMyShipMergeBlock OtherMergeBlock(IMyShipMergeBlock merge)
        {
            if (merge == null)
            {
                return(null);
            }

            // This is a massive hack. Keen f****d up when they made the Small Grid 1x1x1 merge and it is oriented so the connection
            // is Base6Directions.Direction.Up, not Base6Directions.Direction.Right like the previous merges. This uses the length
            // of the subtype name (24 characters) of the 1x1x1 small grid merge to do the exception, where as the older two are 19
            // characters. If you ever have a mod merge block that is 24 characters, you'll need to do something else here.
            Vector3I otherPosition = merge.Position + Base6Directions.GetIntVector(merge.Orientation.TransformDirection(
                                                                                       merge.BlockDefinition.SubtypeName.Length == 24? Base6Directions.Direction.Up : Base6Directions.Direction.Right));

            IMyShipMergeBlock otherMerge = merge.CubeGrid.GetCubeBlock(otherPosition)?.FatBlock as IMyShipMergeBlock;

            if (otherMerge == merge)
            {
                return(null);
            }
            return(otherMerge);
        }
        bool CollectAllPartsHummingbird(IMyTerminalBlock block)
        {
            if (block == Me)
            {
                return(false);
            }
            if (!Me.IsSameConstructAs(block))
            {
                return(false);
            }
            if (block.CubeGrid == Me.CubeGrid)
            {
                PartsOfInterest.Add(block);
            }
            else
            {
                PartsOfInterest2.Add(block);
            }
            if (block is IMyShipMergeBlock && block.CustomName.Contains("<BASE>"))
            {
                Base = (IMyShipMergeBlock)block;
            }
            if (block is IMyMotorAdvancedStator)
            {
                Rotor = (IMyMotorAdvancedStator)block;
            }
            if (block is IMyProjector)
            {
                Projector = (IMyProjector)block;
            }
            if (block is IMyShipConnector)
            {
                Connector = (IMyShipConnector)block;
            }

            return(false);
        }
            public Missile(
                List <IMyGyro> gyros,
                List <IMyThrust> thrusters,
                IMyShipMergeBlock mergeBlock = null,
                IMyUserControllableGun gun   = null,
                List <IMyWarhead> warheads   = null,
                IMyTimerBlock customP        = null,
                IMySensorBlock sensor        = null)
            {
                // Initialize
                _gyros      = gyros;
                _thrusters  = thrusters;
                _mergeBlock = mergeBlock;
                _gun        = gun;
                _warheads   = warheads;
                _customP    = customP;
                _sensor     = sensor;

                // Check if the missile is valid
                if (_gyros == null)
                {
                    Error |= MissileError.MissingGyros;
                }
                if (_thrusters == null)
                {
                    Error |= MissileError.MissingThrust;
                }
                if (_mergeBlock == null && gun == null && _warheads == null)
                {
                    Error |= MissileError.MissingDetach;
                }
                if (Error != MissileError.None)
                {
                    Error ^= MissileError.None;
                    return;
                }
            }
Beispiel #26
0
            public Torpedo(string GroupName, Program program)
            {
                _program = program;
                Name     = GroupName;
                List <IMyTerminalBlock> templist = new List <IMyTerminalBlock>();

                templist.Clear();

                _program.Echo("Init Connector");
                gts.GetBlocksOfType <IMyShipConnector>(templist, (b) => b.CustomName.Contains(GroupName));
                connector = templist[0] as IMyShipConnector;
                connector.ApplyAction(Actions.TURN_ON);
                if (connector.Status == MyShipConnectorStatus.Connectable)
                {
                    connector.ToggleConnect();
                }
                templist.Clear();

                _program.Echo("Init Merge Block");
                gts.GetBlocksOfType <IMyShipMergeBlock>(templist, (b) => b.CustomName.Contains(GroupName));
                merge = templist[0] as IMyShipMergeBlock;
                merge.ApplyAction(Actions.TURN_ON);
                merge.Enabled = true;
                templist.Clear();

                _program.Echo("Init Remote Control");
                gts.GetBlocksOfType <IMyRemoteControl>(templist, (b) => b.CustomName.Contains(GroupName));
                remcon = templist[0] as IMyRemoteControl;
                //remcon.ApplyAction(Actions.TURN_ON);


                _program.Echo("Init Battery");
                batteries = new List <IMyBatteryBlock>();
                gts.GetBlocksOfType <IMyBatteryBlock>(batteries, (b) => b.CustomName.Contains(GroupName));
                foreach (IMyBatteryBlock battery in batteries)
                {
                    battery.ApplyAction(Actions.TURN_ON);
                    battery.Enabled = true;
                }

                _program.Echo("Init HYDROGEN tANKS");
                hydrogenTanks = new List <IMyGasTank>();
                gts.GetBlocksOfType <IMyGasTank>(hydrogenTanks, (b) => b.CustomName.Contains(GroupName));
                foreach (IMyGasTank hydrogenTank in hydrogenTanks)
                {
                    hydrogenTank.ApplyAction(Actions.TURN_ON);
                    hydrogenTank.Enabled   = true;
                    hydrogenTank.Stockpile = true;                     //Tankowanie zbiorników
                }

                _program.Echo("Init thrusters");
                thrusters = new List <IMyThrust>();
                gts.GetBlocksOfType <IMyThrust>(thrusters, (b) => b.CustomName.Contains(GroupName));
                _program.Echo("Init gyros");
                gyros = new List <IMyGyro>();
                gts.GetBlocksOfType <IMyGyro>(gyros, (b) => b.CustomName.Contains(GroupName));
                _program.Echo("Init warheads");
                warheads = new List <IMyWarhead>();
                gts.GetBlocksOfType <IMyWarhead>(warheads, (b) => b.CustomName.Contains(GroupName));
                _program.Echo("Init decoys");
                decoys = new List <IMyDecoy>();
                gts.GetBlocksOfType <IMyDecoy>(decoys, (b) => b.CustomName.Contains(GroupName));
                status = 1;
            }
Beispiel #27
0
 public LandpedoTube(IMyShipMergeBlock merge)
 {
     Merge = merge;
 }
Beispiel #28
0
        public void CheckLandpedo()
        {
            statusBuilder.Clear();
            if (Landpedo != null)
            {
                return;
            }

            if (Connector != null)
            {
                if (!Connector.IsWorking)
                {
                    return;
                }
                if (Connector.Status == MyShipConnectorStatus.Unconnected)
                {
                    return;
                }
                if (Connector.Status == MyShipConnectorStatus.Connectable)
                {
                    Connector.Connect();
                }

                if (Connector.Status != MyShipConnectorStatus.Connected)
                {
                    return;
                }

                var other = Connector.OtherConnector;
                var lines = other.CustomData.Split('\n');
                // Parts
                // Projector
                // Merge

                IMyProjector      projector = null;
                IMyShipMergeBlock merge     = null;


                if (GridTerminalHelper.Base64BytePosToBlockList(lines[1], other, ref PartScratchpad))
                {
                    projector = PartScratchpad[0] as IMyProjector;
                }

                PartScratchpad.Clear();
                if (GridTerminalHelper.Base64BytePosToBlockList(lines[2], other, ref PartScratchpad))
                {
                    merge = PartScratchpad[0] as IMyShipMergeBlock;
                }

                if (projector != null && merge != null)
                {
                    projector.Enabled = true;
                    merge.Enabled     = false;
                }

                PartScratchpad.Clear();
                if (!GridTerminalHelper.Base64BytePosToBlockList(lines[0], other, ref PartScratchpad))
                {
                    return;
                }

                Landpedo          = Landpedo.GetLandpedo(PartScratchpad);
                projector.Enabled = false;
            }
            else
            {
            }
        }
Beispiel #29
0
        public Program()
        {
            try
            {
                UpdateSettings();
                ResetDisplay();

                this.remote = GridTerminalSystem.GetBlockOfType <IMyRemoteControl>(rm => rm.CubeGrid == Me.CubeGrid && MyIni.HasSection(rm.CustomData, REFERENCE_RM));

                if (remote == null)
                {
                    throw new InvalidOperationException("Missile MUST have a remote. (That is forward facing)");
                }
                LogLine($"Found remote {remote.CustomName}");

                this.separator = GridTerminalSystem.GetBlockOfType <IMyShipMergeBlock>(mb => mb.CubeGrid == Me.CubeGrid && MyIni.HasSection(mb.CustomData, SEPARATOR_MARKER));
                if (this.separator != null)
                {
                    LogLine($"Found separator merge-block {separator.CustomName}");
                }
                else
                {
                    LogLine($"Warning: No separator block found. Missile can launch without one, but if you do have a separator, add a [{SEPARATOR_MARKER}] line to its custom data.");
                }

                this.statusLogger = new Logger(this, STATUS_DISPLAY_SECTION, true);

                GridTerminalSystem.GetBlocksOfType(allThrusters, th => th.CubeGrid == Me.CubeGrid);

                foreach (var thruster in allThrusters)
                {
                    if (thruster.WorldMatrix.Forward == remote.WorldMatrix.Backward)
                    {
                        fwdThrusters.Add(thruster);
                        LogLine($"Found forward thruster {thruster.CustomName}");
                    }
                    if (thruster.WorldMatrix.Forward == remote.WorldMatrix.Up)
                    {
                        downThrusters.Add(thruster);
                        LogLine($"Found down thruster {thruster.CustomName}");
                    }
                    thruster.Enabled = false;
                    thruster.ThrustOverridePercentage = 0;
                }

                GridTerminalSystem.GetBlocksOfType(warheads, b => b.CubeGrid == Me.CubeGrid);
                LogLine($"Found {warheads.Count} warheads.");

                foreach (var warhead in warheads)
                {
                    warhead.IsArmed = false;
                }

                GridTerminalSystem.GetBlocksOfType(gyros, b => b.CubeGrid == Me.CubeGrid);
                foreach (var gyro in gyros)
                {
                    gyro.Enabled = false;
                }

                GridTerminalSystem.GetBlocksOfType(antennas, b => b.CubeGrid == Me.CubeGrid && MyIni.HasSection(b.CustomData, MISSILE_ANTENNA));
                foreach (var ant in antennas)
                {
                    ant.Enabled    = false;
                    ant.Radius     = 50000f;
                    ant.CustomName = $"{uuid} Antenna";
                }

                LogLine("Missile is ready to launch");
                LogStatus("Missile: Pre-flight");
                this.msgHandler = CreateMessageHandler();
                IGC.SendBroadcast(new RegisterMissileCommand()
                {
                    UUID = uuid
                });
            }
            catch (Exception ex)
            {
                LogLine($"[{uuid}] Program() expection: {ex}\nStacktrace: \n{ex.StackTrace}");
            }
        }
Beispiel #30
0
 public void GetBlocks() // you didn't change any names, did you?
 {
     _Sensor      = GridTerminalSystem.GetBlockWithName("Tool Sensor") as IMySensorBlock;
     _ConnectorX  = GridTerminalSystem.GetBlockWithName("X Connector") as IMyShipConnector;
     _ConnectorY  = GridTerminalSystem.GetBlockWithName("Y Connector") as IMyShipConnector;
     _ConnectorZ1 = GridTerminalSystem.GetBlockWithName("Z Connector 1") as IMyShipConnector;
     _ConnectorZ2 = GridTerminalSystem.GetBlockWithName("Z Connector 2") as IMyShipConnector;
     _MoveConX    = GridTerminalSystem.GetBlockWithName("X Move") as IMyShipConnector;
     _MoveConY    = GridTerminalSystem.GetBlockWithName("Y Move") as IMyShipConnector;
     _MoveConZ1   = GridTerminalSystem.GetBlockWithName("Z Move 1") as IMyShipConnector;
     _MoveConZ2   = GridTerminalSystem.GetBlockWithName("Z Move 2") as IMyShipConnector;
     _PistonX     = GridTerminalSystem.GetBlockWithName("X Piston") as IMyPistonBase;
     _PistonY     = GridTerminalSystem.GetBlockWithName("Y Piston") as IMyPistonBase;
     _PistonZ     = GridTerminalSystem.GetBlockWithName("Z Piston") as IMyPistonBase;
     _MergeX      = GridTerminalSystem.GetBlockWithName("X Merge") as IMyShipMergeBlock;
     _MergeY      = GridTerminalSystem.GetBlockWithName("Y Merge") as IMyShipMergeBlock;
     _MergeZ      = GridTerminalSystem.GetBlockWithName("Z Merge") as IMyShipMergeBlock;
     GridTerminalSystem.GetBlockGroupWithName("3D-Printer").GetBlocksOfType(_Welders);
     GridTerminalSystem.GetBlockGroupWithName("3D-Printer").GetBlocksOfType(_Grinders);
     GridTerminalSystem.GetBlockGroupWithName("3D-Printer").GetBlocksOfType(_Lcds);
     if (_Sensor == null)
     {
         output.Append("Tool Sensor not found!\n");
     }
     if (_ConnectorX == null)
     {
         output.Append("X Connector not found!\n");
     }
     if (_ConnectorY == null)
     {
         output.Append("Y Connector not found!\n");
     }
     if (_ConnectorZ1 == null)
     {
         output.Append("Z Connector 1 not found!\n");
     }
     if (_ConnectorZ2 == null)
     {
         output.Append("Z Connector 2 not found!\n");
     }
     if (_MoveConX == null)
     {
         output.Append("X Move not found!\n");
     }
     if (_MoveConY == null)
     {
         output.Append("Y Move not found!\n");
     }
     if (_MoveConZ1 == null)
     {
         output.Append("Z Move 1 not found!\n");
     }
     if (_MoveConZ2 == null)
     {
         output.Append("Z Move 2 not found!\n");
     }
     if (_PistonX == null)
     {
         output.Append("X Piston not found!\n");
     }
     if (_PistonY == null)
     {
         output.Append("Y Piston not found!\n");
     }
     if (_PistonZ == null)
     {
         output.Append("Z Piston not found!\n");
     }
     if (_MergeX == null)
     {
         output.Append("X Merge not found!\n");
     }
     if (_MergeY == null)
     {
         output.Append("Y Merge not found!\n");
     }
     if (_MergeZ == null)
     {
         output.Append("Z Merge not found!\n");
     }
     if (_Welders.Count == 0 && _Grinders.Count == 0)
     {
         output.Append("No Welders or Grinders found in Group '3D-Printer'\n");
     }
     if (_Lcds.Count == 0)
     {
         output.Append("No LCD Panels found in Group '3D-Printer'\n");
     }
     if (_Welders.Count != 0 && _Grinders.Count == 0)
     {
         mode = EMode.welding;
     }
     if (_Welders.Count == 0 && _Grinders.Count != 0)
     {
         mode = EMode.grinding;
     }
 }