Add merge block support to sequencer.
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionConnector.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionDoor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionGasTank.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionMerge.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionPiston.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockActionRotor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)BlockAction.cs" />
|
||||
|
45
Mixins/ActionGroups/BlockActionMerge.cs
Normal file
45
Mixins/ActionGroups/BlockActionMerge.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using Sandbox.ModAPI.Ingame;
|
||||
using SpaceEngineers.Game.ModAPI.Ingame;
|
||||
|
||||
namespace IngameScript
|
||||
{
|
||||
partial class Program
|
||||
{
|
||||
public enum MergeAction
|
||||
{
|
||||
Merge,
|
||||
Unmerge,
|
||||
}
|
||||
|
||||
public class BlockActionMerge : BlockAction
|
||||
{
|
||||
private IMyShipMergeBlock _connector;
|
||||
private MergeAction _action;
|
||||
|
||||
public BlockActionMerge(
|
||||
IMyShipMergeBlock connector,
|
||||
MergeAction action
|
||||
)
|
||||
{
|
||||
_connector = connector;
|
||||
_action = action;
|
||||
}
|
||||
|
||||
protected override IEnumerator<bool> onRun()
|
||||
{
|
||||
switch (_action)
|
||||
{
|
||||
case MergeAction.Merge:
|
||||
_connector.Enabled = true;
|
||||
while (!_connector.IsConnected) yield return true;
|
||||
break;
|
||||
case MergeAction.Unmerge:
|
||||
_connector.Enabled = false;
|
||||
while (_connector.IsConnected) yield return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user