public WaypathManager(IMyTextSurface outputSurface)
        {
            this.outputSurface = outputSurface;
            paths        = new List <Waypath>();
            currentIndex = 0;

            commandTree = new PanelCommander.CommandTree()
            {
                label    = "Waypath Manager",
                commands = new List <PanelCommander.Command>()
                {
                    new PanelCommander.Command()
                    {
                        label = "Next Waypath", action = NextWaypath
                    },
                    new PanelCommander.Command()
                    {
                        label = "Delete Waypath", action = DeleteWaypath
                    }
                },
                subtrees = new List <PanelCommander.CommandTree>(),
            };

            DrawOutput();
        }
Ejemplo n.º 2
0
 private static void PrintStatus(IMyTextSurface textSurface, SolarArray solarArray)
 {
     textSurface.WriteText($"{solarArray.Label}: ", true);
     textSurface.WriteText($"{solarArray.CurrentOutput:F3}MW / {solarArray.MaxOutput:F3}MW ", true);
     PrintMovementStatus(textSurface, solarArray);
     textSurface.WriteText("\n", true);
 }
Ejemplo n.º 3
0
        public Program()
        {
            GridTerminalSystem.GetBlocksOfType(inventoryEntities, entity => entity.HasInventory);
            Dictionary <String, String> properties = ReadProperties(Me.CustomData);

            if (properties.ContainsKey(PROP_MASS_WATERM_VAL))
            {
                massWatermarkValue = Int64.Parse(properties[PROP_MASS_WATERM_VAL] as string);
            }

            if (properties.ContainsKey(PROP_MASS_WATERM_ACT))
            {
                massWatermarkActivate      = properties[PROP_MASS_WATERM_ACT] as string;
                massWatermarkActivateBlock = GridTerminalSystem.GetBlockWithName(massWatermarkActivate) as IMyFunctionalBlock;
            }

            if (properties.ContainsKey(PROP_VOL_WATERM_VAL))
            {
                volumeWatermarkValue = Int64.Parse(properties[PROP_VOL_WATERM_VAL] as string);
            }

            if (properties.ContainsKey(PROP_VOL_WATERM_ACT))
            {
                volumeWatermarkActivate      = properties[PROP_VOL_WATERM_ACT] as string;
                volumeWatermarkActivateBlock = GridTerminalSystem.GetBlockWithName(volumeWatermarkActivate) as IMyFunctionalBlock;
            }

            Runtime.UpdateFrequency = UpdateFrequency.Update100;

            surface             = Me.GetSurface(0);
            surface.ContentType = ContentType.TEXT_AND_IMAGE;
        }
Ejemplo n.º 4
0
        public Program()
        {
            m_Cockpit = GridTerminalSystem.GetBlockWithName(CockpitName) as IMyCockpit;

            m_CockpitBatteryDamagePanel           = m_Cockpit.GetSurface(IntegrityBatteryDisplayIndex);
            m_CockpitBatteryDamagePanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
            GridTerminalSystem.GetBlocksOfType(m_Batteries, a => a is IMyBatteryBlock && a.IsSameConstructAs(m_Cockpit));

            m_CockpitCargoPanel           = m_Cockpit.GetSurface(CargoCheckDisplayIndex);
            m_CockpitCargoPanel.Alignment = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            m_Gyros = new List <IMyGyro>();
            GridTerminalSystem.GetBlocksOfType(m_Gyros, a => a.IsSameConstructAs(m_Cockpit));

            var allBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(allBlocks, a => a.IsSameConstructAs(m_Cockpit));
            foreach (var block in allBlocks)
            {
                m_AllBlocks.Add(new KeyValuePair <IMyTerminalBlock, IMySlimBlock>(block, block.CubeGrid.GetCubeBlock(block.Position)));
            }

            m_Connector = GridTerminalSystem.GetBlockWithName(ConnectorName) as IMyShipConnector;

            Runtime.UpdateFrequency = UpdateFrequency.Update10;
        }
