Example #1
0
        public void EvaRepair()
        {
            try
            {
                this.FailureLog("Initiating EVA repair");

                // Get the EVA part (parts can hold resources)
                Part evaPart = DangIt.FindEVAPart();

                if (evaPart == null)
                {
                    throw new Exception("ERROR: couldn't find an active EVA!");
                }

                // Check if the kerbal is able to perform the repair
                if (CheckRepairConditions(evaPart))
                {
                    this.DI_EvaRepair();
                    this.SetFailureState(false);

                    DangIt.FlightLog(this.RepairMessage);

                    //TODO: experience repair boni
                    float intelligence   = 1 - evaPart.protoModuleCrew[0].stupidity;
                    float discountedCost = (float)Math.Round(RepairCost * (1 - UnityEngine.Random.Range(0f, intelligence)));
                    float discount       = RepairCost - discountedCost;

                    this.FailureLog("Kerbal's intelligence: " + intelligence + ", discount: " + discount);

                    // One more MC2 hack - TrypChangeling
                    // evaPart.RequestResource(Spares.Name, discountedCost);
                    evaPart.Resources[Spares.Name].amount -= discountedCost;
                    ResourceDisplay.Instance.Refresh();

                    DangIt.Broadcast(this.RepairMessage, true);
                    this.DiscountAge(this.RepairBonus);

                    if (discount > 0)
                    {
                        DangIt.Broadcast(evaPart.protoModuleCrew[0].name + " was able to save " + discount + " spare parts");
                    }
                    AlarmManager alarmManager = FindObjectOfType <AlarmManager>();
                    alarmManager.RemoveAllAlarmsForModule(this); //Remove alarms from this module
                    RemoveBCRepaired(this.part);
                    DisableAlarm(false);
                }
            }
            catch (Exception e)
            {
                OnError(e);
            }
        }
Example #2
0
        }                                                             // extra descriptive info for the


        /// <summary>
        /// Returns the string that is displayed during an inspection.
        /// </summary>
        public virtual string InspectionMessage()
        {
            Log.Info("InspectionMessage");

            if (this.HasFailed)
            {
                return("the part has failed!");
            }

            // The same experience that is needed for repair is also needed to inspect the element
            Part evaPart = DangIt.FindEVAPart();

            if (evaPart != null)
            {
                if (!CheckOutExperience(evaPart.protoModuleCrew[0]))
                {
                    return(evaPart.protoModuleCrew[0].name + " isn't quite sure about this...");
                }
            }

            // Perks check out, return a message based on the age
            float ratio = this.Age / this.LifeTimeSecs;

            if (ratio < 0.10)
            {
                return("This part seems to be as good as new");
            }
            else if (ratio < 0.50)
            {
                return("This part is still in good condition");
            }
            else if (ratio < 0.75)
            {
                return("This part is starting to show its age");
            }
            else if (ratio < 1.25)
            {
                return("It looks like it's time to get a new one");
            }
            else if (ratio < 2.00)
            {
                return("It really isn't a good idea to keep using this part");
            }
            else if (ratio < 3)
            {
                return("This part needs replacing soon");
            }
            else
            {
                return("This part is in terrible condition");
            }
        }
Example #3
0
        public void Maintenance()
        {
            this.FailureLog("Initiating EVA maitenance");

            Part evaPart = DangIt.FindEVAPart();

            if (evaPart == null)
            {
                throw new Exception("ERROR: couldn't find an active EVA!");
            }

            if (!CheckOutExperience(evaPart.protoModuleCrew[0]))
            {
                DangIt.Broadcast(evaPart.protoModuleCrew[0].name + " isn't really qualified for this...", true);
                return;
            }

            if (this.part.temperature > DangIt.Instance.CurrentSettings.GetMaxServicingTemp())
            {
                DangIt.Broadcast("This is too hot to service right now", true);
                return;
            }


            // Check if he is carrying enough spares
            if (evaPart.Resources.Contains(Spares.Name) && evaPart.Resources[Spares.Name].amount >= this.MaintenanceCost)
            {
                this.FailureLog("Spare parts check: OK! Maintenance allowed allowed");

                // Consume the spare parts
                // MC2 Breaks RequestResource, since amount is checked, simply decrement! Just like in SparesContainer! Whee! -TrypChangeling
                // evaPart.RequestResource(Spares.Name, this.MaintenanceCost);
                evaPart.Resources[Spares.Name].amount -= this.MaintenanceCost;

                // Distance between the kerbal's perks and the required perks, used to scale the maintenance bonus according to the kerbal's skills
                int expDistance = evaPart.protoModuleCrew[0].experienceLevel - this.PerksRequirementValue;

                //// The higher the skill gap, the higher the maintenance bonus
                //// The + 1 is there to makes it so that a maintenance bonus is always gained even when the perks match exactly
                this.DiscountAge(this.MaintenanceBonus * ((expDistance + 1) / 3));

                DangIt.Broadcast("This should last a little longer now");
            }
            else
            {
                this.FailureLog("Spare parts check: failed! Maintenance NOT allowed");
                DangIt.Broadcast("You need " + this.MaintenanceCost + " spares to maintain this.");
            }
        }
Example #4
0
        public void DepositParts()
        {
            Part evaPart = DangIt.FindEVAPart();

            if (evaPart == null)
            {
                Log.Error("ERROR: couldn't find an active EVA!");
            }
            else
            {
                EmptyEvaSuit(evaPart, this.part);
            }

            Events["DepositParts"].active = false;

            GameEvents.onCrewBoardVessel.Remove(OnCrewBoardVessel);
            eventAdded = false;
        }
Example #5
0
        public void TakeParts()
        {
            Part evaPart = DangIt.FindEVAPart();


            if (evaPart == null)
            {
                throw new Exception("ERROR: couldn't find an active EVA!");
            }
            else
            {
                FillEvaSuit(evaPart, this.part);
            }

            Events["DepositParts"].active = true;

            if (!eventAdded)
            {
                GameEvents.onCrewBoardVessel.Add(OnCrewBoardVessel);
                eventAdded = true;
            }
        }