Esempio n. 1
0
        public static void manageRescueMission(Vessel v)
        {
            // true if we detected this was a rescue mission vessel
            bool detected = false;

            // deal with rescue missions
            foreach (ProtoCrewMember c in Lib.CrewList(v))
            {
                // get kerbal data
                KerbalData kd = DB.Kerbal(c.name);

                // flag the kerbal as not rescue at prelaunch
                if (v.situation == Vessel.Situations.PRELAUNCH)
                {
                    kd.rescue = false;
                }

                // if the kerbal belong to a rescue mission
                if (kd.rescue)
                {
                    // remember it
                    detected = true;

                    // flag the kerbal as non-rescue
                    // note: enable life support mechanics for the kerbal
                    kd.rescue = false;

                    // show a message
                    Message.Post(Lib.BuildString("We found <b>", c.name, "</b>"), Lib.BuildString((c.gender == ProtoCrewMember.Gender.Male ? "He" : "She"), "'s still alive!"));
                }
            }

            // gift resources
            if (detected)
            {
                var reslib = PartResourceLibrary.Instance.resourceDefinitions;
                var parts  = Lib.GetPartsRecursively(v.rootPart);

                // give the vessel some propellant usable on eva
                string monoprop_name   = Lib.EvaPropellantName();
                double monoprop_amount = Lib.EvaPropellantCapacity();
                foreach (var part in parts)
                {
                    if (part.CrewCapacity > 0 || part.FindModuleImplementing <KerbalEVA>() != null)
                    {
                        if (Lib.Capacity(part, monoprop_name) <= double.Epsilon)
                        {
                            Lib.AddResource(part, monoprop_name, 0.0, monoprop_amount);
                        }
                        break;
                    }
                }
                ResourceCache.Produce(v, monoprop_name, monoprop_amount);

                // give the vessel some supplies
                Profile.SetupRescue(v);
            }
        }
Esempio n. 2
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));
        }
Esempio n. 3
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;
         }
     }
 }