Ejemplo n.º 1
0
        private void UnRenamePrefix(string tag)
        {
            BlockSystem <IMyTerminalBlock> blocks = BlockSystem <IMyTerminalBlock> .SearchBlocks(this);

            blocks.ForEach(delegate(IMyTerminalBlock block)
            {
                if (block.CustomName.StartsWith(tag))
                {
                    block.CustomName = block.CustomName.Replace(tag + " ", "");
                }
            });
        }
Ejemplo n.º 2
0
        private void Prepare()
        {
            stators = BlockSystem <IMyMotorStator> .SearchByTag(this, MyProperty.Search_Rotor);

            pistonUp = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Up);

            pistonDown = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Down);

            pistonRayon = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Rayon);

            drills = BlockSystem <IMyShipDrill> .SearchBlocks(this);

            SetTargetValues();
        }
Ejemplo n.º 3
0
        private void Display()
        {
            WriteText($"Machine Mode:{Mode}", false);
            WriteText($"Machine Cycle:{Cycle}", true);
            if (Sequence != null && Sequence.Count > Stage)
            {
                WriteText($"Machine Action:{Sequence[Stage]}", true);
            }
            WriteText($"Machine Stage:{Stage}", true);
            BlockSystem <IMyShipConnector> connectors = BlockSystem <IMyShipConnector> .SearchBlocks(this);

            float deep = MyProperty.elevator_position_max * connectors.List.Count;

            WriteText($"Machine Deep:{deep}", true);
        }
Ejemplo n.º 4
0
            private void Search()
            {
                cockpit = BlockSystem <IMyCockpit> .SearchBlocks(DisplayLcd.program);

                thrusts_up = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Up");

                thrusts_down = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Down");

                thrusts_left = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Left");

                thrusts_right = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Right");

                thrusts_forward = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Forward");

                thrusts_backward = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Backward");

                search = false;
            }
Ejemplo n.º 5
0
            public Vector2 Draw(Drawing drawing, Vector2 position)
            {
                if (!enable)
                {
                    return(position);
                }
                List <string> types = new List <string>();

                if (tank_h2)
                {
                    types.Add("Hydrogen");
                }
                if (tank_o2)
                {
                    types.Add("Oxygen");
                }
                if (types.Count > 0)
                {
                    foreach (string type in types)
                    {
                        BlockSystem <IMyGasTank> tanks = BlockSystem <IMyGasTank> .SearchBlocks(DisplayLcd.program, block => block.BlockDefinition.SubtypeName.Contains(type));

                        float      volumes  = 0f;
                        float      capacity = 0f;
                        float      width    = 50f;
                        StyleGauge style    = new StyleGauge()
                        {
                            Orientation     = SpriteOrientation.Horizontal,
                            Fullscreen      = true,
                            Width           = width,
                            Height          = width,
                            Padding         = new StylePadding(0),
                            Round           = false,
                            RotationOrScale = 0.5f
                        };

                        MySprite text = new MySprite()
                        {
                            Type            = SpriteType.TEXT,
                            Color           = Color.DimGray,
                            Position        = position + new Vector2(0, 0),
                            RotationOrScale = 1f,
                            FontId          = drawing.Font,
                            Alignment       = TextAlignment.LEFT
                        };

                        tanks.ForEach(delegate(IMyGasTank block)
                        {
                            volumes  += (float)block.FilledRatio * block.Capacity;
                            capacity += block.Capacity;
                        });

                        drawing.DrawGauge(position, volumes, capacity, style);
                        position += new Vector2(0, 60);
                        switch (type)
                        {
                        case "Hydrogen":
                            text.Data = $"H2: {Math.Round(volumes, 2)}L / {Math.Round(capacity, 2)}L";
                            break;

                        case "Oxygen":
                            text.Data = $"O2: {Math.Round(volumes, 2)}L / {Math.Round(capacity, 2)}L";
                            break;
                        }
                        text.Position = position;
                        drawing.AddSprite(text);
                        position += new Vector2(0, 60);
                    }
                }
                return(position);
            }
Ejemplo n.º 6
0
 public static BlockSystem <T> SearchByName(Program program, string name)
 {
     return(BlockSystem <T> .SearchBlocks(program, block => ((IMyTerminalBlock)block).CustomName.Equals(name), name));
 }
Ejemplo n.º 7
0
 public static BlockSystem <T> SearchByTag(Program program, string tag)
 {
     return(BlockSystem <T> .SearchBlocks(program, block => ((IMyTerminalBlock)block).CustomName.Contains(tag), tag));
 }
Ejemplo n.º 8
0
 public static BlockSystem <T> SearchByGrid(Program program, IMyCubeGrid cubeGrid)
 {
     return(BlockSystem <T> .SearchBlocks(program, block => ((IMyTerminalBlock)block).CubeGrid == cubeGrid));
 }
