예제 #1
0
        public void Maintenance()
        {
            this.Log("Initiating EVA maitenance");

            // Get the EVA part (parts can hold resources)
            Part evaPart = DangIt.FindEVAPart();
            if (evaPart == null)
            {
                DangIt.Broadcast("DangIt ERROR: couldn't find an active EVA!");
                this.Log("ERROR: couldn't find an active EVA!");
                return;
            }

            // Check if he is carrying enough spares
            if (evaPart.Resources.Contains(Spares.Name) && evaPart.Resources[Spares.Name].amount >= this.MaintenanceCost)
            {
                this.Log("Spare parts check: OK! Maintenance allowed allowed");
                DiscountAge(this.MaintenanceBonus);
                DangIt.Broadcast("This should last a little longer now");
            }
            else
            {
                this.Log("Spare parts check: failed! Maintenance NOT allowed");
                DangIt.Broadcast("You need " + this.MaintenanceCost + " spares to maintain this.");
            }
        }
예제 #2
0
        public virtual string ExtraEditorInfo { get { return ""; } }  // extra descriptive info for the

      
        /// <summary>
        /// Returns the string that is displayed during an inspection.
        /// </summary>
        public virtual string 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";
        }
예제 #3
0
        public void EvaRepair()
        {
            try
            {
                this.Log("Initiating EVA repair");

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

                if (evaPart == null)
                {
                    DangIt.Broadcast("DangIt ERROR: couldn't find an active EVA!");
                    this.Log("ERROR: couldn't find an active EVA!");
                    return;
                }

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

                    this.DI_EvaRepair();
                    this.SetFailureState(false);

                    DangIt.FlightLog(this.RepairMessage);

                    float intelligence = 1 - evaPart.vessel.GetVesselCrew().First().stupidity;
                    float discountedCost = (float)Math.Round( RepairCost * (1 - UnityEngine.Random.Range(0f, intelligence)) );
                    float discount = RepairCost - discountedCost;

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

                    evaPart.RequestResource(Spares.Name, discountedCost);
                    ResourceDisplay.Instance.Refresh();

                    DangIt.Broadcast(this.RepairMessage, true);

                    DiscountAge(this.RepairBonus);

                    if (discount > 0)
                    {
                        DangIt.Broadcast(evaPart.vessel.GetVesselCrew().First().name + " was able to save " + discount + " spare parts");
                    }

                }
                else
                {
                    this.Log("Spare parts check: failed! Repair NOT allowed");
                    DangIt.Broadcast("You need " + this.RepairCost + " spares to repair this.", true);
                }

                DangIt.ResetShipGlow(this.part.vessel);

            }
            catch (Exception e)
            {
                OnError(e);
            }
        }
예제 #4
0
        public void EvaRepair()
        {
            try
            {
                this.Log("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.Log("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");
                    }

                    FindObjectOfType <AlarmManager>().RemoveAllAlarmsForModule(this);                    //Remove alarms from this module
                }

                DangIt.ResetShipGlow(this.part.vessel);
            }
            catch (Exception e)
            {
                OnError(e);
            }
        }
예제 #5
0
        public void Maintenance()
        {
            this.Log("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.Log("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.Log("Spare parts check: failed! Maintenance NOT allowed");
                DangIt.Broadcast("You need " + this.MaintenanceCost + " spares to maintain this.");
            }
        }
예제 #6
0
        public void DepositParts()
        {
            Part evaPart = DangIt.FindEVAPart();

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

            Events["DepositParts"].active = false;

            GameEvents.onCrewBoardVessel.Remove(OnCrewBoardVessel);
            eventAdded = false;
        }
예제 #7
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;
            }
        }