Beispiel #1
0
        private static void Abort(MyFunctionalBlock block)
        {
            ManualMessage instance;
            if (!Registrar.TryGetValue(block.EntityId, out instance))
                throw new ArgumentException("block id not found in registrar");

            instance.m_sending = false;
            MyGuiScreenTerminal.SwitchToControlPanelBlock(block);
        }
        public void Initialize(Vector3 panelOrientation, bool isTwoSided, float panelOffset, MyFunctionalBlock solarBlock)
        {
            m_initialized = true;

            m_panelOrientation = panelOrientation;
            m_isTwoSided = isTwoSided;
            m_panelOffset = panelOffset;
            m_solarBlock = solarBlock;

            //Warning: this will change the NeedsUpdate variable on the entity
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
        }
 public FunctionalBlockWrapper( MySlimBlock block )
     : base(block)
 {
     Block = (MyFunctionalBlock)block.FatBlock;
 }
Beispiel #4
0
        private static void SendMessage(MyFunctionalBlock block)
        {
            ManualMessage instance;
            if (!Registrar.TryGetValue(block.EntityId, out instance))
                throw new ArgumentException("block id not found in registrar");

            if (instance.m_sending)
            {
                if (instance.m_targetShipName.Length < 3)
                {
                    (block as IMyTerminalBlock).AppendCustomInfo("Ship Name(s) must be at least 3 characters");
                    return;
                }
                if (instance.m_targetBlockName.Length < 3)
                {
                    (block as IMyTerminalBlock).AppendCustomInfo("Block Name(s) must be at least 3 characters");
                    return;
                }

                int count = Message.CreateAndSendMessage(block.EntityId, instance.m_targetShipName.ToString(), instance.m_targetBlockName.ToString(), instance.m_message.ToString());
                if (MyAPIGateway.Session.Player != null)
                    (block as IMyTerminalBlock).AppendCustomInfo("Sent message to " + count + " block" + (count == 1 ? "" : "s"));

                instance.m_sending = false;
                MyGuiScreenTerminal.SwitchToControlPanelBlock(block);
            }
            else
            {
                instance.m_sending = true;
                MyGuiScreenTerminal.SwitchToControlPanelBlock(block);
            }
        }
        /// <param name="args">Recipient grid, recipient block, message</param>
        private static void ProgrammableBlock_SendMessage(MyFunctionalBlock block, ListReader<Ingame.TerminalActionParameter> args)
        {
            if (args.Count != 3)
            {
                Static.s_logger.debugLog("Wrong number of arguments, expected 3, got " + args.Count, Logger.severity.WARNING);
                if (MyAPIGateway.Session.Player != null)
                    block.AppendCustomInfo("Failed to send message:\nWrong number of arguments, expected 3, got " + args.Count + '\n');
                return;
            }

            string[] stringArgs = new string[3];
            for (int i = 0; i < 3; i++)
            {
                if (args[i].TypeCode != TypeCode.String)
                {
                    Static.s_logger.debugLog("TerminalActionParameter #" + i + " is of wrong type, expected String, got " + args[i].TypeCode, Logger.severity.WARNING);
                    if (MyAPIGateway.Session.Player != null)
                        block.AppendCustomInfo("Failed to send message:\nTerminalActionParameter #" + i + " is of wrong type, expected String, got " + args[i].TypeCode + '\n');
                    return;
                }

                stringArgs[i] = (string)args[i].Value;
            }

            int count = Message.CreateAndSendMessage(block.EntityId, stringArgs[0], stringArgs[1], stringArgs[2]);
            if (MyAPIGateway.Session.Player != null)
                (block as IMyTerminalBlock).AppendCustomInfo("Sent message to " + count + " block" + (count == 1 ? "" : "s"));
        }