Ejemplo n.º 5
0
        public Program()
        {
            cockpit = GridTerminalSystem.GetBlockWithName(NAME_COCKPIT) as IMyCockpit;
            GridTerminalSystem.GetBlocksOfType <IMyGyro>(gyroList);

            if (cockpit != null)
            {
                Echo("cockpit OK");
                lcd             = cockpit.GetSurface(0); // or 1
                lcd.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            }
            else
            {
                Echo("cockpit ERROR");
            }

            if (gyroList.Count() > 0)
            {
                Echo("gyro OK");
            }
            else
            {
                Echo("gyro ERROR");
            }

            if (gyroList.Count() > 0 && cockpit != null)
            {
                Runtime.UpdateFrequency = UpdateFrequency.Update1;
            }
            else
            {
                Runtime.UpdateFrequency = UpdateFrequency.None;
            }
        }
Ejemplo n.º 6
0
        // Script constructor
        public Program()
        {
            // Me is the programmable block which is running this script.
            // Retrieve the Large Display, which is the first surface
            _drawingSurface = Me.GetSurface(0);

            StringBuilder sprts   = new StringBuilder();
            List <String> sprites = new List <String>();

            _drawingSurface.GetSprites(sprites);

            sprites.ForEach(sprt =>
            {
                sprts.Append($"{sprt}\n");
            });
            Me.CustomData = "";
            Me.CustomData = sprts.ToString();

            // Set the continuous update frequency of this script
            //Runtime.UpdateFrequency = UpdateFrequency.Update100;

            IMyTextPanel lcd = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("Shitty Fucky Test LCD");

            _drawingSurface = lcd;

            // Calculate the viewport by centering the surface size onto the texture size
            _viewport = new RectangleF(
                (_drawingSurface.TextureSize - _drawingSurface.SurfaceSize) / 2f,
                _drawingSurface.SurfaceSize
                );

            // Make the text surface display sprites
            PrepareTextSurfaceForSprites(_drawingSurface);
        }
Ejemplo n.º 7
0
 public Program()
 {
     Runtime.UpdateFrequency = UpdateFrequency.Update10;
     GridTerminalSystem.GetBlocks(blocks);
     foreach (IMyTerminalBlock block in blocks)
     {
         IMyTextSurfaceProvider surfaceProvider = block as IMyTextSurfaceProvider;
         if (null != surfaceProvider)
         {
             surfaceProviders.Add(surfaceProvider);
         }
     }
     foreach (IMyTextSurfaceProvider prov in surfaceProviders)
     {
         int count = prov.SurfaceCount;
         for (int i = 0; i < count; i++)
         {
             IMyTextSurface surface = prov.GetSurface(i);
             surface.ContentType = ContentType.SCRIPT;
             surface.Script      = "None";
             surfaces.Add(surface);
         }
     }
     //Runtime.UpdateFrequency = UpdateFrequency.Update100;
 }
Ejemplo n.º 8
0
        private void CargoDisplay(IMyTextSurface display)
        {
            var cargoDict = new Dictionary <MyItemType, MyFixedPoint>();

            foreach (var cargo in m_Cargos)
            {
                var items = new List <MyInventoryItem>();
                for (int i = 0; i < cargo.InventoryCount; i++)
                {
                    var inventory = cargo.GetInventory(i);
                    inventory.GetItems(items);
                }
                foreach (var item in items)
                {
                    if (!cargoDict.ContainsKey(item.Type))
                    {
                        cargoDict[item.Type] = item.Amount;
                    }
                    else
                    {
                        cargoDict[item.Type] += item.Amount;
                    }
                }
            }

            string textString = "=== CARGO ===\n";

            foreach (var pair in cargoDict)
            {
                textString += string.Format("{0}: {1}\n", pair.Key.SubtypeId, pair.Value.ToIntSafe());
            }
            m_CockpitCargoPanel.WriteText(textString);
        }
