Example #1
0
        public void StartGooeyProgramming()
        {
            Log.DebugLog("entered");

            using (MainLock.AcquireSharedUsing())
            {
                m_currentCommand = null;
                m_listCommands   = true;
                m_commandList.Clear();
                m_syntaxErrors.Clear();

                MyTerminalControls.Static.CustomControlGetter += CustomControlGetter;
                m_block.AppendingCustomInfo += m_block_AppendingCustomInfo;

                Commands = AutopilotTerminal.GetAutopilotCommands(m_block).ToString();
                foreach (ACommand comm in ParseCommands(Commands))
                {
                    m_commandList.Add(comm);
                }
                if (m_syntaxErrors.Length != 0)
                {
                    m_block.UpdateCustomInfo();
                }
                m_block.RebuildControls();
            }
        }
Example #2
0
        /// <summary>
        /// Get all the blocks on the target grid that are damaged
        /// </summary>
        private void GetDamagedBlocks()
        {
            m_damagedBlocks.Clear();
            m_projectedBlocks.Clear();

            // get physical blocks

            foreach (IMySlimBlock slim in Attached.AttachedGrid.AttachedSlimBlocks((IMyCubeGrid)m_currentGrid.Entity, Attached.AttachedGrid.AttachmentKind.Permanent, true))
            {
                if (slim.CurrentDamage > 0f || slim.BuildLevelRatio < 1f)
                {
                    m_damagedBlocks.Add(slim);
                }
            }

            // get projections

            HashSet <IMyEntity> projections = null;

            foreach (IMyCubeGrid grid in Attached.AttachedGrid.AttachedGrids((IMyCubeGrid)m_currentGrid.Entity, Attached.AttachedGrid.AttachmentKind.Permanent, true))
            {
                if (CubeGridCache.GetFor(grid).CountByType(typeof(MyObjectBuilder_Projector)) == 0)
                {
                    continue;
                }

                using (MainLock.AcquireSharedUsing())
                {
                    if (projections == null)
                    {
                        projections = new HashSet <IMyEntity>();
                        MyAPIGateway.Entities.GetEntities(projections, entity => entity is MyCubeGrid && ((MyCubeGrid)entity).Projector != null);

                        if (projections.Count == 0)
                        {
                            break;
                        }
                    }

                    foreach (MyCubeGrid proj in projections)
                    {
                        if (proj.Projector.CubeGrid == grid)
                        {
                            foreach (IMySlimBlock block in proj.CubeBlocks)
                            {
                                m_projectedBlocks.Add(block);
                            }
                        }
                    }
                }

                continue;
            }

            m_projectedBlocks.ApplyAdditions();

            Log.DebugLog("damaged blocks: " + m_damagedBlocks.Count + ", projected blocks: " + m_projectedBlocks.Count);
        }
Example #3
0
        public AutopilotActionList GetActions(string allCommands)
        {
            using (MainLock.AcquireSharedUsing())
            {
                Commands = allCommands;
                m_syntaxErrors.Clear();

                AutopilotActionList actList = new AutopilotActionList();
                GetActions(Commands, actList);
                if (m_syntaxErrors.Length != 0)
                {
                    m_block.UpdateCustomInfo();
                }
                return(actList);
            }
        }
Example #4
0
 private void GetAllComponents(IMySlimBlock slim)
 {
     using (MainLock.AcquireSharedUsing())
     {
         foreach (MyCubeBlockDefinition.Component component in ((MySlimBlock)slim).BlockDefinition.Components)
         {
             int currentCount;
             if (!m_components_missing.TryGetValue(component.Definition.Id.SubtypeName, out currentCount))
             {
                 currentCount = 0;
             }
             currentCount += component.Count;
             m_components_missing[component.Definition.Id.SubtypeName] = currentCount;
             //Log.DebugLog("missing " + component.Definition.Id.SubtypeName + ": " + component.Count + ", total: " + currentCount, "GetAllComponents()");
         }
     }
 }
Example #5
0
        public AutopilotActionList GetActions()
        {
            using (MainLock.AcquireSharedUsing())
            {
                if (!m_actionList.IsEmpty)
                {
                    m_actionList.Reset();
                    return(m_actionList);
                }
                m_syntaxErrors.Clear();

                Commands = AutopilotTerminal.GetAutopilotCommands(m_block).ToString();
                List <ACommand> commands = new List <ACommand>();
                GetActions(Commands, m_actionList);
                if (m_syntaxErrors.Length != 0)
                {
                    m_block.UpdateCustomInfo();
                }
                return(m_actionList);
            }
        }
Example #6
0
 private void GetMissingComponents(IMySlimBlock slim)
 {
     using (MainLock.AcquireSharedUsing())
         slim.GetMissingComponents(m_components_missing);
 }