From f2f4ec5395f1e140d930d5b2ab2b4389de8af25d Mon Sep 17 00:00:00 2001 From: annabunches Date: Fri, 28 Feb 2025 12:47:11 -0800 Subject: [PATCH] Add Landing Gear to available sequencer actions. --- ActionSequencer/Program.cs | 22 ++++++++ Mixins/ActionGroups/ActionGroups.projitems | 1 + Mixins/ActionGroups/BlockActionLandingGear.cs | 50 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Mixins/ActionGroups/BlockActionLandingGear.cs diff --git a/ActionSequencer/Program.cs b/ActionSequencer/Program.cs index 2b003fb..0f53498 100644 --- a/ActionSequencer/Program.cs +++ b/ActionSequencer/Program.cs @@ -189,6 +189,28 @@ namespace IngameScript } return new BlockActionMerge(block as IMyShipMergeBlock, action); } + else if (block is IMyLandingGear) + { + LandingGearAction action; + string config = Ini.Get(key, "action").ToString("unlock").ToLower(); + switch (config) + { + case "enable": + action = LandingGearAction.Enable; + break; + case "disable": + action = LandingGearAction.Disable; + break; + case "lock": + action = LandingGearAction.Lock; + break; + case "unlock": + action = LandingGearAction.Unlock; + break; + } + + return new BlockActionLandingGear(block as IMyLandingGear, action); + } // TODO: there are several block types added for other scripts that we should support here. Console.Print($"Can't add unsupported block '{block.CustomName}'"); diff --git a/Mixins/ActionGroups/ActionGroups.projitems b/Mixins/ActionGroups/ActionGroups.projitems index c3625eb..18abd0b 100644 --- a/Mixins/ActionGroups/ActionGroups.projitems +++ b/Mixins/ActionGroups/ActionGroups.projitems @@ -11,6 +11,7 @@ + diff --git a/Mixins/ActionGroups/BlockActionLandingGear.cs b/Mixins/ActionGroups/BlockActionLandingGear.cs new file mode 100644 index 0000000..12d7611 --- /dev/null +++ b/Mixins/ActionGroups/BlockActionLandingGear.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using Sandbox.ModAPI.Ingame; + +namespace IngameScript +{ + partial class Program + { + public enum LandingGearAction + { + Unlock, + Lock, + Disable, + Enable, + } + + public class BlockActionLandingGear : BlockAction + { + private IMyLandingGear _gear; + private LandingGearAction _action; + + public BlockActionLandingGear( + IMyLandingGear gear, + LandingGearAction action + ) + { + _gear = gear; + _action = action; + } + + protected override IEnumerator onRun() + { + switch (_action) + { + case LandingGearAction.Enable: + _gear.Enabled = true; + yield break; + case LandingGearAction.Disable: + _gear.Enabled = false; + yield break; + case LandingGearAction.Lock: + // STUB + break; + case LandingGearAction.Unlock: + // STUB + break; + } + } + } + } +} \ No newline at end of file