public override void Init(MyObjectBuilder_EntityBase objectBuilder) { base.Init(objectBuilder); m_MergeBlock = Container.Entity as InGame.IMyShipMergeBlock; //m_Grid = m_MergeBlock.CubeGrid as IMyCubeGrid; m_Logger = new Logger(m_MergeBlock.EntityId.ToString(), "MergeBlock"); log("Attached to merge block", "Init"); (m_MergeBlock as IMyShipMergeBlock).BeforeMerge += beforeMerge; }
private bool lockLanding() { Ingame.IMyShipConnector connector = CNS.landLocalBlock as Ingame.IMyShipConnector; if (connector != null) { if (!connector.IsLocked) // this actually checks for ready to lock (yellow light) { connector.GetActionWithName("OnOff_On").Apply(connector); // on return(false); } log("trying to lock connector", "lockLanding()", Logger.severity.TRACE); connector.GetActionWithName("SwitchLock").Apply(connector); // lock return(true); } Ingame.IMyLandingGear landingGear = CNS.landLocalBlock as Ingame.IMyLandingGear; if (landingGear != null) { MyObjectBuilder_LandingGear builder = CNS.landLocalBlock.GetObjectBuilderCubeBlock() as MyObjectBuilder_LandingGear; landingGear.GetActionWithName("OnOff_On").Apply(landingGear); // on if (!builder.AutoLock) { log("setting autolock", "lockLanding()", Logger.severity.TRACE); landingGear.GetActionWithName("Autolock").Apply(landingGear); // autolock on return(false); } return(builder.IsLocked); } Ingame.IMyShipMergeBlock mergeBlock = CNS.landLocalBlock as Ingame.IMyShipMergeBlock; if (mergeBlock != null) { MyObjectBuilder_MergeBlock builder = CNS.landLocalBlock.GetObjectBuilderCubeBlock() as MyObjectBuilder_MergeBlock; if (builder.SubBlocks != null && builder.SubBlocks.Length > 0) { log("subblock[0]=" + builder.SubBlocks[0].SubGridName, "lockLanding()", Logger.severity.TRACE); } if (!mergeBlock.IsFunctional || !mergeBlock.IsWorking) //&& mergeMonitor.mergeStatus == MergeMonitor.MergeStatus.OFF) { log("merge block set", "lockLanding()", Logger.severity.TRACE); mergeBlock.GetActionWithName("OnOff_On").Apply(mergeBlock); // on } return(false); } log("unknown lander block type " + CNS.landLocalBlock.DefinitionDisplayNameText, "lockLanding()", Logger.severity.INFO); return(true); // assume there is nothing to lock }
private bool unlockLanding() { if (CNS.landingSeparateBlock == null) { alwaysLog("CNS.landingSeparateBlock == null", "unlockLanding()", Logger.severity.FATAL); return(false); // do not allow Navigator to proceed } Ingame.IMyShipConnector connector = CNS.landingSeparateBlock as Ingame.IMyShipConnector; if (connector != null) { // due to a bug in Space Engineers, Autopilot should not unlock a connector while a player is in any passenger seat if (hasPilot()) { myNav.GET_OUT_OF_SEAT = true; myNav.reportState(Navigator.ReportableState.GET_OUT_OF_SEAT); return(false); } myNav.GET_OUT_OF_SEAT = false; bool disconnected = true; if ((CNS.landingSeparateBlock.GetObjectBuilderCubeBlock() as MyObjectBuilder_ShipConnector).Connected) { disconnected = false; log("switching lock", "unlockLanding()", Logger.severity.TRACE); connector.GetActionWithName("SwitchLock").Apply(connector); // unlock } if ((CNS.landingSeparateBlock as Ingame.IMyFunctionalBlock).Enabled) { disconnected = false; log("turning off", "unlockLanding()", Logger.severity.TRACE); connector.GetActionWithName("OnOff_Off").Apply(connector); // off } return(disconnected); } Ingame.IMyLandingGear landingGear = CNS.landingSeparateBlock as Ingame.IMyLandingGear; if (landingGear != null) { // due to a bug in Space Engineers, Autopilot should not unlock a landing gear while a player is in any passenger seat if (hasPilot()) { myNav.GET_OUT_OF_SEAT = true; myNav.reportState(Navigator.ReportableState.GET_OUT_OF_SEAT); return(false); } myNav.GET_OUT_OF_SEAT = false; bool disconnected = true; MyObjectBuilder_LandingGear builder = CNS.landingSeparateBlock.GetObjectBuilderCubeBlock() as MyObjectBuilder_LandingGear; if (builder.AutoLock) { disconnected = false; log("autolock off", "unlockLanding()", Logger.severity.TRACE); landingGear.GetActionWithName("Autolock").Apply(landingGear); // autolock off } if (builder.IsLocked) { disconnected = false; log("landing gear switching lock", "unlockLanding()", Logger.severity.TRACE); landingGear.GetActionWithName("SwitchLock").Apply(landingGear); // unlock } return(disconnected); } Ingame.IMyShipMergeBlock mergeBlock = CNS.landingSeparateBlock as Ingame.IMyShipMergeBlock; if (mergeBlock != null) { bool disconnected = true; if ((CNS.landingSeparateBlock as Ingame.IMyFunctionalBlock).Enabled) { disconnected = false; log("turning off merge block", "unlockLanding()", Logger.severity.TRACE); mergeBlock.GetActionWithName("OnOff_Off").Apply(connector); // off } return(disconnected); } log("unknown separate block type: " + CNS.landingSeparateBlock.DefinitionDisplayNameText, "unlockLanding()", Logger.severity.INFO); return(true); // assume there is nothing to unlock }