public override void update(MyContext context)
            {
                _running += context.Program.Runtime.TimeSinceLastRun;

                if (context._stopStateRequested)
                {
                    context.transition(MyContext.Stopped);
                    return;
                }

                if (!context.isHeadConnected())
                {
                    context.log("Cannot start: head not connected");
                    return;
                }

                bool inventoryFull = InventoryFilled.computeProportion(context._cargo) >= 0.95;
                bool ok            = context.FoundAllBlocks &&
                                     context._integrityOk
                                     //&& context._hasRequiredInventory
                                     && !inventoryFull;

                if (!ok)
                {
                    MyContext.setBlocksEnabled(context._drills, false);
                    MyContext.setBlocksEnabled(context._welders, false);
                    MyContext.setBlocksEnabled(context._pistons, false);
                    return;
                }

                foreach (IMyLandingGear gear in context._landingGears)
                {
                    gear.Unlock();
                }

                MyContext.setBlocksEnabled(context._drills, true);
                bool enablePistons = _running.TotalSeconds > 2;

                if (enablePistons)
                {
                    MyContext.extendPistons(context._pistons, 0.10f);
                }
                else
                {
                    MyContext.setBlocksEnabled(context._pistons, false);
                }
                MyContext.setBlocksEnabled(context._welders, true);

                if (MyContext.getPistonGroupExtensionProportion(context._pistons) > 0.99999)
                {
                    context.transition(new SettleState());
                }
            }
Esempio n. 2
0
            public override void update(MyContext context)
            {
                if (!context.FoundAllBlocks)
                {
                    return;
                }

                double inventoryFilledPercent = InventoryFilled.computeProportion(context._cargo) * 100;
                bool   on = inventoryFilledPercent <= DRILL_SHUTOFF_CARGO_FILL_PERCENT;

                MyContext.setBlocksEnabled(context._drills, on);
                MyContext.setBlocksEnabled(context._pistons, on);

                context.Program.Echo("Cargo: " + inventoryFilledPercent);
            }
            protected override void updateDisplayImpl()
            {
                _stringBuilder.Clear();
                _stringBuilder.Append("TBM\n");
                if (!FoundAllBlocks)
                {
                    _stringBuilder.Append("ERROR: Missing blocks\n");
                }

                _stringBuilder.Append("Status:\n");
                _stringBuilder.Append("    ");
                _stringBuilder.Append(State.ToString());
                _stringBuilder.Append("\n");

                _stringBuilder.Append("Cargo:\n");
                _stringBuilder.Append(string.Format("    {0:0.0} %\n", InventoryFilled.computeProportion(_cargo) * 100));

                if (_error != null)
                {
                    _stringBuilder.Append(_error);
                }

                if (!_hasRequiredInventory)
                {
                    _stringBuilder.Append("Missing inventory for welders:\n    ");
                    _stringBuilder.Append(_missingInventory);
                }

                string text = _stringBuilder.ToString();

                foreach (IMyTextPanel panel in _textPanels)
                {
                    panel.ContentType = ContentType.TEXT_AND_IMAGE;
                    panel.WriteText(text);
                }
            }