public void recruit() { double inspirationRes, educationRes, flightExperienceRes, maxAmount; vessel.resourcePartSet.GetConnectedResourceTotals(inspirationID, out inspirationRes, out maxAmount, true); if (inspirationRes < HighLogic.CurrentGame.Parameters.CustomParams <CP>().inspirationCost) { return; } // repo.GetLivingRosterForVessel(vessel.GetId()) CivilianPopulationRecruitmentService service = new CivilianPopulationRecruitmentService(recruitmentTraits); foreach (ProtoCrewMember crewMember in part.protoModuleCrew) { if (crewMember.trait == "Civilian") { int engineer, pilot, scientist; applyTheaterBonus(out engineer, out pilot, out scientist); vessel.resourcePartSet.GetConnectedResourceTotals(educationID, out educationRes, out maxAmount, true); vessel.resourcePartSet.GetConnectedResourceTotals(flightExperienceID, out flightExperienceRes, out maxAmount, true); string trait = service.selectTrait(engineer, pilot, scientist, educationRes, flightExperienceRes, HighLogic.CurrentGame.Parameters.CustomParams <CP>().educationCost, HighLogic.CurrentGame.Parameters.CustomParams <CP>().flightExperienceCost); if (trait != "") { crewMember.trait = trait; Log.Info(crewMember.name + " is now a " + crewMember.trait + "!"); //RequestResource(Part part, int id, double demand, bool usePri) //vessel.resourcePartSet.RequestResource(this.part, inspirationID, inspirationCost, true); double d = this.part.RequestResource(inspirationID, HighLogic.CurrentGame.Parameters.CustomParams <CP>().inspirationCost); switch (trait) { case "Engineer": d = this.part.RequestResource(educationID, HighLogic.CurrentGame.Parameters.CustomParams <CP>().educationCost); break; case "Scientist": d = this.part.RequestResource(educationID, HighLogic.CurrentGame.Parameters.CustomParams <CP>().educationCost); break; case "Pilot": d = this.part.RequestResource(flightExperienceID, HighLogic.CurrentGame.Parameters.CustomParams <CP>().flightExperienceCost); break; } vessel.resourcePartSet.GetConnectedResourceTotals(educationID, out educationRes, out maxAmount, true); vessel.resourcePartSet.GetConnectedResourceTotals(flightExperienceID, out flightExperienceRes, out maxAmount, true); } } } }
public void recruit() { CivilianPopulationRecruitmentService service = new CivilianPopulationRecruitmentService(recruitmentTraits); foreach (ProtoCrewMember crewMember in part.protoModuleCrew) { if (crewMember.trait == "Civilian") { string trait = service.selectTrait(); crewMember.trait = trait; log(crewMember.name + " is now a " + crewMember.trait + "!"); } } }
public void recruit() { double inspirationRes, educationRes, flightExperienceRes, maxAmount; SimpleLogger.fetch.Info("recruit"); vessel.resourcePartSet.GetConnectedResourceTotals(inspirationID, out inspirationRes, out maxAmount, true); SimpleLogger.fetch.Info("recruit, inspirationRes: " + inspirationRes + ", inspirationCost: " + inspirationCost); if (inspirationRes < inspirationCost) { return; } // repo.GetLivingRosterForVessel(vessel.GetId()) CivilianPopulationRecruitmentService service = new CivilianPopulationRecruitmentService(recruitmentTraits); foreach (ProtoCrewMember crewMember in part.protoModuleCrew) { SimpleLogger.fetch.Info("recruit, name: " + crewMember.name + ", " + crewMember.trait); if (crewMember.trait == "Civilian") { int engineer, pilot, scientist; SimpleLogger.fetch.Info("recruit, name: " + crewMember.name); applyTheaterBonus(out engineer, out pilot, out scientist); vessel.resourcePartSet.GetConnectedResourceTotals(educationID, out educationRes, out maxAmount, true); vessel.resourcePartSet.GetConnectedResourceTotals(flightExperienceID, out flightExperienceRes, out maxAmount, true); SimpleLogger.fetch.Info("recruit, available educationRes: " + educationRes); SimpleLogger.fetch.Info("recruit, available flightExperienceRes: " + flightExperienceRes); string trait = service.selectTrait(engineer, pilot, scientist, educationRes, flightExperienceRes, educationCost, flightExperienceCost); if (trait != "") { crewMember.trait = trait; log(crewMember.name + " is now a " + crewMember.trait + "!"); //RequestResource(Part part, int id, double demand, bool usePri) //vessel.resourcePartSet.RequestResource(this.part, inspirationID, inspirationCost, true); double d = this.part.RequestResource(inspirationID, inspirationCost); SimpleLogger.fetch.Info("this.part.RequestResource, inspiration, returned" + d); switch (trait) { case "Engineer": d = this.part.RequestResource(educationID, educationCost); SimpleLogger.fetch.Info("Engineer, this.part.RequestResource, education, returned" + d); break; case "Scientist": d = this.part.RequestResource(educationID, educationCost); SimpleLogger.fetch.Info("Scientist, this.part.RequestResource, education, returned" + d); break; case "Pilot": d = this.part.RequestResource(flightExperienceID, flightExperienceCost); SimpleLogger.fetch.Info("Pilot, this.part.RequestResource, flightExperience, returned" + d); break; } vessel.resourcePartSet.GetConnectedResourceTotals(educationID, out educationRes, out maxAmount, true); vessel.resourcePartSet.GetConnectedResourceTotals(flightExperienceID, out flightExperienceRes, out maxAmount, true); SimpleLogger.fetch.Info("recruit, after, available educationRes: " + educationRes); SimpleLogger.fetch.Info("recruit, after, available flightExperienceRes: " + flightExperienceRes); } } } }