private IMyTerminalControlProperty <IReadOnlyList <ListOfBlocks> > LastOperatedProjectedGridBlocks()
        {
            IMyTerminalControlProperty <IReadOnlyList <ListOfBlocks> > LastOperatedProjectedGridBlocks = MyAPIGateway.TerminalControls.CreateProperty <IReadOnlyList <ListOfBlocks>, IMyShipWelder>("TargetProjectedGridsBlocks");

            LastOperatedProjectedGridBlocks.Enabled = Block => HasBlockLogic(Block);
            LastOperatedProjectedGridBlocks.Getter  = LastOperatedProjectedGridBlocks_Getter;
            LastOperatedProjectedGridBlocks.Setter  = DefaultInvalidPropertySetter;

            return(LastOperatedProjectedGridBlocks);
        }
        public IMyTerminalControlProperty <IReadOnlyDictionary <MyItemType, float> > MissingComponents()
        {
            IMyTerminalControlProperty <IReadOnlyDictionary <MyItemType, float> > MissingComponents = MyAPIGateway.TerminalControls.CreateProperty <IReadOnlyDictionary <MyItemType, float>, IMyShipWelder>("MissingComponents");

            MissingComponents.Enabled = Block => HasBlockLogic(Block);
            MissingComponents.Getter  = MissingComponents_Getter;
            MissingComponents.Setter  = DefaultInvalidPropertySetter;

            return(MissingComponents);
        }
        private IMyTerminalControlProperty <IReadOnlyList <long> > LastOperatedGrid()
        {
            IMyTerminalControlProperty <IReadOnlyList <long> > LastOperatedGrid = MyAPIGateway.TerminalControls.CreateProperty <IReadOnlyList <long>, IMyShipWelder>("TargetGrids");

            LastOperatedGrid.Enabled = Block => HasBlockLogic(Block);
            LastOperatedGrid.Getter  = LastOperatedGrid_Getter;
            LastOperatedGrid.Setter  = DefaultInvalidPropertySetter;

            return(LastOperatedGrid);
        }
