コード例 #1
0
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
//                if (this.part.Resources.Contains("SpareParts"))
                if (this.part.Resources.Contains(Spares.Name))
                {
//                    this.part.Resources["SpareParts"].amount = Math.Round(this.part.Resources["SpareParts"].amount);
                    this.part.Resources[Spares.Name].amount = Math.Round(this.part.Resources[Spares.Name].amount);
                }
            }
            else
            {
                if (this.cargoModule == null)
                {
                    cargoModule = base.part.FindModuleImplementing <ModuleCargoBay>();
                    if (cargoModule != null)
                    {
                        deployModule = this.findModule(cargoModule.DeployModuleIndex);
                    }
                }

                if (cargoModule != null && deployModule != null)
                {
                    Logger.Info("Cargo bay found");
                    if (cargoModule.ClosedAndLocked() || this.deployModule.IsMoving())
                    {
                        Events["DepositParts"].active = false;
                        Events["TakeParts"].active    = false;
                    }
                    else
                    {
                        if (!this.deployModule.IsMoving())
                        {
                            Events["DepositParts"].active = true;
                            Events["TakeParts"].active    = true;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static bool IsUnfiredDecoupler(this Part p)
        {
            bool isFairing = false;

            for (int i = 0; i < p.Modules.Count; i++)
            {
                PartModule m = p.Modules[i];

                ModuleDecouple mDecouple = m as ModuleDecouple;
                if (mDecouple != null)
                {
                    if (!mDecouple.isDecoupled && mDecouple.stagingEnabled && p.stagingOn)
                    {
                        return(true);
                    }
                    break;
                }

                ModuleAnchoredDecoupler mAnchoredDecoupler = m as ModuleAnchoredDecoupler;
                if (mAnchoredDecoupler != null)
                {
                    if (!mAnchoredDecoupler.isDecoupled && mAnchoredDecoupler.stagingEnabled && p.stagingOn)
                    {
                        return(true);
                    }
                    break;
                }

                ModuleDockingNode mDockingNode = m as ModuleDockingNode;
                if (mDockingNode != null)
                {
                    if (mDockingNode.staged && mDockingNode.stagingEnabled && p.stagingOn)
                    {
                        return(true);
                    }
                    break;
                }

                if (m is ModuleProceduralFairing)
                {
                    isFairing = true;
                }

                if (isFairing)
                {
                    if (VesselState.isLoadedFAR && m.stagingEnabled && p.stagingOn)
                    {
                        return(true);
                    }

                    else
                    if (m is ModuleCargoBay)
                    {
                        ModuleCargoBay fairing = m as ModuleCargoBay;
                        if (fairing.ClosedAndLocked() && m.stagingEnabled && p.stagingOn)
                        {
                            return(true);
                        }
                        break;
                    }
                }

                if (VesselState.isLoadedProceduralFairing && m.moduleName == "ProceduralFairingDecoupler")
                {
                    if (!m.Fields["decoupled"].GetValue <bool>(m) && m.stagingEnabled && p.stagingOn)
                    {
                        return(true);
                    }
                    break;
                }
            }
            return(false);
        }