Ejemplo n.º 9
0
        public Program()
        {
            m_Cockpit = GridTerminalSystem.GetBlockWithName(CockpitName) as IMyCockpit;

            m_CockpitBatteryDamagePanel             = m_Cockpit.GetSurface(IntegrityBatteryDisplayIndex);
            m_CockpitBatteryDamagePanel.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            m_CockpitBatteryDamagePanel.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            GridTerminalSystem.GetBlocksOfType(m_Batteries, a => a is IMyBatteryBlock && a.IsSameConstructAs(m_Cockpit) && a.CustomName != BIOSBatteryName);
            m_BIOSBattery = GridTerminalSystem.GetBlockWithName(BIOSBatteryName) as IMyBatteryBlock;

            GridTerminalSystem.GetBlocksOfType(m_Cargos, a => a is IMyCargoContainer && a.IsSameConstructAs(m_Cockpit));

            m_CockpitCargoPanel             = m_Cockpit.GetSurface(CargoCheckDisplayIndex);
            m_CockpitCargoPanel.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            m_CockpitCargoPanel.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;
            m_CockpitCargoPanel.FontSize    = 2.5f;

            m_Gyros = new List <IMyGyro>();
            GridTerminalSystem.GetBlocksOfType(m_Gyros, a => a.IsSameConstructAs(m_Cockpit));

            var allBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock>(allBlocks, a => a.IsSameConstructAs(m_Cockpit));
            foreach (var block in allBlocks)
            {
                m_AllBlocks.Add(new KeyValuePair <IMyTerminalBlock, IMySlimBlock>(block, block.CubeGrid.GetCubeBlock(block.Position)));
            }

            m_Connector = GridTerminalSystem.GetBlockWithName(ConnectorName) as IMyShipConnector;

            m_Hinge = GridTerminalSystem.GetBlockWithName(ToolieHingeName) as IMyMotorStator;

            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
Ejemplo n.º 10
0
 public Program()
 {
     textSurface = Me.GetSurface(0);
     data        = Me.CustomData;
     if (isCenter)
     {
         GridTerminalSystem.GetBlocksOfType <IMyProgrammableBlock>(nodes, g => g.CustomName.Contains(likeName));
         if (nodes.Count == 0)
         {
             Echo("最少需要一个处理节点");
             return;
         }
         nodes.ForEach(g => {
             print(g.CustomData);
             if (g.CustomData != null && g.CustomData != "")
             {
                 allPB.Add(g.CustomData);
                 allPBCount.Add(g.CustomData.Split(Communication.objectDelimiter).Length);
                 print(allPB[allPB.Count - 1]);
                 print(allPBCount[allPBCount.Count - 1] + "");
             }
             else
             {
                 allPB.Add("");
                 allPBCount.Add(0);
                 print("无");
                 print("0");
             }
         });
     }
     MSG = new Communication(Me, IGC);
     Runtime.UpdateFrequency = UpdateFrequency.Update10;
     print("初始化完成");
 }
Ejemplo n.º 11
0
        public Program()
        {
            //gets all programmable blocks, where the block's name starts with "Dock"
            int hangarCount = GetAllHangars();

            Echo(String.Format("Found {0} Hangar Controllers", hangarCount));

            antenna = GridTerminalSystem.GetBlockWithName("Dock Request Antenna") as IMyRadioAntenna; //TODO: Remove specific name requrement
            if (antenna != null)
            {
                antenna.AttachedProgrammableBlock = Me.EntityId;
                listener = IGC.RegisterBroadcastListener(MESSAGE_TAG);
                listener.SetMessageCallback("REQUEST_WAITING");
            }
            logger = GridTerminalSystem.GetBlockWithName("LCD Logger") as IMyTextPanel;
            Echo(string.Format("ANTENNA FOUND: {0}", antenna != null));
            Echo(string.Format("LOGGER FOUND: {0}", logger != null));
            if (logger == null)
            {
                logger = Me.GetSurface(0);
            }
            logger.ContentType = ContentType.TEXT_AND_IMAGE;
            logger.FontSize    = FONT_SIZE;
            string loggerText = logger.GetText();

            if (!loggerText.Contains("DOCKING LOG"))
            {
                Echo("LOGGER TEXT DOES NOT INCLUDE HEADER. Only Found:\n" + loggerText);
                logger.WriteText(LOGGER_HEADER);
            }
        }
Ejemplo n.º 12
0
 public Program()
 {
     _MyTextSurface             = Me.GetSurface(0);
     _MyTextSurface.ContentType = ContentType.TEXT_AND_IMAGE;
     _MyTextSurface.Font        = "MONOSPACE";
     _MyTextSurface.WriteText("Batch Rename v1.0\nReady to serve ...");
 }
Ejemplo n.º 13
0
        private void PistonControl(string switchName, string displayNum, string pistonName, string action)
        {
            IMyButtonPanel panel   = (IMyButtonPanel)GridTerminalSystem.GetBlockWithName(switchName);
            IMyTextSurface surface = ((IMyTextSurfaceProvider)panel).GetSurface(Int32.Parse(displayNum));
            IMyPistonBase  piston  = (IMyPistonBase)GridTerminalSystem.GetBlockWithName(pistonName);

            if (action == "On/Off")
            {
                bool pistonEnabled = piston.Enabled;
                if (pistonEnabled)
                {
                    surface.BackgroundColor = Color.Red;
                }
                else
                {
                    surface.BackgroundColor = Color.Green;
                }
                piston.Enabled = !pistonEnabled;
            }
            if (action == "Reverse")
            {
                piston.Reverse();
                if (piston.Velocity < 0)
                {
                    surface.BackgroundColor = Color.Red;
                }
                else
                {
                    surface.BackgroundColor = Color.Green;
                }
            }
        }
Ejemplo n.º 14
0
 public Program()
 {
     Runtime.UpdateFrequency    = UpdateFrequency.Update100;
     drawingSurface             = Me.GetSurface(0);
     drawingSurface.ContentType = ContentType.TEXT_AND_IMAGE;
     Search();
 }
            protected override void updateDisplayImpl()
            {
                _stringBuilder.Clear();

                double distanceToPlanetSurface =
                    (getTargetingBlockPosition() - _planetPosition).Length()
                    - _nearestPlanet.getNearestPlanetOrbitRadius();

                _stringBuilder.Append(string.Format("{0} gravity:\n  ", _nearestPlanet.getNearestPlanetName()));
                _stringBuilder.Append(string.Format("{0:0.00} km", distanceToPlanetSurface / 1000));
                _stringBuilder.Append("\n");

                string text = _stringBuilder.ToString();

                foreach (IMyCockpit cockpit in _cockpits)
                {
                    IMyTextSurfaceProvider surfaceProvider = cockpit as IMyTextSurfaceProvider;
                    if (surfaceProvider.SurfaceCount > 0)
                    {
                        IMyTextSurface surface = surfaceProvider.GetSurface(0);
                        surface.ContentType = ContentType.TEXT_AND_IMAGE;
                        surface.WriteText(text);
                        surface.FontSize  = 2.3f;
                        surface.Alignment = TextAlignment.CENTER;
                    }
                }

                foreach (IMyTextPanel panel in _textPanels)
                {
                    panel.ContentType = ContentType.TEXT_AND_IMAGE;
                    panel.WriteText(text);
                    panel.FontSize  = 2.3f;
                    panel.Alignment = TextAlignment.CENTER;
                }
            }
        public Program()  // init
        {
            this.gts = GridTerminalSystem;

            //init mechanical blocks
            this.legs = new Dictionary <string, Leg>()
            {
                ["right"] = new Leg(this.gts, "Right"),
                ["left"]  = new Leg(this.gts, "Left")
            };
            this.cockpit         = this.gts.GetBlockWithName("LWE Cockpit") as IMyCockpit;
            this.cockpitLcdLarge = Me.GetSurface(0);

            this.activeMovementAction = null;

            if (!(this.legs["right"].checkValidity() && this.legs["left"].checkValidity() && this.cockpit != null))
            {
                this.cockpitLcdLarge.WriteText("one ore more of the expected mechanical components not found!\n");
                Echo("one ore more of the expected mechanical components not found!\n");
            }
            else
            {
                this.cockpitLcdLarge.WriteText("all set up!\n");
                Echo("all set up!\n");
            }
        }
Ejemplo n.º 17
0
 // Auto-setup text surface
 public void PrepareTextSurfaceForSprites(IMyTextSurface textSurface)
 {
     // Set the sprite display mode
     textSurface.ContentType = ContentType.SCRIPT;
     // Make sure no built-in script has been selected
     textSurface.Script = "";
 }
        public static void DrawScaledSpriteText(this IMyTextSurface textSurface, StringBuilder text, String fontId, Color color, Single?scale = null, TextAlignment textAlignment = TextAlignment.CENTER)
        {
            textSurface.Script      = "";
            textSurface.ContentType = ContentType.SCRIPT;

            using (var frame = textSurface.DrawFrame())
            {
                var fillArea = textSurface.TextureSize - new Vector2(textSurface.TextPadding * 2);

                if (scale == null)
                {
                    var tryScale    = 10f;
                    var currentSize = textSurface.MeasureStringInPixels(text, fontId, tryScale);

                    while (currentSize.X > fillArea.X || currentSize.Y > fillArea.Y)
                    {
                        tryScale   *= 0.9f;
                        currentSize = textSurface.MeasureStringInPixels(text, fontId, tryScale);
                    }

                    scale = tryScale;
                }

                var sprite = MySprite.CreateText(text.ToString(), fontId, color, scale.Value, textAlignment);
                sprite.Position = new Vector2(textSurface.TextPadding, textSurface.TextPadding);
                frame.Add(sprite);
            }
        }
Ejemplo n.º 19
0
        public Program()
        {
            m_MainCargoContainer  = GridTerminalSystem.GetBlockWithName(MainCargoName) as IMyCargoContainer;
            m_ToolsCargoContainer = GridTerminalSystem.GetBlockWithName(ToolsCargoName) as IMyCargoContainer;

            GridTerminalSystem.GetBlocksOfType(m_Assemblers, a => (a is IMyAssembler && a.CubeGrid == m_MainCargoContainer.CubeGrid));
            GridTerminalSystem.GetBlocksOfType(m_Refineries, a => (a is IMyRefinery && a.CubeGrid == m_MainCargoContainer.CubeGrid));

            m_MainAssembler    = m_Assemblers.First(a => a.CustomName == MainAssemblerName);
            m_MainGasGenerator = GridTerminalSystem.GetBlockWithName(MainGasGeneratorName) as IMyGasGenerator;

            m_FrontLcdOres       = GridTerminalSystem.GetBlockWithName(OresIngotsLcdName) as IMyTextSurface;
            m_FrontLcdComponents = GridTerminalSystem.GetBlockWithName(ComponentsLcdName) as IMyTextSurface;

            #region Лист заказов кроме стальных пластин
            m_OrderList = new List <MyItemType>();
            m_OrderList.Add(TypeInteriorPlate);
            m_OrderList.Add(TypeConstructionComponent);
            m_OrderList.Add(TypeMetalGrid);
            m_OrderList.Add(TypeComputer);
            m_OrderList.Add(TypeLargeTube);
            m_OrderList.Add(TypeSmallTube);
            m_OrderList.Add(TypeMotor);
            m_OrderList.Add(TypeDisplay);
            m_OrderList.Add(TypePowerCell);
            m_OrderList.Add(TypeGirder);
            m_OrderList.Add(TypeDetector);
            m_OrderList.Add(TypeRadioCommunication);
            m_OrderList.Add(TypeBulletproofGlass);
            #endregion

            Runtime.UpdateFrequency = UpdateFrequency.Update100;
        }
Ejemplo n.º 20
0
 public MyScreen(IMyTextSurface TargetSurface, char pixelValueOn, char pixelValueOff, bool mirrorX)
 {
     this.TargetSurface = TargetSurface;
     this.mirrorX       = mirrorX;
     this.pixelValueOn  = pixelValueOn;
     this.pixelValueOff = pixelValueOff;
 }
Ejemplo n.º 21
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Once;

            TerminalSystem.GetBlockWithName(this, "SBS-Console", ref ConsoleProvider);
            TerminalSystem.GetBlockWithName(this, "SBS2 Camera Nose", ref Camera);
            TerminalSystem.GetBlockWithName(this, "SBS2 Fighter Cockpit ", ref Cockpit);
            Console             = ConsoleProvider.GetSurface(0);
            Console.ContentType = ContentType.TEXT_AND_IMAGE;
            Console.Alignment   = TextAlignment.CENTER;
            ConsoleBuffers.Clear();

            Camera.EnableRaycast = true;

            UpdateType UpdatesWithArgs =
                UpdateType.Terminal |
                UpdateType.Trigger |
                UpdateType.Script |
                UpdateType.IGC;
            UpdateType UpdatesTick =
                UpdateType.Update1 |
                UpdateType.Update10 |
                UpdateType.Update100;

            UpdateEvents.Subscribers[AddArgToBuffer]           = new EventHandlerMeta(UpdatesWithArgs, "AddArgToBuffer");
            UpdateEvents.Subscribers[DumpData]                 = new EventHandlerMeta(UpdatesWithArgs, "DumpData");
            UpdateEvents.Subscribers[GetTargetData]            = new EventHandlerMeta(UpdatesWithArgs, "GetTargetData");
            UpdateEvents.Subscribers[UpdateReletiveTargetData] = new EventHandlerMeta(UpdatesTick, "UpdateReletiveTargetData");
        }