Beispiel #4
0
        private void create_PB_property <_type_, _block_>(string id, Func <IMyTerminalBlock, _type_> getter, Action <IMyTerminalBlock, _type_> setter = null)
            where _block_ : IMyTerminalBlock
        {
            IMyTerminalControlProperty <_type_> new_property = MyAPIGateway.TerminalControls.CreateProperty <_type_, _block_>(id);

            new_property.Getter = getter;
            if (setter != null)
            {
                new_property.Setter = setter;
            }
            MyAPIGateway.TerminalControls.AddControl <_block_>(new_property);
        }
        // Context: All
        public override void UpdateOnceBeforeFrame()
        {
            if (me.CubeGrid?.Physics == null)
            {
                return;
            }

            _state = new SyncableProjectorState(me, State.Idle, 0);

            if (Constants.IsServer)
            {
                LoadStorage();
                _settings.OnValueReceived += SaveStorage;
                BuildState           = State.Idle;
                me.IsWorkingChanged += Me_IsWorkingChanged;
            }
            else
            {
                _settings = new SyncableProjectorSettings(me, 0, true);
                _state.RequestFromServer();
                _settings.RequestFromServer();
                _state.OnValueReceived += ReceivedNewState;
            }

            MyProjectorDefinition def = (MyProjectorDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(me.BlockDefinition);

            minPower = def.RequiredPowerInput;
            sink     = me.Components.Get <MyResourceSinkComponent>();
            MyDefinitionId powerDef = MyResourceDistributorComponent.ElectricityId;

            sink.SetRequiredInputFuncByType(powerDef, GetCurrentPower);
            sink.Update();
            _settings.OnValueReceived += RefreshUI;

            me.AppendingCustomInfo += CustomInfo;
            me.RefreshCustomInfo();

            Settings.MapSettings config = IPSession.Instance.MapSettings;
            config.OnSubgridsChanged += ClearCachedComps;
            config.OnComponentCostModifierChanged += ClearCachedComps;
            config.OnExtraComponentChanged        += ClearCachedComps;
            config.OnExtraCompCostChanged         += ClearCachedComps;

            if (!controls)
            {
                // Terminal controls

                IMyTerminalControlSeparator sep = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyProjector>("BuildGridSep");
                sep.Enabled = IsValid;
                sep.Visible = IsValid;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sep);

                IMyTerminalControlButton btnBuild = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("BuildGrid");
                btnBuild.Enabled = IsWorking;
                btnBuild.Visible = IsValid;
                btnBuild.SupportsMultipleBlocks = true;
                btnBuild.Title   = MyStringId.GetOrCompute("Build Grid");
                btnBuild.Action  = BuildClient;
                btnBuild.Tooltip = MyStringId.GetOrCompute("Builds the projection instantly.\nThere will be a cooldown after building.");
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnBuild);

                IMyTerminalControlButton btnCancel = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("CancelBuildGrid");
                btnCancel.Enabled = IsWorking;
                btnCancel.Visible = IsValid;
                btnCancel.SupportsMultipleBlocks = true;
                btnCancel.Title   = MyStringId.GetOrCompute("Cancel");
                btnCancel.Action  = CancelClient;
                btnCancel.Tooltip = MyStringId.GetOrCompute("Cancels the build process.");
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnCancel);

                IMyTerminalControlCheckbox chkShift = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyProjector>("MoveProjectionArea");
                chkShift.Enabled = IsWorking;
                chkShift.Visible = IsValid;
                chkShift.SupportsMultipleBlocks = true;
                chkShift.Title   = MyStringId.GetOrCompute("Loose Projection Area");
                chkShift.OnText  = MyStringId.GetOrCompute("On");
                chkShift.OffText = MyStringId.GetOrCompute("Off");
                chkShift.Tooltip = MyStringId.GetOrCompute("Allow the projection to spawn in a different area if the original area is occupied.");
                chkShift.Setter  = SetLooseArea;
                chkShift.Getter  = GetLooseArea;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(chkShift);

                IMyTerminalControlSlider sliderSpeed = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyProjector>("BuildSpeed");
                sliderSpeed.Enabled = IsWorking;
                sliderSpeed.Visible = IsValid;
                sliderSpeed.SupportsMultipleBlocks = true;
                sliderSpeed.Title   = MyStringId.GetOrCompute("Speed");
                sliderSpeed.Tooltip = MyStringId.GetOrCompute("Increasing the speed will use more energy.");
                sliderSpeed.SetLogLimits(Constants.minSpeed, Constants.maxSpeed);
                sliderSpeed.Writer = GetSpeedText;
                sliderSpeed.Getter = GetSpeed;
                sliderSpeed.Setter = SetSpeed;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sliderSpeed);

                IMyTerminalControlTextbox txtTimeout = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyProjector>("GridTimer");
                txtTimeout.Enabled = (b) => false;
                txtTimeout.Visible = IsValid;
                txtTimeout.Getter  = GetTimer;
                txtTimeout.Setter  = (b, s) => { };
                txtTimeout.SupportsMultipleBlocks = false;
                txtTimeout.Title   = MyStringId.GetOrCompute("Build Timer");
                txtTimeout.Tooltip = MyStringId.GetOrCompute("The amount of time you must wait after building a grid to be able to build another.");
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(txtTimeout);

                // Terminal actions
                // Button panels are special and trigger on the server instead of the client, making everything more complicated.

                IMyTerminalAction aCancel = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildAction");
                aCancel.Enabled             = IsValid;
                aCancel.Action              = CancelClient; // For all except button panels
                aCancel.ValidForGroups      = true;
                aCancel.Name                = new StringBuilder("Cancel Spawn Grid");
                aCancel.Writer              = (b, s) => s.Append("Cancel");
                aCancel.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList();
                MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel);
                IMyTerminalAction aCancel2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildGrid");
                aCancel2.Enabled             = IsValid;
                aCancel2.Action              = CancelClientUnsafe; // For only button panels
                aCancel2.ValidForGroups      = true;
                aCancel2.Name                = new StringBuilder("Cancel Spawn Grid");
                aCancel2.Writer              = (b, s) => s.Append("Cancel");
                aCancel2.InvalidToolbarTypes = new List <MyToolbarType> {
                    MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit,
                    MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator
                };
                MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel2);

                IMyTerminalAction aBuild = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGridAction");
                aBuild.Enabled             = IsValid;
                aBuild.Action              = BuildClient; // For all except button panels
                aBuild.ValidForGroups      = true;
                aBuild.Name                = new StringBuilder("Spawn Grid");
                aBuild.Writer              = (b, s) => s.Append("Spawn");
                aBuild.InvalidToolbarTypes = new [] { MyToolbarType.ButtonPanel }.ToList();
                MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild);
                IMyTerminalAction aBuild2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGrid");
                aBuild2.Enabled             = IsValid;
                aBuild2.Action              = BuildClientUnsafe; // For only button panels
                aBuild2.ValidForGroups      = true;
                aBuild2.Name                = new StringBuilder("Spawn Grid");
                aBuild2.Writer              = (b, s) => s.Append("Spawn");
                aBuild2.InvalidToolbarTypes = new List <MyToolbarType> {
                    MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit,
                    MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator
                };
                MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild2);

                IMyTerminalControlListbox itemList = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyProjector>("ComponentList");
                itemList.Enabled                = IsWorking;
                itemList.Visible                = IsValid;
                itemList.ListContent            = GetItemList;
                itemList.Multiselect            = false;
                itemList.SupportsMultipleBlocks = false;
                itemList.Title            = MyStringId.GetOrCompute("Components");
                itemList.VisibleRowsCount = 10;
                itemList.ItemSelected     = (b, l) => { };
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemList);


                // Programmable Block stuff

                IMyTerminalControlProperty <Dictionary <MyItemType, int> > itemListProp
                    = MyAPIGateway.TerminalControls.CreateProperty <Dictionary <MyItemType, int>, IMyProjector>("RequiredComponents");
                itemListProp.Enabled = IsWorking;
                itemListProp.Visible = IsValid;
                itemListProp.SupportsMultipleBlocks = false;
                itemListProp.Setter = (b, l) => { };
                itemListProp.Getter = GetItemListPB;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListProp);

                IMyTerminalControlProperty <int> gridTimeoutProp
                    = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerProjection");
                gridTimeoutProp.Enabled = IsWorking;
                gridTimeoutProp.Visible = IsValid;
                gridTimeoutProp.SupportsMultipleBlocks = false;
                gridTimeoutProp.Setter = (b, l) => { };
                gridTimeoutProp.Getter = GetMaxTimerPB;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutProp);

                IMyTerminalControlProperty <int> gridTimeoutActive
                    = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerCurrent");
                gridTimeoutActive.Enabled = IsWorking;
                gridTimeoutActive.Visible = IsValid;
                gridTimeoutActive.SupportsMultipleBlocks = false;
                gridTimeoutActive.Setter = (b, l) => { };
                gridTimeoutActive.Getter = GetCurrentTimerPB;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive);

                IMyTerminalControlProperty <int> buildState
                    = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("BuildState");
                buildState.Enabled = IsWorking;
                buildState.Visible = IsValid;
                buildState.SupportsMultipleBlocks = false;
                buildState.Setter = (b, l) => { };
                buildState.Getter = GetStatePB;
                MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive);

                MyLog.Default.WriteLineAndConsole("Initialized Instant Projector.");
                controls = true;
            }
        }
        public static void Create()
        {
            if (controls)
            {
                return;
            }

            IMyTerminalControlSeparator sep = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSeparator, IMyProjector>("BuildGridSep");

            sep.Enabled = IsValid;
            sep.Visible = IsValid;
            sep.SupportsMultipleBlocks = true;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sep);

            IMyTerminalControlLabel lbl = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlLabel, IMyProjector>("BuildGridLabel");

            lbl.Enabled = IsValid;
            lbl.Visible = IsValid;
            lbl.SupportsMultipleBlocks = true;
            lbl.Label = MyStringId.GetOrCompute("Instant Projector Controls");
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(lbl);

            IMyTerminalControlButton btnBuild = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("BuildGrid");

            btnBuild.Enabled = IsWorking;
            btnBuild.Visible = IsValid;
            btnBuild.SupportsMultipleBlocks = true;
            btnBuild.Title   = MyStringId.GetOrCompute("Build Grid");
            btnBuild.Action  = BuildClient;
            btnBuild.Tooltip = MyStringId.GetOrCompute("Builds the projection instantly.\nThere will be a cooldown after building.");
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnBuild);

            IMyTerminalControlButton btnCancel = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("CancelBuildGrid");

            btnCancel.Enabled = IsWorking;
            btnCancel.Visible = IsValid;
            btnCancel.SupportsMultipleBlocks = true;
            btnCancel.Title   = MyStringId.GetOrCompute("Cancel");
            btnCancel.Action  = CancelClient;
            btnCancel.Tooltip = MyStringId.GetOrCompute("Cancels the build process.");
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(btnCancel);

            IMyTerminalControlCheckbox chkShift = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyProjector>("MoveProjectionArea");

            chkShift.Enabled = IsWorking;
            chkShift.Visible = IsValid;
            chkShift.SupportsMultipleBlocks = true;
            chkShift.Title   = MyStringId.GetOrCompute("Loose Projection Area");
            chkShift.OnText  = MyStringId.GetOrCompute("On");
            chkShift.OffText = MyStringId.GetOrCompute("Off");
            chkShift.Tooltip = MyStringId.GetOrCompute("Allow the projection to spawn in a different area if the original area is occupied.");
            chkShift.Setter  = SetLooseArea;
            chkShift.Getter  = GetLooseArea;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(chkShift);

            IMyTerminalControlSlider sliderSpeed = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyProjector>("BuildSpeed");

            sliderSpeed.Enabled = IsWorking;
            sliderSpeed.Visible = IsValid;
            sliderSpeed.SupportsMultipleBlocks = true;
            sliderSpeed.Title   = MyStringId.GetOrCompute("Speed");
            sliderSpeed.Tooltip = MyStringId.GetOrCompute("Increasing the speed will use more energy.");
            sliderSpeed.SetLogLimits(Constants.minSpeed, Constants.maxSpeed);
            sliderSpeed.Writer = GetSpeedText;
            sliderSpeed.Getter = GetSpeed;
            sliderSpeed.Setter = SetSpeed;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(sliderSpeed);

            IMyTerminalControlTextbox txtTimeout = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlTextbox, IMyProjector>("GridTimer");

            txtTimeout.Enabled = (b) => false;
            txtTimeout.Visible = IsValid;
            txtTimeout.Getter  = GetTimer;
            txtTimeout.Setter  = (b, s) => { };
            txtTimeout.SupportsMultipleBlocks = false;
            txtTimeout.Title   = MyStringId.GetOrCompute("Build Timer");
            txtTimeout.Tooltip = MyStringId.GetOrCompute("The amount of time you must wait after building a grid to be able to build another.");
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(txtTimeout);

            // Terminal actions
            // Button panels are special and trigger on the server instead of the client, making everything more complicated.

            IMyTerminalAction aCancel = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildAction");

            aCancel.Enabled             = IsValid;
            aCancel.Action              = CancelClient; // For all except button panels
            aCancel.ValidForGroups      = true;
            aCancel.Name                = new StringBuilder("Cancel Spawn Grid");
            aCancel.Writer              = (b, s) => s.Append("Cancel");
            aCancel.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList();
            MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel);
            IMyTerminalAction aCancel2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("CancelBuildGrid");

            aCancel2.Enabled             = IsValid;
            aCancel2.Action              = CancelClientUnsafe; // For only button panels
            aCancel2.ValidForGroups      = true;
            aCancel2.Name                = new StringBuilder("Cancel Spawn Grid");
            aCancel2.Writer              = (b, s) => s.Append("Cancel");
            aCancel2.InvalidToolbarTypes = new List <MyToolbarType> {
                MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit,
                MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator
            };
            MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aCancel2);

            IMyTerminalAction aBuild = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGridAction");

            aBuild.Enabled             = IsValid;
            aBuild.Action              = BuildClient; // For all except button panels
            aBuild.ValidForGroups      = true;
            aBuild.Name                = new StringBuilder("Spawn Grid");
            aBuild.Writer              = (b, s) => s.Append("Spawn");
            aBuild.InvalidToolbarTypes = new[] { MyToolbarType.ButtonPanel }.ToList();
            MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild);
            IMyTerminalAction aBuild2 = MyAPIGateway.TerminalControls.CreateAction <IMyProjector>("BuildGrid");

            aBuild2.Enabled             = IsValid;
            aBuild2.Action              = BuildClientUnsafe; // For only button panels
            aBuild2.ValidForGroups      = true;
            aBuild2.Name                = new StringBuilder("Spawn Grid");
            aBuild2.Writer              = (b, s) => s.Append("Spawn");
            aBuild2.InvalidToolbarTypes = new List <MyToolbarType> {
                MyToolbarType.BuildCockpit, MyToolbarType.Character, MyToolbarType.LargeCockpit,
                MyToolbarType.None, MyToolbarType.Seat, MyToolbarType.Ship, MyToolbarType.SmallCockpit, MyToolbarType.Spectator
            };
            MyAPIGateway.TerminalControls.AddAction <IMyProjector>(aBuild2);

            IMyTerminalControlListbox itemList = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlListbox, IMyProjector>("ComponentList");

            itemList.Enabled                = IsWorking;
            itemList.Visible                = IsValid;
            itemList.ListContent            = GetItemList;
            itemList.Multiselect            = false;
            itemList.SupportsMultipleBlocks = false;
            itemList.Title            = MyStringId.GetOrCompute("Components");
            itemList.VisibleRowsCount = 10;
            itemList.ItemSelected     = (b, l) => { };
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemList);

            IMyTerminalControlButton itemListInfo = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyProjector>("ComponentListInfo");

            itemListInfo.Enabled = IsWorking;
            itemListInfo.Visible = IsValid;
            itemListInfo.SupportsMultipleBlocks = false;
            itemListInfo.Title  = MyStringId.GetOrCompute("Check Inventory");
            itemListInfo.Action = OpenItemList;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListInfo);


            // Programmable Block stuff

            IMyTerminalControlProperty <Dictionary <MyItemType, int> > itemListProp
                = MyAPIGateway.TerminalControls.CreateProperty <Dictionary <MyItemType, int>, IMyProjector>("RequiredComponents");

            itemListProp.Enabled = IsWorking;
            itemListProp.Visible = IsValid;
            itemListProp.SupportsMultipleBlocks = false;
            itemListProp.Setter = (b, l) => { };
            itemListProp.Getter = GetItemListPB;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(itemListProp);

            IMyTerminalControlProperty <int> gridTimeoutProp
                = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerProjection");

            gridTimeoutProp.Enabled = IsWorking;
            gridTimeoutProp.Visible = IsValid;
            gridTimeoutProp.SupportsMultipleBlocks = false;
            gridTimeoutProp.Setter = (b, l) => { };
            gridTimeoutProp.Getter = GetMaxTimerPB;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutProp);

            IMyTerminalControlProperty <int> gridTimeoutActive
                = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("GridTimerCurrent");

            gridTimeoutActive.Enabled = IsWorking;
            gridTimeoutActive.Visible = IsValid;
            gridTimeoutActive.SupportsMultipleBlocks = false;
            gridTimeoutActive.Setter = (b, l) => { };
            gridTimeoutActive.Getter = GetCurrentTimerPB;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive);

            IMyTerminalControlProperty <int> buildState
                = MyAPIGateway.TerminalControls.CreateProperty <int, IMyProjector>("BuildState");

            buildState.Enabled = IsWorking;
            buildState.Visible = IsValid;
            buildState.SupportsMultipleBlocks = false;
            buildState.Setter = (b, l) => { };
            buildState.Getter = GetStatePB;
            MyAPIGateway.TerminalControls.AddControl <IMyProjector>(gridTimeoutActive);

            MyLog.Default.WriteLineAndConsole("Initialized Instant Projector.");
            controls = true;
        }
