Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Sandbox.ModAPI;
- using Sandbox.ModAPI.Interfaces.Terminal;
- using System;
- using System.Text;
- using VRage.Game.Components;
- using VRage.Utils;
- //Cobbled together from various forms of advice, tutorials, and depression.
- namespace JumpAnyway
- {
- [MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
- public class Program : MySessionComponentBase
- {
- private bool init = false;
- private int updateCount = 0;
- public override void UpdateBeforeSimulation()
- {
- try
- {
- if (!init)
- {
- //MyAPIGateway.Utilities.ShowMessage("Jump", "UpdateBeforeSimulation");
- CreateJumpCommand();
- init = true;
- }
- }
- catch (Exception e)
- {
- MyAPIGateway.Utilities.ShowMessage("Error", e.Message);
- }
- }
- void TriggerJumpCommand(IMyTerminalBlock jumpDrive)
- {
- //MyAPIGateway.Utilities.ShowMessage("Jump", "Triggering!");
- IMyJumpDrive jd = jumpDrive as IMyJumpDrive;
- jd.Jump(false);
- }
- public Action<IMyTerminalBlock> JumpAction
- {
- get
- {
- //MyAPIGateway.Utilities.ShowMessage("JumpAction", "Get");
- return TriggerJumpCommand;
- //return true;
- }
- set
- {
- //MyAPIGateway.Utilities.ShowMessage("JumpAction", "SET");
- }
- }
- void CreateJumpCommand()
- {
- //MyAPIGateway.Utilities.ShowMessage("Jump","Creating Jump Command");
- //Create a jump button in the terminal after the list of GPS coordinates. Too much work to put it higher.
- var jumpButton = MyAPIGateway.TerminalControls.CreateControl<IMyTerminalControlButton, Sandbox.ModAPI.Ingame.IMyJumpDrive>("JumpAnyways");//"engage"?
- jumpButton.Action = JumpAction;
- jumpButton.Title = MyStringId.GetOrCompute("Jump");
- jumpButton.Tooltip = MyStringId.GetOrCompute("Attempt to initate space-time distortion fields, bypassing in-cockpit safety check.");
- MyAPIGateway.TerminalControls.AddControl<Sandbox.ModAPI.Ingame.IMyJumpDrive>(jumpButton);
- //Create the action for timers, buttons, etc.
- var jumpAction = MyAPIGateway.TerminalControls.CreateAction<Sandbox.ModAPI.Ingame.IMyJumpDrive>("Jump Please");
- jumpAction.Action = JumpAction;
- jumpAction.Name = new StringBuilder("Jump Please");
- //jumpAction.Writer = CruiseControlSwitchHotbarText; //??
- MyAPIGateway.TerminalControls.AddAction<Sandbox.ModAPI.Ingame.IMyJumpDrive>(jumpAction);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement