public void CheckHummingbird() { status = releaseStage.ToString(); if (releaseStage == 0) { // Check for completeness if (!Hummingbird.CheckHummingbirdComponents(ChasisMerge, ref hummingbirdConnector, ref turretRotor, ref PartScratchpad, ref status)) { return; } if (!Hummingbird.CheckHummingbirdComponents(TurretMerge, ref hummingbirdConnector, ref turretRotor, ref PartScratchpad, ref status)) { return; } if (turretRotor == null || hummingbirdConnector == null) { return; } turretRotor.Detach(); Connector.Connect(); var inventoryItem = Host.AmmoBox?.GetItemAt(0); if (inventoryItem != null) { Host.AmmoBox.TransferItemTo(Connector.OtherConnector.GetInventory(0), (MyInventoryItem)inventoryItem); } Connector.Disconnect(); releaseStage = 1; Piston.Velocity = -0.2f; } else if (releaseStage == 1) { // Move pistons if (Piston.CurrentPosition == Piston.MinLimit) { releaseStage = 2; } } else if (releaseStage < 0) { releaseStage++; } }
public void Detach() { attachmentRotor?.Detach(); if (attachmentMergeBlock != null) { attachmentMergeBlock.Enabled = false; } }
private IEnumerable <int> LockSchedule() { // Current state: Unlocked, in any position // Target state: Locked, in same position // Retract rotor head to -0.35 (no collision) or -0.4(collision but final resting point) while (Motor.Displacement > -0.4f) { Motor.Displacement -= 0.01f; yield return(10); } // Activate merge blocks and connectors MergeBlock1.Enabled = true; MergeBlock2.Enabled = true; Connector1.Enabled = true; Connector2.Enabled = true; yield return(10); // Detach rotor head to avoid clang Motor.Detach(); }
public IEnumerator <bool> LaunchSequence() { foreach (var propellingRotor in propellingRotorArray) { propellingRotor.Displacement = 20; } yield return(true); launchRotor.ApplyAction("Add Top Part"); foreach (var propellingRotor in propellingRotorArray) { propellingRotor.Displacement = -40; } yield return(true); launchRotor.Detach(); yield return(true); }
void UnlockStator() { IMyMotorStator clamp = Reference as IMyMotorStator; clamp.Detach(); }
public void Main(string argument, UpdateType updateSource) { if (!setupError) { if ((updateSource & UpdateType.Update1) != 0) { switch (reloadState) { case ReloadStates.RELOAD_COMPLETE: // All done! break; case ReloadStates.RETRACTING_PLACER: if (PlacerPiston.CurrentPosition == PlacerPiston.MinLimit) { Echo("Moving clip."); reloadState = ReloadStates.MOVING_CLIP; GridTerminalSystem.GetBlocksOfType <IMyWarhead>(warheads); } else { PlacerPiston.Retract(); } break; case ReloadStates.MOVING_CLIP: var closestWarheadDistance = GetClosestDistance(warheads, PlacerRotor); if (closestWarheadDistance < 0.5) { ClipPiston.Enabled = false; Echo("Loading warhead."); reloadState = ReloadStates.LOADING_WARHEAD; } else if (warheads.Count() == 0 && ClipPiston.CurrentPosition == ClipPiston.MaxLimit) { Echo("Out of warheads."); reloadState = ReloadStates.RELOAD_COMPLETE; } else { ClipPiston.Enabled = true; ClipPiston.Extend(); } break; case ReloadStates.LOADING_WARHEAD: if (PlacerRotor.IsAttached) { var rotors = new List <IMyMotorStator>(); GridTerminalSystem.GetBlocksOfType <IMyMotorStator>(rotors, (IMyMotorStator x) => x.CubeGrid == ClipPiston.TopGrid && x.TopGrid == PlacerRotor.TopGrid); if (rotors.Count() > 0) { var otherRotor = rotors.First(); otherRotor.Detach(); } Echo("Extending placer."); reloadState = ReloadStates.EXTENDING_PLACER; } else { Echo("Attaching."); PlacerRotor.Attach(); } break; case ReloadStates.EXTENDING_PLACER: if (PlacerPiston.CurrentPosition == PlacerPiston.MaxLimit) { Echo("Reload complete."); reloadState = ReloadStates.RELOAD_COMPLETE; } else { PlacerPiston.Extend(); } break; default: Echo("Encountered unexpected state while reloading."); break; } } else if (argument.ToLower() == "reload") { Echo("Retracting placer piston."); PlacerRotor.Detach(); reloadState = ReloadStates.RETRACTING_PLACER; } else if (argument.ToLower() == "fire") { if (PlacerRotor.IsAttached) { Echo("Deploying payload."); var viableWarheads = new List <IMyWarhead>(); GridTerminalSystem.GetBlocksOfType <IMyWarhead>(viableWarheads, (IMyWarhead x) => x.CubeGrid == PlacerRotor.TopGrid); foreach (var warhead in viableWarheads) { warhead.DetonationTime = DetonationTime; warhead.StartCountdown(); } if (viableWarheads.Count() > 0) { countdown = DetonationTime; bombPosition = PlacerRotor.GetPosition(); } PlacerRotor.Detach(); reloadState = ReloadStates.RETRACTING_PLACER; } } else if (argument.ToLower().StartsWith("timer")) { int.TryParse(argument.ToLower().Substring("timer".Length), out DetonationTime); } } }