Ejemplo n.º 22
0
 public SpriteBuilder(IMyTextSurface surface)
 {
     Surface = surface;
     Color   = surface.ScriptForegroundColor;
     BGColor = surface.ScriptBackgroundColor;
     Box     = new BoundingBox2(Cursor, Cursor);
 }
Ejemplo n.º 23
0
        void initCockpit(out IMyCockpit cockpit, out IMyTextSurface topLeft, out IMyTextSurface topRight, out IMyTextSurface keyboard)
        {
            var cockpits = new List <IMyCockpit>();

            this.GridTerminalSystem.GetBlocksOfType(cockpits, c => c.CubeGrid == this.Me.CubeGrid);
            if (cockpits.Count == 0)
            {
                throw new ArgumentException("No cockpit found");
            }

            cockpit = cockpits[0];
            topLeft = topRight = keyboard = null;
            for (int i = 0; i < cockpit.SurfaceCount; ++i)
            {
                IMyTextSurface surface = cockpit.GetSurface(i);
                if (surface.DisplayName == "Top Left Screen")
                {
                    topLeft = surface;
                }
                else if (surface.DisplayName == "Top Right Screen")
                {
                    topRight = surface;
                }
                else if (surface.DisplayName == "Keyboard")
                {
                    keyboard = surface;
                }
            }
        }
