Example #1
0
 public override void OnUpdate()
 {
     if (FreezerEngaged)
     {
         CryoTime   = LifeSupportUtilities.SmartDurationDisplay(Planetarium.GetUniversalTime() - FreezeTime);
         CryoMargin = String.Format("{0:0.00}%", (1 - CalculateMargin()) * 100);
     }
     else
     {
         CryoTime   = "Not Active";
         CryoMargin = String.Format("{0:0.00}%", 100f);
     }
     base.OnUpdate();
 }
Example #2
0
        public override void OnUpdate()
        {
            Fields["KerbabyCountdown"].guiActive = KolonyGrowthEnabled;

            // We don't need to update kolony growth hyperactively, once per second is more than sufficient
            var now         = Planetarium.GetUniversalTime();
            var elapsedTime = now - _lastCheck;

            if (elapsedTime >= 1d)
            {
                _lastCheck = now;

                if (KolonyGrowthEnabled && part.CrewCapacity > part.protoModuleCrew.Count)
                {
                    var hasMale   = false;
                    var hasFemale = false;

                    var crew  = vessel.GetVesselCrew();
                    var count = crew.Count;
                    for (int i = 0; i < count; ++i)
                    {
                        var c = crew[i];
                        if (c.gender == ProtoCrewMember.Gender.Male)
                        {
                            hasMale = true;
                        }
                        if (c.gender == ProtoCrewMember.Gender.Female)
                        {
                            hasFemale = true;
                        }
                    }

                    if (hasMale && hasFemale)
                    {
                        // Grow our Kolony!
                        GrowthTime += (elapsedTime * part.protoModuleCrew.Count);
                        if (GrowthTime >= GestationTime)
                        {
                            GrowthTime -= GestationTime;
                            SpawnKerbal();
                        }
                        KerbabyCountdown = LifeSupportUtilities.SmartDurationDisplay(GestationTime - GrowthTime);
                    }
                }
            }
        }