Exemple #1
0
        // return percentage of radiations blocked by shielding
        public static double Shielding(ConnectedLivingSpace.ICLSSpace space)
        {
            double amount   = 0.0;
            double capacity = 0.0;

            foreach (var part in space.Parts)
            {
                amount   += Lib.Amount(part.Part, "Shielding");
                capacity += Lib.Capacity(part.Part, "Shielding");
            }
            return(Shielding(amount, capacity));
        }
Exemple #2
0
 bool resource_loss()
 {
     // detect if any of the setup deal with resources
     // - we are ignoring resources that configured modules may generate on-the-fly
     //   this is okay for our current IConfigurable modules (habitat, process controller, harvester)
     //   however this will not be okay for something like a Container module, for example
     //   if the need arise, add a function bool change_resources() to the IConfigurable interface
     foreach (ConfigureSetup setup in setups)
     {
         foreach (ConfigureResource res in setup.resources)
         {
             if (Lib.Amount(part, res.name, true) > double.Epsilon)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        void ToEVA(GameEvents.FromToAction <Part, Part> data)
        {
            // get total crew in the origin vessel
            double tot_crew = (double)Lib.CrewCount(data.from.vessel) + 1.0;

            // get vessel resources handler
            Vessel_resources resources = ResourceCache.Get(data.from.vessel);

            // setup supply resources capacity in the eva kerbal
            Profile.SetupEva(data.to);

            // for each resource in the kerbal
            for (int i = 0; i < data.to.Resources.Count; ++i)
            {
                // get the resource
                PartResource res = data.to.Resources[i];

                // determine quantity to take
                double quantity = Math.Min(resources.Info(data.from.vessel, res.resourceName).amount / tot_crew, res.maxAmount);

                // remove resource from vessel
                quantity = data.from.RequestResource(res.resourceName, quantity);

                // add resource to eva kerbal
                data.to.RequestResource(res.resourceName, -quantity);
            }

            // show warning if there isn't monoprop in the eva suit
            string prop_name = Lib.EvaPropellantName();

            if (Lib.Amount(data.to, prop_name) <= double.Epsilon && !Lib.Landed(data.from.vessel))
            {
                Message.Post(Severity.danger, Lib.BuildString("There isn't any <b>", prop_name, "</b> in the EVA suit"), "Don't let the ladder go!");
            }

            // turn off headlamp light, to avoid stock bug that show them for a split second when going on eva
            KerbalEVA kerbal = data.to.FindModuleImplementing <KerbalEVA>();

            EVA.HeadLamps(kerbal, false);

            // execute script
            DB.Vessel(data.from.vessel).computer.Execute(data.from.vessel, ScriptType.eva_out);
        }
Exemple #4
0
 public void Update()
 {
     Animation[] anim = this.part.FindModelAnimators(animation_name);
     if (anim.Length > 0)
     {
         double capacity = Lib.Capacity(part, resource_name);
         double level    = capacity > 0.0 ? Lib.Amount(part, resource_name) / capacity : 0.0;
         if (level <= threshold && green_status)
         {
             anim[0][animation_name].normalizedTime = 0.0f;
             anim[0][animation_name].speed          = Math.Abs(anim[0][animation_name].speed);
             anim[0].Play(animation_name);
             green_status = false;
         }
         if (level > threshold && !green_status)
         {
             anim[0][animation_name].normalizedTime = 1.0f;
             anim[0][animation_name].speed          = -Math.Abs(anim[0][animation_name].speed);
             anim[0].Play(animation_name);
             green_status = true;
         }
     }
 }