Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Sandbox.Game.EntityComponents;
- using Sandbox.ModAPI.Ingame;
- using Sandbox.ModAPI.Interfaces;
- using SpaceEngineers.Game.ModAPI.Ingame;
- using System.Collections.Generic;
- using System.Collections;
- using System.Linq;
- using System.Text;
- using System;
- using VRage.Collections;
- using VRage.Game.Components;
- using VRage.Game.GUI.TextPanel;
- using VRage.Game.ModAPI.Ingame.Utilities;
- using VRage.Game.ModAPI.Ingame;
- using VRage.Game.ObjectBuilders.Definitions;
- using VRage.Game;
- using VRage;
- using VRageMath;
- namespace IngameScript
- {
- partial class Program : MyGridProgram
- {
- IMyTextSurface _drawingSurface;
- RectangleF _viewport;
- public Program()
- {
- // The constructor, called only once every session and
- // always before any other method is called. Use it to
- // initialize your script.
- //
- // The constructor is optional and can be removed if not
- // needed.
- //
- // It's recommended to set Runtime.UpdateFrequency
- // here, which will allow your script to run itself without a
- // timer block.
- _drawingSurface = Me.GetSurface(0);
- Runtime.UpdateFrequency = UpdateFrequency.Update100;
- _viewport = new RectangleF(
- (_drawingSurface.TextureSize - _drawingSurface.SurfaceSize) / 2f,
- _drawingSurface.SurfaceSize
- );
- }
- public void Save()
- {
- }
- public void Main(string argument, UpdateType updateSource)
- {
- var position = new Vector2(256, 20) + _viewport.Position;
- var frame = _drawingSurface.DrawFrame();
- List<IMySolarPanel> solarPanels = new List<IMySolarPanel>();
- GridTerminalSystem.GetBlocksOfType(solarPanels);
- int i = 1;
- foreach(IMySolarPanel p in solarPanels)
- {
- var sprite = new MySprite()
- {
- Type = SpriteType.TEXT,
- Data = "Solar[" + i + "] - " + p.CurrentOutput +"/" + p.MaxOutput + "MW (" + ((int)(p.CurrentOutput/p.MaxOutput*100.0)*1000)/1000.0 + "%)",
- Position = position,
- RotationOrScale = 0.8f /* 80 % of the font's default size */,
- Color = Color.Red,
- Alignment = TextAlignment.CENTER /* Center the text on the position */,
- FontId = "White"
- };
- frame.Add(sprite);
- position += new Vector2(0, 20);
- i++;
- }
- frame.Dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement