コード例 #1
0
        public override void OnStart(StartState state)
        {
            // TODO Consider deprecating checkForDecoupling; it should no longer be necessary
            //GameEvents.onStageSeparation.Add (checkForDecoupling);
            GameEvents.onVesselWasModified.Add(OnVesselWasModified);

            cargoBay = part.FindModuleImplementing <ModuleCargoBay> ();
            base.OnStart(state);
            Debug.Log("ModuleAnimatedDecoupler.OnStart(), isDecoupled = " + this.isDecoupled.ToString());
            if (animationName != "")
            {
                anim = part.FindModelAnimators(animationName).FirstOrDefault();
                if ((object)this.anim == null)
                {
                    Debug.Log("ModuleAnimatedDecoupler: Animations not found");
                }
                else
                {
                    Debug.Log("ModuleAnimatedDecoupler.OnStart() - Animation found named " + animationName);
                    // If Decoupled or animation already played then set animation to end.
                    this.anim[animationName].layer = layer;
                    if (this.animationComplete || this.isDecoupled)
                    {
                        this.anim[animationName].normalizedTime = 1f;
                    }
                }
            }
        }
コード例 #2
0
ファイル: CargoBay.cs プロジェクト: Kerbal007/krpc
 internal CargoBay(Part part)
 {
     this.part = part;
     bay       = part.InternalPart.Module <ModuleCargoBay> ();
     animation = part.InternalPart.Module <ModuleAnimateGeneric> ();
     if (bay == null || animation == null)
     {
         throw new ArgumentException("Part is not a cargo bay");
     }
 }
コード例 #3
0
ファイル: CargoBay.cs プロジェクト: zentarul/krpc
        internal CargoBay(Part part)
        {
            if (!Is(part))
            {
                throw new ArgumentException("Part is not a cargo bay");
            }
            Part = part;
            var internalPart = part.InternalPart;

            bay       = internalPart.Module <ModuleCargoBay> ();
            animation = internalPart.Module <ModuleAnimateGeneric> ();
        }
コード例 #4
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;
                        }
                    }
                }
            }
        }
コード例 #5
0
 private void FindCargoBay()
 {
     cargoBay = part.Modules.OfType <ModuleCargoBay>().Where(module => module.DeployModuleIndex == part.Modules.IndexOf(this)).FirstOrDefault();
 }
コード例 #6
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);
        }
 public override void OnStart(StartState state)
 {
     // TODO Consider deprecating checkForDecoupling; it should no longer be necessary
     //GameEvents.onStageSeparation.Add (checkForDecoupling);
     GameEvents.onVesselWasModified.Add (OnVesselWasModified);
     cargoBay = part.FindModuleImplementing<ModuleCargoBay> ();
     base.OnStart (state);
     Debug.Log ("ModuleAnimatedAnchoredDecoupler.OnStart(), isDecoupled = " + isDecoupled.ToString ());
     if (animationName != "")
     {
         anim = part.FindModelAnimators(animationName).FirstOrDefault ();
         if ((object)anim == null)
         {
             Debug.Log ("ModuleAnimatedAnchoredDecoupler: Animations not found");
         }
         else
         {
             Debug.Log ("ModuleAnimatedAnchoredDecoupler.OnStart() - Animation found named " + animationName);
             if (this.animationComplete || this.isDecoupled)
             // If Decoupled or animation already played then set animation to end.
             {
                 this.anim[animationName].normalizedTime = 1f;
             }
         }
     }
 }