Ejemplo n.º 9
0
            public Vector2 Draw(Drawing drawing, Vector2 position)
            {
                if (!enable)
                {
                    return(position);
                }
                BlockSystem <IMyTerminalBlock> producers = BlockSystem <IMyTerminalBlock> .SearchBlocks(DisplayLcd.program, block => block.Components.Has <MyResourceSourceComponent>());

                BlockSystem <IMyTerminalBlock> consummers = BlockSystem <IMyTerminalBlock> .SearchBlocks(DisplayLcd.program, block => block.Components.Has <MyResourceSinkComponent>());

                Dictionary <string, Power> outputs = new Dictionary <string, Power>();
                Power batteries_store = new Power()
                {
                    Type = "Batteries"
                };

                outputs.Add("all", new Power()
                {
                    Type = "All"
                });
                float      current_input = 0f;
                float      max_input     = 0f;
                float      width         = 30f;
                StyleGauge style         = new StyleGauge()
                {
                    Orientation     = SpriteOrientation.Horizontal,
                    Fullscreen      = true,
                    Width           = width,
                    Height          = width,
                    Padding         = new StylePadding(0),
                    Round           = false,
                    RotationOrScale = 0.5f
                };

                MySprite text = new MySprite()
                {
                    Type            = SpriteType.TEXT,
                    Color           = Color.DimGray,
                    Position        = position + new Vector2(0, 0),
                    RotationOrScale = .6f,
                    FontId          = drawing.Font,
                    Alignment       = TextAlignment.LEFT
                };

                producers.ForEach(delegate(IMyTerminalBlock block)
                {
                    string type = block.BlockDefinition.SubtypeName;
                    if (block is IMyBatteryBlock)
                    {
                        IMyBatteryBlock battery = (IMyBatteryBlock)block;
                        batteries_store.AddCurrent(battery.CurrentStoredPower);
                        batteries_store.AddMax(battery.MaxStoredPower);
                    }
                    else
                    {
                        MyResourceSourceComponent resourceSource;
                        block.Components.TryGet <MyResourceSourceComponent>(out resourceSource);
                        if (resourceSource != null)
                        {
                            ListReader <MyDefinitionId> myDefinitionIds = resourceSource.ResourceTypes;
                            if (myDefinitionIds.Contains(PowerDefinitionId))
                            {
                                Power global_output = outputs["all"];
                                global_output.AddCurrent(resourceSource.CurrentOutputByType(PowerDefinitionId));
                                global_output.AddMax(resourceSource.MaxOutputByType(PowerDefinitionId));

                                if (!outputs.ContainsKey(type))
                                {
                                    outputs.Add(type, new Power()
                                    {
                                        Type = type
                                    });
                                }
                                Power current_output = outputs[type];
                                current_output.AddCurrent(resourceSource.CurrentOutputByType(PowerDefinitionId));
                                current_output.AddMax(resourceSource.MaxOutputByType(PowerDefinitionId));
                            }
                        }
                    }
                });

                drawing.DrawGauge(position, outputs["all"].Current, outputs["all"].Max, style);

                foreach (KeyValuePair <string, Power> kvp in outputs)
                {
                    string title = kvp.Key;

                    position += new Vector2(0, 40);
                    if (kvp.Key.Equals("all"))
                    {
                        text.Data = $"Global Generator\n Out: {Math.Round(kvp.Value.Current, 2)}MW / {Math.Round(kvp.Value.Max, 2)}MW";
                    }
                    else
                    {
                        text.Data  = $"{title} (n={kvp.Value.Count})\n";
                        text.Data += $" Out: {Math.Round(kvp.Value.Current, 2)}MW / {Math.Round(kvp.Value.Max, 2)}MW";
                        text.Data += $" (Moy={kvp.Value.Moyen}MW)";
                    }
                    text.Position = position;
                    drawing.AddSprite(text);
                }

                position += new Vector2(0, 40);
                drawing.DrawGauge(position, batteries_store.Current, batteries_store.Max, style, true);
                position     += new Vector2(0, 40);
                text.Data     = $"Battery Store (n={batteries_store.Count})\n Store: {Math.Round(batteries_store.Current, 2)}MW / {Math.Round(batteries_store.Max, 2)}MW";
                text.Position = position;
                drawing.AddSprite(text);

                consummers.ForEach(delegate(IMyTerminalBlock block)
                {
                    if (block is IMyBatteryBlock)
                    {
                    }
                    else
                    {
                        MyResourceSinkComponent resourceSink;
                        block.Components.TryGet <MyResourceSinkComponent>(out resourceSink);
                        if (resourceSink != null)
                        {
                            ListReader <MyDefinitionId> myDefinitionIds = resourceSink.AcceptedResources;
                            if (myDefinitionIds.Contains(PowerDefinitionId))
                            {
                                max_input     += resourceSink.RequiredInputByType(PowerDefinitionId);
                                current_input += resourceSink.CurrentInputByType(PowerDefinitionId);
                            }
                        }
                    }
                });
                position += new Vector2(0, 40);
                drawing.DrawGauge(position, current_input, max_input, style, true);
                position     += new Vector2(0, 40);
                text.Data     = $"Power In: {Math.Round(current_input, 2)}MW / {Math.Round(max_input, 2)}MW";
                text.Position = position;
                drawing.AddSprite(text);

                return(position + new Vector2(0, 60));
            }