예제 #1
0
        void Main()
        {
            // initialize
            var blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyShipController>(blocks, FilterShipController);

            if (blocks.Count == 0)
            {
                throw new Exception("Did not find any cockpit.");
            }

            controller = blocks[0] as IMyShipController;
            debug.Append("use ").Append(controller.CustomName).Append(':').AppendLine();
            debug.Append(controller.HasInventory());
            if (controller.HasInventory())
            {
                for (int i = 0; i < controller.GetInventoryCount(); ++i)
                {
                    IMyInventory inv = controller.GetInventory(i);
                    debug.Append(inv).AppendLine();
                    var items = inv.GetItems();
                    for (int j = 0; j < items.Count; ++j)
                    {
                        debug.Append(items[j].Content).AppendLine();
                    }
                }
            }

            blocks = new List <IMyTerminalBlock>();
            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(blocks);
            if (blocks.Count == 0)
            {
                return;
            }

            IMyTextPanel text    = blocks[0] as IMyTextPanel;
            var          actions = new List <ITerminalAction>();

            text.GetActions(actions);
            for (int j = 0; j < actions.Count; ++j)
            {
                var action = actions[j];
                debug.Append(action.Id).AppendLine();
            }

            var properties = new List <ITerminalProperty>();

            text.GetProperties(properties);
            for (int j = 0; j < actions.Count; ++j)
            {
                var property = properties[j];
                debug.Append(property.TypeName).Append(" ").Append(property.Id).AppendLine();
            }


            Debug(debug.ToString());
            debug.Clear();
        }