Пример #1
0
 bool tryAddAssemblerTask(IMyProductionBlock assembler, string definition, VRage.MyFixedPoint count)
 {
     try {
         MyDefinitionId objectIdToAdd = new MyDefinitionId();
         MyDefinitionId.TryParse(definition, out objectIdToAdd);
         assembler.AddQueueItem(objectIdToAdd, count);
         return(true);
     } catch (Exception e) {
         return(false);
     }
 }
Пример #2
0
        public void Make_component(MyFixedPoint min_count, MyFixedPoint current_count, MyFixedPoint production_queue, string blueprint)
        {
            //Dbg_panel($"Make_component({blueprint})");

            MyDefinitionId queue_item_blueprint_id;
            MyFixedPoint   amount_diff;

            amount_diff = min_count - current_count - production_queue;
            //Dbg_panel($"amount_diff ({amount_diff}) = min_count ({min_count}) - current_count ({current_count}) - production_queue ({production_queue})");

            bool opt1 = amount_diff <= min_count;
            bool opt2 = amount_diff > 0;

            if (opt1 & opt2)
            {
                if (MyDefinitionId.TryParse(blueprint, out queue_item_blueprint_id))
                {
                    string[] blueprint_name = blueprint.Split('/');
                    Dbg_panel($"Make {amount_diff} of {blueprint_name[1]}");
                    assembler.AddQueueItem(queue_item_blueprint_id, amount_diff);
                }
            }
        }
        public void Main(string argument)
        {
            if (_assembler == null && !InitialiseAssembler())
            {
                WriteToTextPanel(_assemblerName + " not installed");
                return;
            }
            string arg = argument.ToLower();

            List <string> groups = new List <string>();

            for (int start = 0; (start = arg.IndexOf('(', start)) != -1; start++)
            {
                int    end    = (start >= 0) ? arg.IndexOf(')', start) : -1;
                string result = (end >= 0) ? arg.Substring(start + 1, end - start - 1) : "";
                groups.Add(result);
            }

            const string working = "Assembler is working.\n";
            const string missing = "Missing material for Queue.\n";

            if (!_assembler.IsProducing && !_assembler.IsQueueEmpty)
            {
                _asmworking.Replace(working, missing);
            }
            if (_assembler.IsProducing)
            {
                _asmworking.Clear();
                _asmworking.AppendLine(working);
            }
            if (!_assembler.IsProducing && _assembler.IsQueueEmpty)
            {
                _asmworking.Clear();
                _dynamicContent.Clear();
                _asmworking.AppendLine("Assembler is Idle.\n");
            }
            //dynamicContent.Clear();

            Echo(_runStatus[_runAdvancer]);
            _runAdvancer = (_runAdvancer + 1) % _runStatus.Length;

            foreach (var selectedGroup in groups)
            {
                List <string> args = new List <string>(selectedGroup.Split('/'));

                if (_values.ContainsKey(args[0]))
                {
                    string item  = _values[args[0]];
                    string count = args[1];

                    if (count?.Length == 0 || Convert.ToDouble(count) <= 0)
                    {
                        Echo("Item: " + item + "\nAmount: Wrong or No number input\n");
                        return;
                    }
                    MyDefinitionId objectIdToAdd = new MyDefinitionId();
                    if (MyDefinitionId.TryParse("MyObjectBuilder_BlueprintDefinition/" + item, out objectIdToAdd))
                    {
                        Echo("Item: " + item + "\nAmount: " + Convert.ToDouble(count) + "\n");
                        _assembler.AddQueueItem(objectIdToAdd, Convert.ToDouble(count));
                        _dynamicContent.Append("Item: ").Append(item).Append("\nAmount: ").Append(Convert.ToDouble(count)).AppendLine("\n");
                    }
                }
                else
                {
                    Echo("Argument Missing: Check Name \n");
                }
            }
            if (arg == "clear")
            {
                _dynamicContent.Clear();
                _assembler.ClearQueue();
                Echo("Cleared Assembler Queue.");
                _dynamicContent.AppendLine("Cleared Assembler Queue.");
            }

            WriteToTextPanel(_asmworking.ToString() + _dynamicContent.ToString());
            string asmstatus = ("\nAssembler is producing: " + _assembler.IsProducing.ToString());
            //string asmstatus = assembler.NextItemId.ToString();
            //WriteToTextPanel(asmstatus);
        }