diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index 0305b24fa2..9bee944da2 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -1440,27 +1440,32 @@ public Unit getUnit(UUID id) { // region Personnel // region Person Creation /** - * Creates a new {@link Person} instance who is a dependent. - * If {@code baby} is false and the random dependent origin option is enabled, - * the new person will have a random origin. + * Creates a new dependent with given gender. The origin faction and planet are set to null. * - * @param baby a boolean indicating if the person is a baby or not - * @param gender the Gender enum for the person (should normally be Gender.RANDOMIZE) - * @return a new {@link Person} instance who is a dependent - */ - public Person newDependent(boolean baby, Gender gender) { - Person person; - - if ((!baby) && (getCampaignOptions().getRandomOriginOptions().isRandomizeDependentOrigin())) { - person = newPerson(PersonnelRole.DEPENDENT, PersonnelRole.NONE, - new DefaultFactionSelector(getCampaignOptions().getRandomOriginOptions()), - new DefaultPlanetSelector(getCampaignOptions().getRandomOriginOptions()), - gender); - } else { - person = newPerson(PersonnelRole.DEPENDENT); - } + * @param gender The {@link Gender} of the new dependent. + * @return Return a {@link Person} object representing the new dependent. + */ + public Person newDependent(Gender gender) { + return newDependent(gender, null, null); + } - return person; + /** + * Creates a new dependent with given gender, origin faction and origin planet. + * + * @param gender The {@link Gender} of the new dependent. + * @param originFaction The {@link Faction} that represents the origin faction for the new dependent. + * This can be null, suggesting the faction will be chosen based on campaign options. + * @param originPlanet The {@link Planet} that represents the origin planet for the new dependent. + * This can be null, suggesting the planet will be chosen based on campaign options. + * @return Return a {@link Person} object representing the new dependent. + */ + public Person newDependent(Gender gender, @Nullable Faction originFaction, + @Nullable Planet originPlanet) { + return newPerson(PersonnelRole.DEPENDENT, + PersonnelRole.NONE, + new DefaultFactionSelector(getCampaignOptions().getRandomOriginOptions(), originFaction), + new DefaultPlanetSelector(getCampaignOptions().getRandomOriginOptions(), originPlanet), + gender); } /** @@ -4451,7 +4456,7 @@ void dependentsAddNew(int dependentCount, int dependentCapacity) { } if (roll <= (getAtBUnitRatingMod() * 2)) { - final Person dependent = newDependent(false, Gender.RANDOMIZE); + final Person dependent = newDependent(Gender.RANDOMIZE); recruitPerson(dependent, PrisonerStatus.FREE, true, false); diff --git a/MekHQ/src/mekhq/campaign/mission/AtBContract.java b/MekHQ/src/mekhq/campaign/mission/AtBContract.java index 1bd588e19f..9b45452716 100644 --- a/MekHQ/src/mekhq/campaign/mission/AtBContract.java +++ b/MekHQ/src/mekhq/campaign/mission/AtBContract.java @@ -664,7 +664,7 @@ public void doBonusRoll(Campaign campaign) { campaign.addReport("Bonus: " + number + " dependent" + ((number > 1) ? "s" : "")); for (int i = 0; i < number; i++) { - Person p = campaign.newDependent(false, Gender.RANDOMIZE); + Person p = campaign.newDependent(Gender.RANDOMIZE); campaign.recruitPerson(p); } } diff --git a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java index 3f5ef99913..b2e0183c50 100644 --- a/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java +++ b/MekHQ/src/mekhq/campaign/personnel/marriage/AbstractMarriage.java @@ -376,7 +376,7 @@ protected void marryRandomSpouse(final Campaign campaign, final LocalDate today, * @return the created external spouse */ Person createExternalSpouse(final Campaign campaign, final LocalDate today, final Person person, Gender gender) { - Person externalSpouse = campaign.newDependent(false, gender); + Person externalSpouse = campaign.newDependent(gender); // Calculate person's age and the maximum and minimum allowable spouse ages diff --git a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java index 7d2794d92e..ec222bdc44 100644 --- a/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java +++ b/MekHQ/src/mekhq/campaign/personnel/procreation/AbstractProcreation.java @@ -36,6 +36,8 @@ import mekhq.campaign.personnel.education.EducationController; import mekhq.campaign.personnel.enums.*; import mekhq.campaign.personnel.enums.education.EducationLevel; +import mekhq.campaign.universe.Faction; +import mekhq.campaign.universe.Planet; import java.time.LocalDate; import java.time.temporal.ChronoUnit; @@ -337,7 +339,8 @@ public void birth(final Campaign campaign, final LocalDate today, final Person m // Create Babies for (int i = 0; i < size; i++) { // Create a baby - final Person baby = campaign.newDependent(true, Gender.RANDOMIZE); + final Person baby = campaign.newDependent( + Gender.RANDOMIZE, mother.getOriginFaction(), campaign.getLocation().getPlanet()); baby.setSurname(campaign.getCampaignOptions().getBabySurnameStyle() .generateBabySurname(mother, father, baby.getGender())); baby.setDateOfBirth(today); @@ -436,7 +439,15 @@ public List birthHistoric(final Campaign campaign, final LocalDate today // Create Babies for (int i = 0; i < size; i++) { // Create the babies - final Person baby = campaign.newDependent(true, Gender.RANDOMIZE); + Faction originFaction = mother.getOriginFaction(); + Planet originPlanet = mother.getOriginPlanet(); + + if (father != null && Compute.randomInt(1) == 0) { + originFaction = father.getOriginFaction(); + originPlanet = father.getOriginPlanet(); + } + + final Person baby = campaign.newDependent(Gender.RANDOMIZE, originFaction, originPlanet); baby.setSurname(campaign.getCampaignOptions().getBabySurnameStyle() .generateBabySurname(mother, father, baby.getGender()));