Esempio n. 1
0
            public StaticVariables()
            {
                Logger.DebugLog("entered", Logger.severity.TRACE);
                TerminalControlHelper.EnsureTerminalControlCreated <MyProgrammableBlock>();

                MyTerminalAction <MyProgrammableBlock> programmable_sendMessage = new MyTerminalAction <MyProgrammableBlock>("SendMessage", new StringBuilder("Send Message"), "Textures\\GUI\\Icons\\Actions\\Start.dds")
                {
                    ValidForGroups       = false,
                    ActionWithParameters = ProgrammableBlock_SendMessage
                };

                programmable_sendMessage.ParameterDefinitions.Add(Ingame.TerminalActionParameter.Get(string.Empty));
                programmable_sendMessage.ParameterDefinitions.Add(Ingame.TerminalActionParameter.Get(string.Empty));
                programmable_sendMessage.ParameterDefinitions.Add(Ingame.TerminalActionParameter.Get(string.Empty));
                MyTerminalControlFactory.AddAction(programmable_sendMessage);

                MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyProgrammableBlock>());

                handleDetected = new MyTerminalControlOnOffSwitch <MyProgrammableBlock>("HandleDetected", MyStringId.GetOrCompute("Handle Detected"));
                new ValueSync <bool, ProgrammableBlock>(handleDetected, (prog) => prog.value_handleDetectedTerminal, (prog, value) => prog.value_handleDetectedTerminal = value);
                MyTerminalControlFactory.AddControl(handleDetected);

                blockCountList = new MyTerminalControlTextbox <MyProgrammableBlock>("BlockCounts", MyStringId.GetOrCompute("Blocks to Count"), MyStringId.GetOrCompute("Comma separated list of blocks to count"));
                new StringBuilderSync <ProgrammableBlock>(blockCountList, (prog) => prog.value_blockCountList, (prog, value) => {
                    prog.value_blockCountList = value;
                    prog.m_blockCountList_btl = new BlockTypeList(prog.m_blockCountList_sb.ToString().LowerRemoveWhitespace().Split(','));
                });
                MyTerminalControlFactory.AddControl(blockCountList);
            }
Esempio n. 2
0
        private static void CreateTerminal()
        {
            Logger.DebugLog("entered", Logger.severity.TRACE);
            TerminalControlHelper.EnsureTerminalControlCreated <MySolarPanel>();
            TerminalControlHelper.EnsureTerminalControlCreated <MyOxygenFarm>();

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MySolarPanel>());
            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyOxygenFarm>());

            MyTerminalControlCheckbox <MyTerminalBlock> s_termControl_faceSun = new MyTerminalControlCheckbox <MyTerminalBlock>("FaceSun", MyStringId.GetOrCompute("Face Sun"), MyStringId.GetOrCompute("Face this block towards the sun"));

            new ValueSync <bool, Solar>(s_termControl_faceSun, (script) => script.m_termControl_faceSun, (script, value) => script.m_termControl_faceSun = value);

            MyTerminalControlFactory.AddControl <MyTerminalBlock, MySolarPanel>(s_termControl_faceSun);
            MyTerminalControlFactory.AddControl <MyTerminalBlock, MyOxygenFarm>(s_termControl_faceSun);
        }
Esempio n. 3
0
        private static void CreateTerminal()
        {
            Logger.DebugLog("entered", Logger.severity.TRACE);
            TerminalControlHelper.EnsureTerminalControlCreated <MyTextPanel>();

            MyTerminalAction <MyTextPanel> textPanel_displayEntities = new MyTerminalAction <MyTextPanel>("DisplayEntities", new StringBuilder("Display Entities"), "Textures\\GUI\\Icons\\Actions\\Start.dds")
            {
                ValidForGroups       = false,
                ActionWithParameters = TextPanel_DisplayEntities
            };

            MyTerminalControlFactory.AddAction(textPanel_displayEntities);

            MyTerminalControlFactory.AddControl(new MyTerminalControlSeparator <MyTextPanel>());

            AddCheckbox("DisplayDetected", "Display Detected", "Write detected entities to the public text of the panel", Option.DisplayDetected);
            AddCheckbox("DisplayGPS", "Display GPS", "Write gps with detected entities", Option.GPS);
            AddCheckbox("DisplayEntityId", "Display Entity ID", "Write entity ID with detected entities", Option.EntityId);
            AddCheckbox("DisplayAutopilotStatus", "Display Autopilot Status", "Write the status of nearby Autopilots to the public text of the panel", Option.AutopilotStatus);
        }
Esempio n. 4
0
        private static void HijackShoot()
        {
            TerminalControlHelper.EnsureTerminalControlCreated <MySmallMissileLauncher>();
            Func <object, bool> False = (o) => false;

            foreach (ITerminalControl control in MyTerminalControlFactory.GetControls(typeof(MyUserControllableGun)))
            {
                if (control.Id == "ShootOnce")
                {
                    MyTerminalControlButton <MyUserControllableGun> shootOnce = (MyTerminalControlButton <MyUserControllableGun>)control;
                    EventSync <GuidedMissileLauncher> termControl_shootOnce   = new EventSync <GuidedMissileLauncher>(shootOnce.Id, ShootOnceEvent, false);

                    Action <MyUserControllableGun> originalAction = shootOnce.Action;
                    shootOnce.Action = block => {
                        if (IsGuidedMissileLauncher(block))
                        {
                            termControl_shootOnce.RunEvent(block);
                        }
                        else
                        {
                            originalAction(block);
                        }
                    };

                    shootOnce.Actions[0].Action = shootOnce.Action;
                }
                else if (control.Id == "Shoot")
                {
                    MyTerminalControlOnOffSwitch <MyUserControllableGun> shoot = (MyTerminalControlOnOffSwitch <MyUserControllableGun>)control;
                    termControl_shoot = new ValueSync <bool, GuidedMissileLauncher>(shoot.Id, "value_termShoot");

                    var originalGetter = shoot.Getter;
                    var originalSetter = shoot.Setter;
                    shoot.Getter = (block) => {
                        if (IsGuidedMissileLauncher(block))
                        {
                            return(termControl_shoot.GetValue(block));
                        }
                        else
                        {
                            return(originalGetter(block));
                        }
                    };
                    shoot.Setter = (block, value) => {
                        if (IsGuidedMissileLauncher(block))
                        {
                            Logger.TraceLog("Set shoot: " + value);
                            termControl_shoot.SetValue(block, value);
                        }
                        else
                        {
                            originalSetter(block, value);
                        }
                    };

                    shoot.Actions[0].Action = block => shoot.SetValue(block, !shoot.GetValue(block));   // toggle
                    shoot.Actions[1].Action = block => shoot.SetValue(block, true);                     // on
                    shoot.Actions[2].Action = block => shoot.SetValue(block, false);                    // off
                    break;
                }
            }
        }
Esempio n. 5
0
            public StaticVariables()
            {
                Logger.DebugLog("entered", Logger.severity.TRACE);
                MyAPIGateway.Session.DamageSystem.RegisterAfterDamageHandler((int)MyDamageSystemPriority.Low, AfterDamageHandler);

                TerminalControlHelper.EnsureTerminalControlCreated <MySpaceProjector>();

                TermControls.Add(new MyTerminalControlSeparator <MySpaceProjector>());

                AddCheckbox("HoloDisplay", "Holographic Display", "Holographically display this ship and nearby detected ships", Option.OnOff);
                AddCheckbox("HD_This_Ship", "This Ship", "Holographically display this ship", Option.ThisShip);
                AddCheckbox("HD_Owner", "Owned Ships", "Holographically display ships owned by this block's owner", Option.Owner);
                AddCheckbox("HD_Faction", "Faction Ships", "Holographically display faction owned ships", Option.Faction);
                AddCheckbox("HD_Neutral", "Neutral Ships", "Holographically display neutral ships", Option.Neutral);
                AddCheckbox("HD_Enemy", "Enemy Ships", "Holographically display enemy ships", Option.Enemy);

                MyTerminalControlSlider <MySpaceProjector> slider = new MyTerminalControlSlider <MySpaceProjector>("HD_RangeDetection", MyStringId.GetOrCompute("Detection Range"), MyStringId.GetOrCompute("Maximum distance of detected entity"));
                ValueSync <float, Projector> tvsRange             = new ValueSync <float, Projector>(slider, (proj) => proj.m_rangeDetection, (proj, value) => proj.m_rangeDetection = value);

                slider.DefaultValue = DefaultRangeDetection;
                slider.Normalizer   = (block, value) => Normalizer(MinRangeDetection, MaxRangeDetection, block, value);
                slider.Denormalizer = (block, value) => Denormalizer(MinRangeDetection, MaxRangeDetection, block, value);
                slider.Writer       = (block, sb) => WriterMetres(tvsRange.GetValue(block), sb);
                TermControls.Add(slider);

                slider = new MyTerminalControlSlider <MySpaceProjector>("HD_RadiusHolo", MyStringId.GetOrCompute("Hologram Radius"), MyStringId.GetOrCompute("Maximum radius of hologram"));
                ValueSync <float, Projector> tvsRadius = new ValueSync <float, Projector>(slider, (proj) => proj.m_radiusHolo, (proj, value) => proj.m_radiusHolo = value);

                slider.DefaultValue = DefaultRadiusHolo;
                slider.Normalizer   = (block, value) => Normalizer(MinRadiusHolo, MaxRadiusHolo, block, value);
                slider.Denormalizer = (block, value) => Denormalizer(MinRadiusHolo, MaxRadiusHolo, block, value);
                slider.Writer       = (block, sb) => WriterMetres(tvsRadius.GetValue(block), sb);
                TermControls.Add(slider);

                slider = new MyTerminalControlSlider <MySpaceProjector>("HD_EntitySizeScale", MyStringId.GetOrCompute("Entity Size Scale"), MyStringId.GetOrCompute("Larger value causes entities to appear larger"));
                ValueSync <float, Projector> tvsScale = new ValueSync <float, Projector>(slider, (proj) => proj.m_sizeDistScale, (proj, value) => proj.m_sizeDistScale = value);

                slider.DefaultValue = DefaultSizeScale;
                slider.Normalizer   = (block, value) => Normalizer(MinSizeScale, MaxSizeScale, block, value);
                slider.Denormalizer = (block, value) => Denormalizer(MinSizeScale, MaxSizeScale, block, value);
                slider.Writer       = (block, sb) => sb.Append(tvsScale.GetValue(block));
                TermControls.Add(slider);

                TermControls.Add(new MyTerminalControlSeparator <MySpaceProjector>());

                MyTerminalControlCheckbox <MySpaceProjector> control = new MyTerminalControlCheckbox <MySpaceProjector>("HD_MouseControls", MyStringId.GetOrCompute("Mouse Controls"),
                                                                                                                        MyStringId.GetOrCompute("Allow manipulation of hologram with mouse. User-specific setting."));
                IMyTerminalValueControl <bool> valueControlBool = control;

                valueControlBool.Getter = block => MouseControls;
                valueControlBool.Setter = (block, value) => MouseControls = value;
                TermControls.Add(control);

                control                 = new MyTerminalControlCheckbox <MySpaceProjector>("HD_ShowBoundary", MyStringId.GetOrCompute("Show Boundary"), MyStringId.GetOrCompute("Show the boundaries of the hologram. User-specific setting."));
                valueControlBool        = control;
                valueControlBool.Getter = block => ShowBoundary;
                valueControlBool.Setter = (block, value) => ShowBoundary = value;
                TermControls.Add(control);

                control        = new MyTerminalControlCheckbox <MySpaceProjector>("HD_ShowOffset", MyStringId.GetOrCompute("Show Offset Controls"), MyStringId.GetOrCompute("Display controls that can be used to adjust the position of the hologram. User-specific setting."));
                control.Getter = block => ShowOffset;
                control.Setter = (block, value) => {
                    ShowOffset = value;
                    block.RebuildControls();
                };
                TermControls.Add(control);

                AddOffsetSlider("HD_OffsetX", "Right/Left Offset", "+ve moves hologram to the right, -ve moves hologram to the left", 0);
                AddOffsetSlider("HD_OffsetY", "Up/Down Offset", "+ve moves hologram up, -ve moves hologram down", 1);
                AddOffsetSlider("HD_OffsetZ", "Back/Fore Offset", "+ve moves hologram back, -ve moves hologram forward", 2);

                TermControls_Offset.Add(new MyTerminalControlSeparator <MySpaceProjector>());

                AddCheckbox("HD_IntegrityColour", "Colour by Integrity", "Colour blocks according to their integrities", Option.IntegrityColours);

                IMyTerminalControlColor colour = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyProjector>("HD_FullIntegriyColour");

                colour.Title   = MyStringId.GetOrCompute("Whole");
                colour.Tooltip = MyStringId.GetOrCompute("Colour when block has full integrity. User-specific setting.");
                colour.Getter  = (block) => IntegrityFull;
                colour.Setter  = (block, value) => IntegrityFull = value;
                TermControls_Colours.Add(colour);

                colour         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyProjector>("HD_CriticalIntegriyColour");
                colour.Title   = MyStringId.GetOrCompute("Func.");
                colour.Tooltip = MyStringId.GetOrCompute("Colour when block is just above critical integrity. User-specific setting.");
                colour.Getter  = (block) => IntegrityFunctional;
                colour.Setter  = (block, value) => IntegrityFunctional = value;
                TermControls_Colours.Add(colour);

                colour         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyProjector>("HD_CriticalIntegriyColour");
                colour.Title   = MyStringId.GetOrCompute("Broken");
                colour.Tooltip = MyStringId.GetOrCompute("Colour when block is just below critical integrity. User-specific setting.");
                colour.Getter  = (block) => IntegrityDamaged;
                colour.Setter  = (block, value) => IntegrityDamaged = value;
                TermControls_Colours.Add(colour);

                colour         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlColor, IMyProjector>("HD_ZeroIntegriyColour");
                colour.Title   = MyStringId.GetOrCompute("Razed");
                colour.Tooltip = MyStringId.GetOrCompute("Colour when block has zero integrity. User-specific setting.");
                colour.Getter  = (block) => IntegrityZero;
                colour.Setter  = (block, value) => IntegrityZero = value;
                TermControls_Colours.Add(colour);

                new ValueSync <long, Projector>("CentreEntity",
                                                (script) => script.m_centreEntityId,
                                                (script, value) => {
                    script.m_centreEntityId = value;
                    script.m_centreEntityId_AfterValueChanged();
                });
            }
Esempio n. 6
0
            public StaticVariables()
            {
                Logger.DebugLog("entered", Logger.severity.TRACE);
                TerminalControlHelper.EnsureTerminalControlCreated <MyCockpit>();
                TerminalControlHelper.EnsureTerminalControlCreated <MyRemoteControl>();

                AddControl(new MyTerminalControlSeparator <MyShipController>()
                {
                    Enabled = ShipAutopilot.IsAutopilotBlock, Visible = ShipAutopilot.IsAutopilotBlock
                });

                autopilotControl = new MyTerminalControlCheckbox <MyShipController>("ArmsAp_OnOff", MyStringId.GetOrCompute("ARMS Autopilot"), MyStringId.GetOrCompute("Enable ARMS Autopilot"));
                new ValueSync <bool, AutopilotTerminal>(autopilotControl, "value_autopilotControl");
                AddControl(autopilotControl);
                AddAction(new MyTerminalAction <MyShipController>("ArmsAp_OnOff", new StringBuilder("ARMS Autopilot On/Off"), @"Textures\GUI\Icons\Actions\Toggle.dds")
                {
                    Action = ToggleAutopilotControl
                });
                AddAction(new MyTerminalAction <MyShipController>("ArmsAp_On", new StringBuilder("ARMS Autopilot On"), @"Textures\GUI\Icons\Actions\SwitchOn.dds")
                {
                    Action = block => SetAutopilotControl(block, true)
                });
                AddAction(new MyTerminalAction <MyShipController>("ArmsAp_Off", new StringBuilder("ARMS Autopilot Off"), @"Textures\GUI\Icons\Actions\SwitchOff.dds")
                {
                    Action = block => SetAutopilotControl(block, false)
                });

                autopilotCommands = new MyTerminalControlTextbox <MyShipController>("ArmsAp_Commands", MyStringId.GetOrCompute("Autopilot Commands"), MyStringId.NullOrEmpty);
                new StringBuilderSync <AutopilotTerminal>(autopilotCommands, (autopilot) => autopilot.value_autopilotCommands, (autopilot, value) => {
                    autopilot.value_autopilotCommands = value;
                    AutopilotCommands.GetOrCreate(autopilot.m_block)?.OnCommandsChanged();
                });
                AddControl(autopilotCommands);

                MyTerminalControlButton <MyShipController> gooeyProgram = new MyTerminalControlButton <MyShipController>("ArmsAp_GuiProgram", MyStringId.GetOrCompute("Program Autopilot"), MyStringId.GetOrCompute("Interactive programming for autopilot"), GooeyProgram);

                gooeyProgram.Enabled = ShipAutopilot.IsAutopilotBlock;
                AddControl(gooeyProgram);

                AddPropertyAndSync <ShipAutopilot.State, Enum>("ArmsAp_Status", out autopilotStatus, "value_autopilotStatus");

                FieldInfo value_autopilotFlags = typeof(AutopilotTerminal).GetField("value_autopilotFlags", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                autopilotFlags = new ValueSync <AutopilotFlags, AutopilotTerminal>("ArmsAp_AutopilotFlags", GenerateGetter <AutopilotFlags>(value_autopilotFlags), GenerateSetter <AutopilotFlags>(value_autopilotFlags), false);
                foreach (AutopilotFlags flag in Enum.GetValues(typeof(AutopilotFlags)))
                {
                    if (flag != 0)
                    {
                        AddPropertyAndSync(flag);
                    }
                }

                AddPropertyAndSync <Pathfinder.State, Enum>("ArmsAp_PathStatus", out pathfinderState, "value_pathfinderState");
                AddPropertyAndSync <GridFinder.ReasonCannotTarget, Enum>("ArmsAp_ReasonCannotTarget", out reasonCannotTarget, "value_reasonCannotTarget");
                AddPropertyAndSync <InfoString.StringId, Enum>("ArmsAp_Complaint", out complaint, "value_complaint");
                AddPropertyAndSync <InfoString.StringId_Jump, Enum>("ArmsAp_JumpComplaint", out jumpComplaint, "value_jumpComplaint");
                AddPropertyAndSync("ArmsAp_WaitUntil", out waitUntil, "value_waitUntil");
                AddPropertyAndSyncEntityId("ArmsAp_BlockedBy", out blockedBy, "value_blockedBy");

                FieldInfo value_distance = typeof(AutopilotTerminal).GetField("value_distance", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                distance = new ValueSync <long, AutopilotTerminal>("ArmsAp_Distance", GenerateGetter <long>(value_distance), GenerateSetter <long>(value_distance), false);
                MyTerminalControlProperty <MyShipController, float> linearDistance = new MyTerminalControlProperty <MyShipController, float>("ArmsAp_LinearDistance")
                {
                    Getter = GetLinearDistance
                };

                AddControl(linearDistance, false);
                MyTerminalControlProperty <MyShipController, float> angularDistance = new MyTerminalControlProperty <MyShipController, float>("ArmsAp_AngularDistance")
                {
                    Getter = GetAngularDistance
                };

                AddControl(angularDistance, false);

                AddPropertyAndSyncEntityId("ArmsAp_EnemyFinderBestTarget", out enemyFinderBestTarget, "value_enemyFinderBestTarget");
                AddPropertyAndSync("ArmsAp_WelderUnfinishedBlocks", out welderUnfinishedBlocks, "value_welderUnfinishedBlocks");
                AddPropertyAndSync("ArmsAp_NavigatorMover", out prevNavMover, "value_prevNavMover");
                AddPropertyAndSync("ArmsAp_NavigatorRotator", out prevNavRotator, "value_prevNavRotator");
                AddPropertyAndSync("ArmsAp_NavigatorMoverInfo", out prevNavMoverInfo, "value_prevNavMoverInfo");
                AddPropertyAndSync("ArmsAp_NavigatorRotatorInfo", out prevNavRotatorInfo, "value_prevNavRotatorInfo");
            }