Ejemplo n.º 1
0
        public static void RaiseHeightAction(IMyTerminalBlock block)
        {
            float height = (float)SettingsStore.Get(block, "height_offset", 1.25f);

            height = Math.Min(2.5f, (float)Math.Round(height + 0.1f, 1));
            SettingsStore.Set(block, "height_offset", height);
        }
Ejemplo n.º 2
0
        public static void InitLate()
        {
            initialized = true;

            powerSwitch         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, IMyTerminalBlock>("HoverRail_OnOff");
            powerSwitch.Title   = MyStringId.GetOrCompute("Maglev Engine");
            powerSwitch.Tooltip = MyStringId.GetOrCompute("Enable to apply force to stick to the track.");
            powerSwitch.Getter  = b => (bool)SettingsStore.Get(b, "power_on", true);
            powerSwitch.Setter  = (b, v) => SettingsStore.Set(b, "power_on", v);
            powerSwitch.SupportsMultipleBlocks = true;
            powerSwitch.OnText  = MyStringId.GetOrCompute("On");
            powerSwitch.OffText = MyStringId.GetOrCompute("Off");
            powerSwitch.Visible = BlockIsEngine;
            MyAPIGateway.TerminalControls.AddControl <IMyTerminalBlock>(powerSwitch);

            forceSlider         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyTerminalBlock>("HoverRail_ForceLimit");
            forceSlider.Title   = MyStringId.GetOrCompute("Force Limit");
            forceSlider.Tooltip = MyStringId.GetOrCompute("The amount of force applied to align this motor with the track.");
            forceSlider.SetLogLimits(10000.0f, 50000000.0f);
            forceSlider.SupportsMultipleBlocks = true;
            forceSlider.Getter  = b => (float)SettingsStore.Get(b, "force_slider", 100000.0f);
            forceSlider.Setter  = (b, v) => SettingsStore.Set(b, "force_slider", (float)LogRound(v));
            forceSlider.Writer  = (b, result) => result.Append(String.Format("{0}N", SIFormat((float)SettingsStore.Get(b, "force_slider", 100000.0f))));
            forceSlider.Visible = BlockIsEngine;
            MyAPIGateway.TerminalControls.AddControl <IMyTerminalBlock>(forceSlider);

            heightSlider         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlSlider, IMyTerminalBlock>("HoverRail_HeightOffset");
            heightSlider.Title   = MyStringId.GetOrCompute("Height Offset");
            heightSlider.Tooltip = MyStringId.GetOrCompute("The height we float above the track.");
            heightSlider.SetLimits(0.1f, 2.5f);
            heightSlider.SupportsMultipleBlocks = true;
            heightSlider.Getter  = b => (float)SettingsStore.Get(b, "height_offset", 1.25f);
            heightSlider.Setter  = (b, v) => SettingsStore.Set(b, "height_offset", (float)Math.Round(v, 1));
            heightSlider.Writer  = (b, result) => result.Append(String.Format("{0}m", (float)SettingsStore.Get(b, "height_offset", 1.25f)));
            heightSlider.Visible = BlockIsEngine;
            MyAPIGateway.TerminalControls.AddControl <IMyTerminalBlock>(heightSlider);

            lowerHeightAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailEngine_LowerHeight0.1");
            lowerHeightAction.Name   = new StringBuilder("Lower Height");
            lowerHeightAction.Action = LowerHeightAction;
            lowerHeightAction.Writer = (block, builder) => {
                builder.Clear();
                builder.Append(String.Format("{0} -", (float)SettingsStore.Get(block, "height_offset", 1.25f)));
            };
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(lowerHeightAction);

            raiseHeightAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailEngine_RaiseHeight0.1");
            raiseHeightAction.Name   = new StringBuilder("Raise Height");
            raiseHeightAction.Action = RaiseHeightAction;
            raiseHeightAction.Writer = (block, builder) => {
                builder.Clear();
                builder.Append(String.Format("{0} +", (float)SettingsStore.Get(block, "height_offset", 1.25f)));
            };
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(raiseHeightAction);

            turnOnAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailEngine_On");
            turnOnAction.Name   = new StringBuilder("Power On");
            turnOnAction.Action = TurnOnAction;
            turnOnAction.Writer = OnOffWriter;
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(turnOnAction);

            turnOffAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailEngine_Off");
            turnOffAction.Name   = new StringBuilder("Power Off");
            turnOffAction.Action = TurnOffAction;
            turnOffAction.Writer = OnOffWriter;
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(turnOffAction);

            turnOnOffAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailEngine_OnOff");
            turnOnOffAction.Name   = new StringBuilder("Power On/Off");
            turnOnOffAction.Action = TurnOnOffAction;
            turnOnOffAction.Writer = OnOffWriter;
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(turnOnOffAction);

            MyAPIGateway.TerminalControls.CustomActionGetter += GetEngineActions;
        }
Ejemplo n.º 3
0
 public static void TurnOnOffAction(IMyTerminalBlock block)
 {
     SettingsStore.Set(block, "power_on", !SettingsStore.Get(block, "power_on", true));
 }
Ejemplo n.º 4
0
 public static void TurnOffAction(IMyTerminalBlock block)
 {
     SettingsStore.Set(block, "power_on", false);
 }
