示例#1
0
        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
        }
 public MergeBlockEntity(CubeGridEntity parent, MyObjectBuilder_MergeBlock definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
 public MergeBlockEntity(CubeGridEntity parent, MyObjectBuilder_MergeBlock definition)
     : base(parent, definition)
 {
 }
 public MergeBlockEntity(CubeGridEntity parent, MyObjectBuilder_MergeBlock definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
 }
 public MergeBlockEntity(CubeGridEntity parent, MyObjectBuilder_MergeBlock definition)
     : base(parent, definition)
 {
 }