diff --git a/Languages/English/Keyed/Manager_Keyed.xml b/Languages/English/Keyed/Manager_Keyed.xml index 85337429..36281c77 100644 --- a/Languages/English/Keyed/Manager_Keyed.xml +++ b/Languages/English/Keyed/Manager_Keyed.xml @@ -198,6 +198,8 @@ Restrict animals with milk fullness above 94% to a specific area. Restrict animals ready to be sheared Restrict animals with shearing fullness above 94% to a specific area + Restrict animals that are sick/injured + Restrict animals that are sick/injured to a specific area Target counts Area restrictions Training diff --git a/Source/Helpers/Livestock/Utilities_Livestock.cs b/Source/Helpers/Livestock/Utilities_Livestock.cs index feef068e..f49fee79 100644 --- a/Source/Helpers/Livestock/Utilities_Livestock.cs +++ b/Source/Helpers/Livestock/Utilities_Livestock.cs @@ -404,6 +404,14 @@ public static bool VisiblyPregnant( this Pawn pawn ) return pawn?.health.hediffSet.GetHediffs().Any( hp => hp.Visible ) ?? false; } + public static bool AnimalIsSick( this Pawn pawn ) + { + if (pawn.health.hediffSet.HasImmunizableNotImmuneHediff()) { return true; } + if (pawn.health.HasHediffsNeedingTend()) { return true; } + if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Moving)) { return true; } + return false; + } + private static bool _milkable( this Pawn pawn ) { var comp = pawn?.TryGetComp(); diff --git a/Source/ManagerJobs/ManagerJob_Livestock.cs b/Source/ManagerJobs/ManagerJob_Livestock.cs index ca73a189..de14aff7 100644 --- a/Source/ManagerJobs/ManagerJob_Livestock.cs +++ b/Source/ManagerJobs/ManagerJob_Livestock.cs @@ -29,12 +29,14 @@ public class ManagerJob_Livestock : ManagerJob public bool RespectBonds = true; public List RestrictArea; public bool RestrictToArea; + public bool SendToSickArea; public bool SendToMilkingArea; public bool SendToShearingArea; public bool SendToSlaughterArea; public bool SendToTrainingArea; public bool SetFollow; public Area ShearArea; + public Area SickArea; public Area SlaughterArea; public Area TameArea; public Pawn Trainer; @@ -79,6 +81,10 @@ public ManagerJob_Livestock( Manager manager ) : base( manager ) SendToSlaughterArea = false; SlaughterArea = null; + // set up sick area + SendToSickArea = false; + SickArea = null; + // set up milking area SendToMilkingArea = false; MilkArea = null; @@ -306,6 +312,7 @@ public override void ExposeData() // settings, references first! Scribe_References.Look( ref TameArea, "TameArea" ); + Scribe_References.Look( ref SickArea, "SickArea" ); Scribe_References.Look( ref SlaughterArea, "SlaughterArea" ); Scribe_References.Look( ref MilkArea, "MilkArea" ); Scribe_References.Look( ref ShearArea, "ShearArea" ); @@ -322,6 +329,7 @@ public override void ExposeData() Scribe_Values.Look( ref ButcherBonded, "ButcherBonded" ); Scribe_Values.Look( ref RestrictToArea, "RestrictToArea" ); Scribe_Values.Look( ref SendToSlaughterArea, "SendToSlaughterArea" ); + Scribe_Values.Look( ref SendToSickArea, "SendToSickArea" ); Scribe_Values.Look( ref SendToMilkingArea, "SendToMilkingArea" ); Scribe_Values.Look( ref SendToShearingArea, "SendToShearingArea" ); Scribe_Values.Look( ref SendToTrainingArea, "SendToTrainingArea" ); @@ -510,6 +518,17 @@ private void DoAreaRestrictions( ref bool actionTaken ) p.playerSettings.AreaRestriction = SlaughterArea; } + // sick + else if (SendToSickArea && p.AnimalIsSick()) + { + if (p.playerSettings.AreaRestriction != SickArea) + { + actionTaken = true; + p.playerSettings.AreaRestriction = SickArea; + } + } + + // milking else if ( SendToMilkingArea && p.GetComp() != null && diff --git a/Source/ManagerTabs/ManagerTab_Livestock.cs b/Source/ManagerTabs/ManagerTab_Livestock.cs index 597a1c26..e8d1d355 100644 --- a/Source/ManagerTabs/ManagerTab_Livestock.cs +++ b/Source/ManagerTabs/ManagerTab_Livestock.cs @@ -539,6 +539,27 @@ private float DrawAreaRestrictionsSection( Vector2 pos, float width ) color: Color.grey ); } + // i think all tamed animals can at least require tending, if not get sick + // if there is some def-wide tamable animal that never gets sick or needs tending + // like pet mechanoids or something, that condition would go here. idk what it is. + if (true) + { + var sendToSickAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + pos.y += ListEntryHeight; + DrawToggle(sendToSickAreaRect, + "FML.SendToSickArea".Translate(), + "FML.SendToSickArea.Tip".Translate(), + ref _selectedCurrent.SendToSickArea); + + if (_selectedCurrent.SendToSickArea) + { + var sickAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + AreaAllowedGUI.DoAllowedAreaSelectors(sickAreaRect, ref _selectedCurrent.SickArea, + manager); + pos.y += ListEntryHeight; + } + } + if ( _selectedCurrent.Trigger.pawnKind.Milkable() ) { var sendToMilkingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight );