Esempio n. 1
0
        /// <summary>
        /// Gets instructions and feeds them to the parser. Stops if parser is happy with an instruction set.
        /// </summary>
        private void GetInstructions()
        {
            m_instructions = null;
            m_monitors.Clear();
            HasInstructions = false;

            //Log.DebugLog("Trying to get instructions from name: " + m_displayName, "GetInstructions()", Logger.severity.DEBUG);
            if (GetInstructions(m_displayName))
            {
                //Log.DebugLog("Got instructions from name", "GetInstructions()", Logger.severity.DEBUG);
                return;
            }

            Ingame.IMyTextPanel asPanel = m_block as Ingame.IMyTextPanel;
            if (asPanel != null)
            {
                //Log.DebugLog("Trying to get instructions from public title: " + asPanel.GetPublicTitle(), "GetInstructions()");
                AddMonitor(asPanel.GetPublicTitle);
                if (GetInstructions(asPanel.GetPublicTitle()))
                {
                    //Log.DebugLog("Got instructions from public title", "GetInstructions()", Logger.severity.DEBUG);
                    return;
                }
                //Log.DebugLog("Trying to get instructions from private title: " + asPanel.GetPrivateTitle(), "GetInstructions()");
#pragma warning disable CS0618
                AddMonitor(asPanel.GetPrivateTitle);
                if (GetInstructions(asPanel.GetPrivateTitle()))
#pragma warning restore CS0618
                {
                    //Log.DebugLog("Got instructions from private title", "GetInstructions()", Logger.severity.DEBUG);
                    return;
                }
            }
        }
Esempio n. 2
0
 public void BindLCD(Ingame.IMyTextPanel txtpnl)
 {
     if (text != null)
     {
         text.WritePublicText("MENU UNBOUND");
     }
     text = txtpnl;
     UpdateLCD();
 }
Esempio n. 3
0
 public TextPanel(IMyCubeBlock block)
 {
     myCubeBlock = block;
     myTextPanel = block as Ingame.IMyTextPanel;
     myTermBlock = block as IMyTerminalBlock;
     myLogger    = new Logger("TextPanel", () => myCubeBlock.CubeGrid.DisplayName, () => myCubeBlock.getNameOnly());
     myLogger.debugLog("init: " + myCubeBlock.DisplayNameText, "DelayedInit()");
     myTermBlock.CustomNameChanged += TextPanel_CustomNameChanged;
     myTermBlock.OnClosing         += Close;
 }
Esempio n. 4
0
        public TextPanel(IMyCubeBlock block)
            : base(block)
        {
            m_textPanel     = block as Ingame.IMyTextPanel;
            myTermBlock     = block as IMyTerminalBlock;
            m_networkClient = new RelayClient(block);
            Log.DebugLog("init: " + m_block.DisplayNameText);

            Registrar.Add(block, this);
        }
Esempio n. 5
0
        private static LinkedList <Ingame.IMyTextPanel> findTextPanel(IMyCubeBlock showoff)
        {
            string searchForName = getTextPanelName(showoff);

            if (searchForName == null)
            {
                return(null);
            }

            List <IMySlimBlock> allBlocks = new List <IMySlimBlock>();

            showoff.CubeGrid.GetBlocks(allBlocks);

            LinkedList <Ingame.IMyTextPanel> textPanels = new LinkedList <Ingame.IMyTextPanel>();

            foreach (IMySlimBlock block in allBlocks)
            {
                IMyCubeBlock fatblock = block.FatBlock;
                if (fatblock == null)
                {
                    continue;
                }

                Ingame.IMyTextPanel panel = fatblock as Ingame.IMyTextPanel;
                if (panel == null)
                {
                    log("not a panel: " + fatblock.DisplayNameText, "findTextPanel()", Logger.severity.TRACE);
                    continue;
                }

                if (!showoff.canConsiderFriendly(fatblock))
                {
                    log("not friendly: " + fatblock.DisplayNameText, "findTextPanel()", Logger.severity.TRACE);
                    continue;
                }

                if (fatblock.DisplayNameText.looseContains(searchForName))
                {
                    log("adding panel: " + fatblock.DisplayNameText, "findTextPanel()", Logger.severity.TRACE);
                    textPanels.AddLast(panel);
                }
            }
            return(textPanels);
        }
Esempio n. 6
0
 public PanelInstructions(Ingame.IMyTextPanel block)
 {
     Block = block;
     PublicText = Block.GetPublicText();
 }
Esempio n. 7
0
        /// <summary>
        /// <para>add actions from a text panel</para>
        /// <para>Format for instruction is [ t (Text Panel Name), (Identifier) ]</para>
        /// </summary>
        private bool addAction_textPanel(string dataLowerCase)
        {
            string[] split = dataLowerCase.Split(',');

            string panelName;

            if (split.Length == 2)
            {
                panelName = split[0];
            }
            else
            {
                panelName = dataLowerCase;
            }

            IMyCubeBlock bestMatch;

            if (!owner.myTargeter.findBestFriendly(owner.myGrid, out bestMatch, panelName))
            {
                myLogger.debugLog("could not find " + panelName + " on " + owner.myGrid.DisplayName, "addAction_textPanel()", Logger.severity.DEBUG);
                return(false);
            }

            Ingame.IMyTextPanel panel = bestMatch as Ingame.IMyTextPanel;
            if (panel == null)
            {
                myLogger.debugLog("not a Text Panel: " + panel, "addAction_textPanel()", Logger.severity.DEBUG);
                return(false);
            }

            string panelText = panel.GetPublicText();
            string lowerText = panelText.ToLower();

            string identifier;
            int    identifierIndex, startOfCommands;

            if (split.Length == 2)
            {
                identifier      = split[1];
                identifierIndex = lowerText.IndexOf(identifier);
                if (identifierIndex < 0)
                {
                    myLogger.debugLog("could not find " + identifier + " in text of " + panel.DisplayNameText, "addAction_textPanel()", Logger.severity.DEBUG);
                    return(false);
                }
                startOfCommands = panelText.IndexOf('[', identifierIndex + identifier.Length) + 1;
            }
            else
            {
                identifier      = null;
                identifierIndex = -1;
                startOfCommands = panelText.IndexOf('[') + 1;
            }

            if (startOfCommands < 0)
            {
                myLogger.debugLog("could not find start of commands following " + identifier + " in text of " + panel.DisplayNameText, "addAction_textPanel()", Logger.severity.DEBUG);
                return(false);
            }

            int endOfCommands = panelText.IndexOf(']', startOfCommands + 1);

            if (endOfCommands < 0)
            {
                myLogger.debugLog("could not find end of commands following " + identifier + " in text of " + panel.DisplayNameText, "addAction_textPanel()", Logger.severity.DEBUG);
                return(false);
            }

            myLogger.debugLog("fetching commands from panel: " + panel.DisplayNameText, "addAction_textPanel()", Logger.severity.TRACE);
            enqueueAllActions_continue(panelText.Substring(startOfCommands, endOfCommands - startOfCommands));

            return(true);            // this instruction was successfully executed, even if sub instructions were not
        }