Ejemplo n.º 5
0
 public static void JunctionSwitchSideAction(IMyTerminalBlock block)
 {
     SettingsStore.Set(block, "junction_turn", true);
 }
Ejemplo n.º 6
0
 public static void JunctionSwitchStraightAction(IMyTerminalBlock block)
 {
     SettingsStore.Set(block, "junction_turn", false);
 }
Ejemplo n.º 7
0
        public static void InitLate()
        {
            initialized = true;

            turnLeftSwitch         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, IMyTerminalBlock>("LeftJunction_TurnOnOff");
            turnLeftSwitch.Title   = MyStringId.GetOrCompute("Junction Direction");
            turnLeftSwitch.Tooltip = MyStringId.GetOrCompute("Which way should a train go?");
            turnLeftSwitch.Getter  = b => (bool)SettingsStore.Get(b, "junction_turn", false);
            turnLeftSwitch.Setter  = (b, v) => SettingsStore.Set(b, "junction_turn", v);
            turnLeftSwitch.OnText  = MyStringId.GetOrCompute("Left");
            turnLeftSwitch.OffText = MyStringId.GetOrCompute("Fwd");
            turnLeftSwitch.Visible = BlockIsLeftJunction;
            MyAPIGateway.TerminalControls.AddControl <IMyTerminalBlock>(turnLeftSwitch);

            turnRightSwitch         = MyAPIGateway.TerminalControls.CreateControl <IMyTerminalControlOnOffSwitch, IMyTerminalBlock>("RightJunction_TurnOnOff");
            turnRightSwitch.Title   = MyStringId.GetOrCompute("Junction Direction");
            turnRightSwitch.Tooltip = MyStringId.GetOrCompute("Which way should a train go?");
            // meaning flipped relative to switch, so that we can
            // swap the labels and have [Fwd] [Right], which is more pleasing
            turnRightSwitch.Getter  = b => !(bool)SettingsStore.Get(b, "junction_turn", false);
            turnRightSwitch.Setter  = (b, v) => SettingsStore.Set(b, "junction_turn", !v);
            turnRightSwitch.OnText  = MyStringId.GetOrCompute("Fwd");
            turnRightSwitch.OffText = MyStringId.GetOrCompute("Right");
            turnRightSwitch.Visible = BlockIsRightJunction;
            MyAPIGateway.TerminalControls.AddControl <IMyTerminalBlock>(turnRightSwitch);

            leftSwitchAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailLeftJunction_Switch");
            leftSwitchAction.Name   = new StringBuilder("Switch Direction");
            leftSwitchAction.Writer = LeftJunctionText;
            leftSwitchAction.Action = JunctionSwitchAction;
            // TODO figure out why doesn't work
            leftSwitchAction.Icon = @"Textures\Icons\HoverRail\HoverRail_Junction_Left_10x-12x_OnOff.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(leftSwitchAction);

            leftSwitchLeftAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailLeftJunction_Left");
            leftSwitchLeftAction.Name   = new StringBuilder("Go Left");
            leftSwitchLeftAction.Writer = LeftJunctionText;
            leftSwitchLeftAction.Action = JunctionSwitchSideAction;
            leftSwitchLeftAction.Icon   = @"Textures\Icons\HoverRail\HoverRail_Junction_Left_10x-12x_On.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(leftSwitchLeftAction);

            leftSwitchStraightAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailLeftJunction_Straight");
            leftSwitchStraightAction.Name   = new StringBuilder("Go Fwd");
            leftSwitchStraightAction.Writer = LeftJunctionText;
            leftSwitchStraightAction.Action = JunctionSwitchStraightAction;
            leftSwitchStraightAction.Icon   = @"Textures\Icons\HoverRail\HoverRail_Junction_Left_10x-12x_Off.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(leftSwitchStraightAction);

            rightSwitchAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailRightJunction_Switch");
            rightSwitchAction.Name   = new StringBuilder("Switch Direction");
            rightSwitchAction.Writer = RightJunctionText;
            rightSwitchAction.Action = JunctionSwitchAction;
            // rightSwitchAction.Icon = @"Textures\Icons\HoverRail\HoverRail_Junction_Right_10x-12x_OnOff.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(rightSwitchAction);

            rightSwitchStraightAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailRightJunction_Straight");
            rightSwitchStraightAction.Name   = new StringBuilder("Go Fwd");
            rightSwitchStraightAction.Writer = RightJunctionText;
            rightSwitchStraightAction.Action = JunctionSwitchStraightAction;
            // rightSwitchStraightAction.Icon = @"Textures\Icons\HoverRail\HoverRail_Junction_Right_10x-12x_Off.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(rightSwitchStraightAction);

            rightSwitchRightAction        = MyAPIGateway.TerminalControls.CreateAction <IMyTerminalBlock>("HoverRailRightJunction_Right");
            rightSwitchRightAction.Name   = new StringBuilder("Go Right");
            rightSwitchRightAction.Writer = RightJunctionText;
            rightSwitchRightAction.Action = JunctionSwitchSideAction;
            // rightSwitchRightAction.Icon = @"Textures\Icons\HoverRail\HoverRail_Junction_Right_10x-12x_On.dds";
            MyAPIGateway.TerminalControls.AddAction <IMyTerminalBlock>(rightSwitchRightAction);

            MyAPIGateway.TerminalControls.CustomActionGetter += GetSwitchActions;
        }