Пример #1
0
        public void FixedUpdate()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            double kw    = Math.Abs(this.part.thermalRadiationFlux);
            Part   rPart = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, resourceName);

            if (rPart != null)
            {
                int    id     = MPFunctions.GetResourceID(rPart, resourceName);
                double rTotal = MPFunctions.GetResourceTotal(FlightGlobals.ActiveVessel, resourceName);
                double rMax   = MPFunctions.GetResourceMax(FlightGlobals.ActiveVessel, resourceName);
                transAmt = resourceAmt * kw;
                if (actRad == true)     // look for active radiator
                {
                    for (int i = this.part.Modules.Count - 1; i >= 0; --i)
                    {
                        PartModule M = this.part.Modules[i];
                        if (M is ModuleActiveRadiator)
                        {
                            if ((M as ModuleActiveRadiator).IsCooling)
                            {
                                rPart.TransferResource(id, transAmt);
                            }
                        }
                    }
                }
                else
                {
                    rPart.TransferResource(id, transAmt);
                }
            }
        }
Пример #2
0
        public void BlowBallast()
        {
            int id = MPFunctions.GetResourceID(Part1, "CompressedWater");

            Part1.TransferResource(id, -MPFunctions.GetResourceAmount(Part1, "CompressedWater"));
            Part2.TransferResource(id, -MPFunctions.GetResourceAmount(Part2, "CompressedWater"));
        }
Пример #3
0
 public void Start()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         foreach (Part mypart in this.vessel.parts)
         {
             if (mypart.Resources.Contains("CompressedWater"))
             {
                 if (rescount == 0)
                 {
                     Part1 = mypart;
                 }
                 if (rescount == 1)
                 {
                     Part2 = mypart;
                 }
                 rescount++;
             }
         }
         MPLog.Writelog("[Maritime Pack] Compressed Water Found: " + rescount);
         id           = MPFunctions.GetResourceID(Part1, "CompressedWater");
         batid        = MPFunctions.GetResourceID(Part1, "ElectricCharge");
         vesselvolume = MPFunctions.GetVolume(this.vessel);
     }
 }
Пример #4
0
 public void FixedUpdate()
 {
     if (!HighLogic.LoadedSceneIsFlight)
     {
         return;
     }
     for (int i = this.part.Modules.Count - 1; i >= 0; --i)
     {
         PartModule M = this.part.Modules[i];
         if (M is ModuleDeployableSolarPanel)
         {
             if ((M as ModuleDeployableSolarPanel).deployState == ModuleDeployableSolarPanel.DeployState.EXTENDED)
             {
                 Double CWTotal   = MPFunctions.GetResourceTotal(this.vessel, "CompressedWater");
                 Double elecTotal = MPFunctions.GetResourceTotal(this.vessel, "ElectricCharge");
                 if (CWTotal <= 0 || elecTotal <= 0)
                 {
                     if (CWTotal <= 0)
                     {
                         (M as ModuleDeployableSolarPanel).status = "No Compressed Water";
                     }
                     else
                     {
                         (M as ModuleDeployableSolarPanel).status = "No Electric Charge";
                     }
                     (M as ModuleDeployableSolarPanel).enabled = false;
                 }
                 else
                 {
                     (M as ModuleDeployableSolarPanel).enabled = true;
                     float thisflow = (M as ModuleDeployableSolarPanel).flowRate;
                     if (thisflow > 0)
                     {
                         Part   sPart  = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, "CompressedWater");
                         int    CWID   = MPFunctions.GetResourceID(sPart, "CompressedWater");
                         double CWFlow = sPart.RequestResource(CWID, thisflow * CWRate, ResourceFlowMode.ALL_VESSEL);
                         sPart = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, "ElectricCharge");
                         int EcID = MPFunctions.GetResourceID(sPart, "ElectricCharge");
                         sPart.RequestResource(EcID, CWFlow * elRate, ResourceFlowMode.ALL_VESSEL);
                     }
                 }
             }
             else
             {
                 (M as ModuleDeployableSolarPanel).enabled = true;
             }
         }
     }
 }
Пример #5
0
        public bool ConsumeResource(string thisresource, double amount)
        {
            Part   rPart  = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, thisresource);
            double rTotal = MPFunctions.GetResourceTotal(FlightGlobals.ActiveVessel, pressureResource1);

            if (rPart != null && rTotal >= amount)
            {
                int    id    = MPFunctions.GetResourceID(rPart, thisresource);
                double rFlow = rPart.RequestResource(id, amount, ResourceFlowMode.ALL_VESSEL);
                if (rFlow > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #6
0
 public void FixedUpdate()
 {
     varPeriod -= Time.deltaTime;
     if (varPeriod < 0)
     {
         varPeriod = decayPeriod;
         resPart   = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, resourceName);
         resID     = MPFunctions.GetResourceID(resPart, resourceName);
         resAmt    = MPFunctions.GetResourceTotal(FlightGlobals.ActiveVessel, resourceName);
         if (resPart != null && resAmt > 0)
         {
             try
             {
                 resPart.RequestResource(resID, decayAmount, ResourceFlowMode.ALL_VESSEL);
             }
             catch
             {
                 MPLog.Writelog("[Maritime Pack] ResDecay: Error removing resource");
             }
         }
     }
 }