public void Release(ZACommons commons, EventDriver eventDriver) { // Enable mass var group = commons.GetBlockGroupWithName(StandardMissile.MASS_GROUP + MissileGroupSuffix); if (group != null) { ZACommons.EnableBlocks(group.Blocks, true); } var releaseGroup = commons.GetBlockGroupWithName(StandardMissile.RELEASE_GROUP + MissileGroupSuffix); if (releaseGroup == null) { throw new Exception("Group missing: " + StandardMissile.RELEASE_GROUP + MissileGroupSuffix); } // Unlock any landing gear ZACommons.ForEachBlockOfType <IMyLandingGear>(releaseGroup.Blocks, gear => gear.ApplyAction("Unlock")); // And then turn everything off (connectors, merge blocks, etc) ZACommons.EnableBlocks(releaseGroup.Blocks, false); // Initialize flight control var shipControl = (ShipControlCommons)commons; shipControl.Reset(gyroOverride: true, thrusterEnable: null); eventDriver.Schedule(0.1, Demass); }
public void Docked(ZACommons commons, EventDriver eventDriver) { ZACommons.ForEachBlockOfType <IMyLandingGear>(commons.Blocks, gear => { if (gear.IsFunctional && gear.IsWorking && gear.Enabled && !gear.IsLocked) { gear.ApplyAction("Lock"); } }); // Do everything else needed after docking ManageShip(commons, eventDriver, true); }
public void Release(ZACommons commons, EventDriver eventDriver) { var releaseGroup = commons.GetBlockGroupWithName(StandardMissile.RELEASE_GROUP + MissileGroupSuffix); if (releaseGroup == null) { throw new Exception("Group missing: " + StandardMissile.RELEASE_GROUP + MissileGroupSuffix); } // Unlock any landing gear ZACommons.ForEachBlockOfType <IMyLandingGear>(releaseGroup.Blocks, gear => gear.ApplyAction("Unlock")); // And then turn everything off (connectors, merge blocks, etc) ZACommons.EnableBlocks(releaseGroup.Blocks, false); eventDriver.Schedule(0.5, Burn); }
private void LaunchDecoy(ZACommons commons, EventDriver eventDriver, string suffix) { var group = commons.GetBlockGroupWithName("SS Decoy Set" + suffix); // Activate decoys ZACommons.ForEachBlockOfType <IMyDecoy>(group.Blocks, block => block.Enabled = true); eventDriver.Schedule(DecoyReleaseDelay, (c, e) => { var g = c.GetBlockGroupWithName("SS Decoy Set" + suffix); // Deactivate merge block ZACommons.ForEachBlockOfType <IMyShipMergeBlock>(g.Blocks, merge => { merge.Enabled = false; }); }); }
public void DockLock(ZACommons commons, EventDriver eventDriver) { bool connected = false; ZACommons.ForEachBlockOfType <IMyShipConnector>(commons.Blocks, connector => { if (connector.IsFunctional && connector.DefinitionDisplayNameText == "Connector" && connector.Status == MyShipConnectorStatus.Connectable) { connector.ApplyAction("Lock"); connected = true; } }); if (connected) { // And 1 second from now, lock landing gear and do everything else eventDriver.Schedule(1.0, Docked); } }
public void DockStart(ZACommons commons, EventDriver eventDriver) { // Enable all connectors ZACommons.ForEachBlockOfType <IMyShipConnector>(commons.Blocks, connector => { if (connector.IsFunctional && connector.DefinitionDisplayNameText == "Connector") { connector.Enabled = true; } }); // Perform any pre-docking actions, if any for (var i = 0; i < DockingHandlers.Length; i++) { DockingHandlers[i].PreDock(commons, eventDriver); } // 1 second from now, lock connectors that are ready eventDriver.Schedule(1.0, DockLock); }
public void Run(ZACommons commons, EventDriver eventDriver) { bool kill = false; // Check if any essential blocks have been damaged for (var e = BlocksToCheck.GetEnumerator(); e.MoveNext();) { var block = e.Current; var slimBlock = block.CubeGrid.GetCubeBlock(block.Position); if (slimBlock.CurrentDamage > 0.0f) { kill = true; break; } } // Check distance from start point if (!kill) { var distance = (((ShipControlCommons)commons).ReferencePoint - StartPoint).Length(); kill = distance >= KILL_DISTANCE; } if (kill) { var shipControl = (ShipControlCommons)commons; shipControl.GyroControl.EnableOverride(false); shipControl.ThrustControl.Enable(false); // Shut down all timer blocks ZACommons.ForEachBlockOfType <IMyTimerBlock>(commons.Blocks, block => { block.SetValue <bool>("OnOff", false); }); } else { eventDriver.Schedule(FramesPerRun, Run); } }
private void LaunchDecoy(ZACommons commons, EventDriver eventDriver, string suffix) { var group = commons.GetBlockGroupWithName("SS Decoy Set" + suffix); // Activate decoys ZACommons.ForEachBlockOfType <IMyTerminalBlock>(group.Blocks, block => { if (block.DefinitionDisplayNameText == "Decoy") { block.SetValue <bool>("OnOff", true); } }); eventDriver.Schedule(DecoyReleaseDelay, (c, e) => { var g = c.GetBlockGroupWithName("SS Decoy Set" + suffix); // Deactivate merge block ZACommons.ForEachBlockOfType <IMyShipMergeBlock>(g.Blocks, merge => { merge.SetValue <bool>("OnOff", false); }); }); }