Ejemplo n.º 24
0
 public SpriteBuilder(IMyTextSurface surface, Vector2 pos, float scale = 1.0f, float frame = 0) : this(surface)
 {
     Cursor     = pos;
     Box        = new BoundingBox2(Cursor, Cursor);
     Scale      = scale;
     FrameCount = frame;
 }
        public Program()
        {
            _DebugLCD             = (IMyTextSurface)GridTerminalSystem.GetBlockWithName("Debug LCD");
            _DebugLCD.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            _DebugLCD.FontSize    = 2;
            _DebugLCD.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            _RotorY = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorY");
            _RotorX = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorX");
            _RotorZ = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorZ");

            _RotorY.TargetVelocityRPM = .2f;
            _RotorX.TargetVelocityRPM = .2f;
            _RotorZ.TargetVelocityRPM = .2f;
            _RotorY.Torque            = 1500000f;
            _RotorX.Torque            = 1500000f;
            _RotorZ.Torque            = 1500000f;

            List <IMyTerminalBlock> tempList = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlockGroupWithName("Solar Panels").GetBlocksOfType <IMySolarPanel>(tempList);

            _SolarPanels = tempList.Cast <IMySolarPanel>().ToList();

            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
Ejemplo n.º 26
0
            public bool addRenderTarget(IMyTextSurface surface, RenderTargetID id, Vector2I coordinate)
            {
                if (getRenderTarget(coordinate) == null && surface != null)
                {
                    RenderTarget rt = new RenderTarget(id, coordinate);
                    rt.construct();
                    rt.setupSurface(surface);

                    // calculate surface offset
                    Vector2 offset = new Vector2(coordinate.X * rt.Size.X, coordinate.Y * rt.Size.Y);

                    // expand vd area
                    renderArea_.X      = Math.Min(renderArea_.X, offset.X);
                    renderArea_.Y      = Math.Min(renderArea_.Y, offset.Y);
                    renderArea_.Width  = Math.Max(renderArea_.Width, (coordinate.X + 1) * rt.Size.X);
                    renderArea_.Height = Math.Max(renderArea_.Height, (coordinate.Y + 1) * rt.Size.Y);

                    // add pd to list
                    renderTargets_.Add(rt);
                    reference_ = getReferenceRT();
                    return(true);
                }

                return(false);
            }
Ejemplo n.º 27
0
            public Surface(IMyTextSurface textSurface, RectangleF viewRect)
            {
                TextSurface = textSurface;
                ViewRect    = viewRect;

                ConfigurePanel();
            }
Ejemplo n.º 28
0
        public Program()
        {
            cockpit = GridTerminalSystem.GetBlockWithName(NAME_COCKPIT) as IMyCockpit;
            if (cockpit != null)
            {
                Echo("init OK");
                Echo("SurfaceCount: " + cockpit.SurfaceCount);

                lcd             = cockpit.GetSurface(0); // or 1
                lcd.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;

                Echo("OxygenCapacity: " + cockpit.OxygenCapacity);
                Echo("OxygenFilledRatio: " + cockpit.OxygenFilledRatio);

                // гравитация, вектор указывает на центр планеты
                Vector3D gravityVector = cockpit.GetNaturalGravity();
                stringBuilder.Append("\ngravityVector: ").Append(gravityVector.Length())
                .Append("\n  X: ").Append(gravityVector.X)
                .Append("\n  Y:").Append(gravityVector.Y)
                .Append("\n  Z:").Append(gravityVector.Z);
                Echo(stringBuilder.ToString());

                // масса корабля
                float PhysicalMass = cockpit.CalculateShipMass().PhysicalMass;
                Echo("PhysicalMass: " + PhysicalMass);

                Runtime.UpdateFrequency = UpdateFrequency.Update1;
            }
            else
            {
                Echo("init ERROR");
            }
        }
Ejemplo n.º 29
0
        private static IMyTextSurface FindDisplay(string DisplayName, IMyGridTerminalSystem gts, IMyTerminalBlock anyBlock)
        {
            IMyTextSurface TextSurface = null;

            int x = DisplayName.IndexOf('(');

            if (x == -1)
            {
                TextSurface = FindBlockOfType <IMyTextSurface>(DisplayName, gts, anyBlock);
            }
            else
            {
                string mName = DisplayName.Substring(0, x);
                IMyTextSurfaceProvider sp = FindBlockOfType <IMyTextSurfaceProvider>(mName, gts, anyBlock);
                if (sp != null)
                {
                    int    y         = DisplayName.IndexOf(')');
                    string indexStr  = DisplayName.Substring(x + 1, y - x - 1).Trim();
                    int    surfIndex = int.Parse(indexStr);
                    TextSurface = sp.GetSurface(surfIndex);
                }
            }

            return(TextSurface);
        }
Ejemplo n.º 30
0
            public void setupSurface(IMyTextSurface surface)
            {
                surface_             = surface;
                surface_.Script      = "";
                surface_.ContentType = ContentType.SCRIPT;
                surface_.Font        = Default.Font;
                surface_.FontSize    = 1f;
                surface_.TextPadding = 0f;

                BackgroundColor = Color.Black;

                RectangleF rect;

                if (!RenderTargetID.tryGetFixed(ID, out rect))
                {
                    Size     = surface_.SurfaceSize;
                    Position = (surface_.TextureSize - Size) * 0.5f;
                }
                else
                {
                    Size     = rect.Size;
                    Position = rect.Position;
                }

                DisplayOffset = -(Size * Coordinate) + Position;

                if (RenderTarget.sprites_.Count == 0)
                {
                    surface_.GetSprites(RenderTarget.sprites_);
                }

                drawInitScreen();
            }