Beispiel #7
0
        private void CreateControls()
        {
            // Actions
            IMyTerminalAction toggleWarp = MyAPIGateway.TerminalControls.CreateAction <IMyUpgradeModule>("ToggleWarp");

            toggleWarp.Enabled = IsWarpDrive;
            toggleWarp.Name    = new StringBuilder("Toggle Warp");
            toggleWarp.Action  = ToggleWarp;
            toggleWarp.Icon    = "Textures\\GUI\\Icons\\Actions\\Toggle.dds";
            toggleWarp.Writer  = GetWarpStatusText;
            MyAPIGateway.TerminalControls.AddAction <IMyUpgradeModule>(toggleWarp);

            IMyTerminalAction toggleSafety = MyAPIGateway.TerminalControls.CreateAction <IMyUpgradeModule>("ToggleSafety");

            toggleSafety.Enabled = IsWarpDrive;
            toggleSafety.Name    = new StringBuilder("Toggle Safety");
            toggleSafety.Action  = ToggleSafety;
            toggleSafety.Icon    = "Textures\\GUI\\Icons\\Actions\\Toggle.dds";
            toggleSafety.Writer  = GetSafetyText;
            MyAPIGateway.TerminalControls.AddAction <IMyUpgradeModule>(toggleSafety);

            // Controls
            IMyTerminalControlButton startWarpBtn = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlButton, IMyUpgradeModule>("StartWarpBtn");

            startWarpBtn.Tooltip = MyStringId.GetOrCompute("Toggles the status of the warp drives on the ship");
            startWarpBtn.Title   = MyStringId.GetOrCompute("Toggle Warp");
            startWarpBtn.Enabled = IsWarpDrive;
            startWarpBtn.Visible = IsWarpDrive;
            startWarpBtn.SupportsMultipleBlocks = false;
            startWarpBtn.Action = ToggleWarp;
            MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(startWarpBtn);

            IMyTerminalControlCheckbox safetyCheckbox = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlCheckbox, IMyUpgradeModule>("Safety");

            safetyCheckbox.Tooltip = MyStringId.GetOrCompute("When checked, the warp drive will not function without a player on the ship.");
            safetyCheckbox.Title   = MyStringId.GetOrCompute("Safety");
            safetyCheckbox.OffText = MyStringId.GetOrCompute("Off");
            safetyCheckbox.OnText  = MyStringId.GetOrCompute("On");
            safetyCheckbox.Enabled = IsWarpDrive;
            safetyCheckbox.Visible = IsWarpDrive;
            safetyCheckbox.SupportsMultipleBlocks = false;
            safetyCheckbox.Setter = SetWarpSafety;
            safetyCheckbox.Getter = GetWarpSafety;
            MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(safetyCheckbox);

            // Pb Properties
            IMyTerminalControlProperty <bool> inWarp = MyAPIGateway.TerminalControls.CreateProperty <bool, IMyUpgradeModule>("WarpStatus");

            inWarp.Enabled = IsWarpDrive;
            inWarp.Visible = IsWarpDrive;
            inWarp.SupportsMultipleBlocks = false;
            inWarp.Setter = SetWarpStatus;
            inWarp.Getter = GetWarpStatus;
            MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(inWarp);

            IMyTerminalControlProperty <bool> warpSafetyProp = MyAPIGateway.TerminalControls.CreateProperty <bool, IMyUpgradeModule>("WarpSafety");

            warpSafetyProp.Enabled = IsWarpDrive;
            warpSafetyProp.Visible = IsWarpDrive;
            warpSafetyProp.SupportsMultipleBlocks = false;
            warpSafetyProp.Setter = SetWarpSafety;
            warpSafetyProp.Getter = GetWarpSafety;
            MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(warpSafetyProp);

            IMyTerminalControlProperty <float> heatPercent = MyAPIGateway.TerminalControls.CreateProperty <float, IMyUpgradeModule>("WarpHeat");

            heatPercent.Enabled = IsWarpDrive;
            heatPercent.Visible = IsWarpDrive;
            heatPercent.SupportsMultipleBlocks = false;
            heatPercent.Setter = (x, y) => { };
            heatPercent.Getter = GetWarpHeat;
            MyAPIGateway.TerminalControls.AddControl <IMyUpgradeModule>(heatPercent);
        }
        private IMyTerminalControlProperty <IReadOnlyList <MyTuple <MyDefinitionId, Vector3I, Vector3D, float, IReadOnlyDictionary <string, int> > > > ProjectedGridBlocks()
        {
            IMyTerminalControlProperty <IReadOnlyList <MyTuple <MyDefinitionId, Vector3I, Vector3D, float, IReadOnlyDictionary <string, int> > > > ProjectedGridBlocks = MyAPIGateway.TerminalControls.CreateProperty <IReadOnlyList <MyTuple <MyDefinitionId, Vector3I, Vector3D, float, IReadOnlyDictionary <string, int> > >, IMyProjector>("ProjectedGridBlocks");

            ProjectedGridBlocks.Enabled = Block => HasBlockLogic(Block);
            ProjectedGridBlocks.Getter  = ProjectedGridBlocks_Getter;
            ProjectedGridBlocks.Setter  = DefaultInvalidPropertySetter;

            return(ProjectedGridBlocks);
        }