diff --git a/Assemblies/Manager.dll b/Assemblies/Manager.dll index 65ae8d82..f630a1b4 100644 Binary files a/Assemblies/Manager.dll and b/Assemblies/Manager.dll differ diff --git a/Readme.md b/Readme.md index 800e3f3f..3f6fa9e5 100644 --- a/Readme.md +++ b/Readme.md @@ -44,19 +44,19 @@ In theory there is no real limit to the number of manager jobs that can be creat - Requires a new save. Adds a worktype, which in my tests gave errors on old savegames. If you also have my Work Tab mod, you should be able to add this mod in an ongoing save. ![Contributors](https://banners.karel-kroeze.nl/title/Contributors.png) -Lion Kerger: [changed version in About.xml](https://github.com/fluffy-mods/ColonyManager/commit/7e8f6ca), [corrected misplaced using-directive](https://github.com/fluffy-mods/ColonyManager/commit/fbc9d1d), [updated package-reference to 2.1.0](https://github.com/fluffy-mods/ColonyManager/commit/1c3cd63), [Fixed minor UI/Window bugs](https://github.com/fluffy-mods/ColonyManager/commit/ff78394) +Lion Kerger: [Initial update for 1.3](https://github.com/fluffy-mods/ColonyManager/commit/ff78394) InsanityPrelude: [Add AllWork tag to Managing WorkTypeDef (#181)](https://github.com/fluffy-mods/ColonyManager/commit/2cec8c1) dodther: [Update russian translate (#165)](https://github.com/fluffy-mods/ColonyManager/commit/9c92f16) CrapoFR: [French translation - update (#149)](https://github.com/fluffy-mods/ColonyManager/commit/89da83d) -maarxx: [Add Husbandry job option to Unassign Training](https://github.com/fluffy-mods/ColonyManager/commit/cdc8702), [Change Order to Milk -> Shear -> Train](https://github.com/fluffy-mods/ColonyManager/commit/ffd77e2), [Add Feature to Restrict Animals Ready for Milking or Shearing](https://github.com/fluffy-mods/ColonyManager/commit/b638b37), [Fix settings not persisting, fix resultant "No language" translation errors. (#145)](https://github.com/fluffy-mods/ColonyManager/commit/a0c451a) +maarxx: [Add Husbandry job option to Unassign Training](https://github.com/fluffy-mods/ColonyManager/commit/cdc8702), [Add Feature to Restrict Animals Ready for Milking or Shearing](https://github.com/fluffy-mods/ColonyManager/commit/b638b37) Marcos Villar: [Updated BrazilianPortuguese (#136)](https://github.com/fluffy-mods/ColonyManager/commit/9171dfc) Suh. Junmin: [Add partial korean translation (#131)](https://github.com/fluffy-mods/ColonyManager/commit/9d559a1) rw-chaos: [Updated German translation (#130)](https://github.com/fluffy-mods/ColonyManager/commit/ccf3cef) harrisongarya: [Add research tab](https://github.com/fluffy-mods/ColonyManager/commit/5b946ad) Alex TD: [Button to suspend any managing job (#123)](https://github.com/fluffy-mods/ColonyManager/commit/ceb5d46), [Fix Forestry in growing zones (#113)](https://github.com/fluffy-mods/ColonyManager/commit/dceaafb) Firty: [Add PT-BR translation (#117)](https://github.com/fluffy-mods/ColonyManager/commit/511736d) -duduluu: [Update Chinese translations (#84)](https://github.com/fluffy-mods/ColonyManager/commit/775396c), [Update Chinese translations](https://github.com/fluffy-mods/ColonyManager/commit/12d4e48), [Add Chinese Translation (#37)](https://github.com/fluffy-mods/ColonyManager/commit/a1667c4) -Kirill: [Russian translation, pt. 2](https://github.com/fluffy-mods/ColonyManager/commit/b731a01), [Russian translation](https://github.com/fluffy-mods/ColonyManager/commit/3fa14f8) +duduluu: [Update Chinese translations](https://github.com/fluffy-mods/ColonyManager/commit/12d4e48), [Add Chinese Translation (#37)](https://github.com/fluffy-mods/ColonyManager/commit/a1667c4) +Kirill: [Russian translation](https://github.com/fluffy-mods/ColonyManager/commit/3fa14f8) Moumix3: [Update ManagerStations_Research.xml](https://github.com/fluffy-mods/ColonyManager/commit/176a581) KapTaiN KaVerN: [Add minified attribute to Benchbase](https://github.com/fluffy-mods/ColonyManager/commit/075a414) diff --git a/Source/ManagerJobs/ManagerJob_Livestock.cs b/Source/ManagerJobs/ManagerJob_Livestock.cs index ca73a189..882eaddf 100644 --- a/Source/ManagerJobs/ManagerJob_Livestock.cs +++ b/Source/ManagerJobs/ManagerJob_Livestock.cs @@ -15,104 +15,104 @@ namespace FluffyManager { public class ManagerJob_Livestock : ManagerJob { - private static readonly MethodInfo SetWanted_MI; - public bool ButcherBonded; - public bool ButcherExcess; - public bool ButcherPregnant; - public bool ButcherTrained; - public bool FollowDrafted; - public bool FollowFieldwork; - public bool FollowTraining; - public Pawn Master; - public MasterMode Masters; - public Area MilkArea; - public bool RespectBonds = true; - public List RestrictArea; - public bool RestrictToArea; - public bool SendToMilkingArea; - public bool SendToShearingArea; - public bool SendToSlaughterArea; - public bool SendToTrainingArea; - public bool SetFollow; - public Area ShearArea; - public Area SlaughterArea; - public Area TameArea; - public Pawn Trainer; - public MasterMode Trainers; - public TrainingTracker Training; - public Area TrainingArea; - public new Trigger_PawnKind Trigger; - public bool TryTameMore; + private static readonly MethodInfo SetWanted_MI; + public bool ButcherBonded; + public bool ButcherExcess; + public bool ButcherPregnant; + public bool ButcherTrained; + public bool FollowDrafted; + public bool FollowFieldwork; + public bool FollowTraining; + public Pawn Master; + public MasterMode Masters; + public Area MilkArea; + public bool RespectBonds = true; + public List RestrictArea; + public bool RestrictToArea; + public bool SendToMilkingArea; + public bool SendToShearingArea; + public bool SendToSlaughterArea; + public bool SendToTrainingArea; + public bool SetFollow; + public Area ShearArea; + public Area SlaughterArea; + public Area TameArea; + public Pawn Trainer; + public MasterMode Trainers; + public TrainingTracker Training; + public Area TrainingArea; + public new Trigger_PawnKind Trigger; + public bool TryTameMore; private Utilities.CachedValue _cachedLabel; - private List _designations; - private History _history; + private List _designations; + private History _history; static ManagerJob_Livestock() { SetWanted_MI = - typeof( Pawn_TrainingTracker ).GetMethod( "SetWanted", BindingFlags.NonPublic | BindingFlags.Instance ); - if ( SetWanted_MI == null ) - throw new NullReferenceException( "Could not find Pawn_TrainingTracker.SetWanted()" ); + typeof(Pawn_TrainingTracker).GetMethod("SetWanted", BindingFlags.NonPublic | BindingFlags.Instance); + if (SetWanted_MI == null) + throw new NullReferenceException("Could not find Pawn_TrainingTracker.SetWanted()"); } - public ManagerJob_Livestock( Manager manager ) : base( manager ) + public ManagerJob_Livestock(Manager manager) : base(manager) { // init designations _designations = new List(); // start history tracker - _history = new History( Utilities_Livestock.AgeSexArray.Select( ageSex => ageSex.ToString() ).ToArray() ); + _history = new History(Utilities_Livestock.AgeSexArray.Select(ageSex => ageSex.ToString()).ToArray()); // set up the trigger, set all target counts to 5 - Trigger = new Trigger_PawnKind( this.manager ); + Trigger = new Trigger_PawnKind(this.manager); // set all training to false Training = new TrainingTracker(); // set areas for restriction and taming to unrestricted - TameArea = null; + TameArea = null; RestrictToArea = false; - RestrictArea = Utilities_Livestock.AgeSexArray.Select( k => (Area) null ).ToList(); + RestrictArea = Utilities_Livestock.AgeSexArray.Select(k => (Area)null).ToList(); // set up sending animals designated for slaughter to an area (freezer) SendToSlaughterArea = false; - SlaughterArea = null; + SlaughterArea = null; // set up milking area SendToMilkingArea = false; - MilkArea = null; + MilkArea = null; // set up shearing area SendToShearingArea = false; - ShearArea = null; + ShearArea = null; // set up training area SendToTrainingArea = false; - TrainingArea = null; + TrainingArea = null; // taming TryTameMore = false; - TameArea = null; + TameArea = null; // set defaults for butchering - ButcherExcess = true; - ButcherTrained = false; + ButcherExcess = true; + ButcherTrained = false; ButcherPregnant = false; - ButcherBonded = false; + ButcherBonded = false; // following - SetFollow = true; - FollowDrafted = true; + SetFollow = true; + FollowDrafted = true; FollowFieldwork = true; - FollowTraining = false; - Masters = MasterMode.Default; - Master = null; - Trainers = MasterMode.Default; - Trainer = null; + FollowTraining = false; + Masters = MasterMode.Default; + Master = null; + Trainers = MasterMode.Default; + Trainer = null; } - public ManagerJob_Livestock( PawnKindDef pawnKindDef, Manager manager ) : this( manager ) // set defaults + public ManagerJob_Livestock(PawnKindDef pawnKindDef, Manager manager) : this(manager) // set defaults { // set pawnkind and get list of current colonist pawns of that def. Trigger.pawnKind = pawnKindDef; @@ -120,27 +120,27 @@ public ManagerJob_Livestock( PawnKindDef pawnKindDef, Manager manager ) : this( public override bool Completed => Trigger.State; - public List Designations => new List( _designations ); + public List Designations => new List(_designations); public string FullLabel { get { - if ( _cachedLabel != null && _cachedLabel.TryGetValue( out var label ) ) + if (_cachedLabel != null && _cachedLabel.TryGetValue(out var label)) return label; Func labelGetter = () => { var text = Label + "\n"; - foreach ( var ageSex in Utilities_Livestock.AgeSexArray ) - text += Trigger.pawnKind.GetTame( manager, ageSex ).Count() + "/" + - Trigger.CountTargets[ageSex] + + foreach (var ageSex in Utilities_Livestock.AgeSexArray) + text += Trigger.pawnKind.GetTame(manager, ageSex).Count() + "/" + + Trigger.CountTargets[ageSex] + ", "; - text += Trigger.pawnKind.GetWild( manager ).Count() + ""; + text += Trigger.pawnKind.GetWild(manager).Count() + ""; return text; }; - _cachedLabel = new Utilities.CachedValue( labelGetter(), 250, labelGetter ); + _cachedLabel = new Utilities.CachedValue(labelGetter(), 250, labelGetter); return labelGetter(); } } @@ -156,74 +156,74 @@ public override string[] Targets get { return Utilities_Livestock.AgeSexArray - .Select( ageSex => - ( "FMP." + ageSex.ToString() + "Count" ).Translate( - Trigger - .pawnKind - .GetTame( - manager, - ageSex ) - .Count(), - Trigger.CountTargets - [ageSex] ) - .Resolve() ) + .Select(ageSex => + ("FMP." + ageSex.ToString() + "Count").Translate( + Trigger + .pawnKind + .GetTame( + manager, + ageSex) + .Count(), + Trigger.CountTargets + [ageSex]) + .Resolve()) .ToArray(); } } public override WorkTypeDef WorkTypeDef => WorkTypeDefOf.Handling; - public void AddDesignation( Pawn p, DesignationDef def ) + public void AddDesignation(Pawn p, DesignationDef def) { // create and add designation to the game and our managed list. - var des = new Designation( p, def ); - _designations.Add( des ); - manager.map.designationManager.AddDesignation( des ); + var des = new Designation(p, def); + _designations.Add(des); + manager.map.designationManager.AddDesignation(des); } - public AcceptanceReport CanBeTrained( PawnKindDef pawnKind, TrainableDef td, out bool visible ) + public AcceptanceReport CanBeTrained(PawnKindDef pawnKind, TrainableDef td, out bool visible) { - if ( pawnKind.RaceProps.untrainableTags != null ) - for ( var index = 0; index < pawnKind.RaceProps.untrainableTags.Count; ++index ) - if ( td.MatchesTag( pawnKind.RaceProps.untrainableTags[index] ) ) + if (pawnKind.RaceProps.untrainableTags != null) + for (var index = 0; index < pawnKind.RaceProps.untrainableTags.Count; ++index) + if (td.MatchesTag(pawnKind.RaceProps.untrainableTags[index])) { visible = false; return false; } - if ( pawnKind.RaceProps.trainableTags != null ) - for ( var index = 0; index < pawnKind.RaceProps.trainableTags.Count; ++index ) - if ( td.MatchesTag( pawnKind.RaceProps.trainableTags[index] ) ) + if (pawnKind.RaceProps.trainableTags != null) + for (var index = 0; index < pawnKind.RaceProps.trainableTags.Count; ++index) + if (td.MatchesTag(pawnKind.RaceProps.trainableTags[index])) { - if ( pawnKind.RaceProps.baseBodySize < (double) td.minBodySize ) + if (pawnKind.RaceProps.baseBodySize < (double)td.minBodySize) { visible = true; return new AcceptanceReport( - "CannotTrainTooSmall".Translate( (object) pawnKind.LabelCap ) ); + "CannotTrainTooSmall".Translate((object)pawnKind.LabelCap)); } visible = true; return true; } - if ( !td.defaultTrainable ) + if (!td.defaultTrainable) { visible = false; return false; } - if ( pawnKind.RaceProps.baseBodySize < (double) td.minBodySize ) + if (pawnKind.RaceProps.baseBodySize < (double)td.minBodySize) { visible = true; return new AcceptanceReport( - "FM.Livestock.CannotTrainTooSmall".Translate( (object) pawnKind.GetLabelPlural() ) ); + "FM.Livestock.CannotTrainTooSmall".Translate((object)pawnKind.GetLabelPlural())); } - if ( pawnKind.RaceProps.trainability.intelligenceOrder < td.requiredTrainability.intelligenceOrder ) + if (pawnKind.RaceProps.trainability.intelligenceOrder < td.requiredTrainability.intelligenceOrder) { visible = true; return - new AcceptanceReport( "CannotTrainNotSmartEnough".Translate( (object) td.requiredTrainability ) ); + new AcceptanceReport("CannotTrainNotSmartEnough".Translate((object)td.requiredTrainability)); } visible = true; @@ -232,72 +232,72 @@ public AcceptanceReport CanBeTrained( PawnKindDef pawnKind, TrainableDef td, out public override void CleanUp() { - foreach ( var des in _designations ) des.Delete(); + foreach (var des in _designations) des.Delete(); _designations.Clear(); } - public List DesignationsOfOn( DesignationDef def, AgeAndSex ageSex ) + public List DesignationsOfOn(DesignationDef def, AgeAndSex ageSex) { - return _designations.Where( des => des.def == def - && des.target.HasThing - && des.target.Thing is Pawn - && ( (Pawn) des.target.Thing ).PawnIsOfAgeSex( ageSex ) ) + return _designations.Where(des => des.def == def + && des.target.HasThing + && des.target.Thing is Pawn + && ((Pawn)des.target.Thing).PawnIsOfAgeSex(ageSex)) .ToList(); } - public void DoFollowSettings( ref bool actionTaken ) + public void DoFollowSettings(ref bool actionTaken) { - foreach ( var animal in Trigger.pawnKind.GetTame( manager ).ToList() ) + foreach (var animal in Trigger.pawnKind.GetTame(manager).ToList()) { // training - Logger.Follow( animal.LabelShort ); - if ( FollowTraining && animal.training.NextTrainableToTrain() != null ) + Logger.Follow(animal.LabelShort); + if (FollowTraining && animal.training.NextTrainableToTrain() != null) { - Logger.Follow( "\ttraining" ); - if ( Trainers != MasterMode.Default ) + Logger.Follow("\ttraining"); + if (Trainers != MasterMode.Default) { - SetMaster( animal, Trainers, Trainer, ref actionTaken ); - SetFollowing( animal, false, true, ref actionTaken ); + SetMaster(animal, Trainers, Trainer, ref actionTaken); + SetFollowing(animal, false, true, ref actionTaken); } } // default else { - if ( Masters != MasterMode.Default ) SetMaster( animal, Masters, Master, ref actionTaken ); - if ( SetFollow ) SetFollowing( animal, FollowDrafted, FollowFieldwork, ref actionTaken ); + if (Masters != MasterMode.Default) SetMaster(animal, Masters, Master, ref actionTaken); + if (SetFollow) SetFollowing(animal, FollowDrafted, FollowFieldwork, ref actionTaken); } } } - public override void DrawListEntry( Rect rect, bool overview = true, bool active = true ) + public override void DrawListEntry(Rect rect, bool overview = true, bool active = true) { // (detailButton) | name | (bar | last update)/(stamp) -> handled in Utilities.DrawStatusForListEntry // set up rects Rect labelRect = new Rect( - Margin, Margin, rect.width - ( active ? StatusRectWidth + 4 * Margin : 2 * Margin ), - rect.height - 2 * Margin ), - statusRect = new Rect( labelRect.xMax + Margin, Margin, StatusRectWidth, - rect.height - 2 * Margin ); + Margin, Margin, rect.width - (active ? StatusRectWidth + 4 * Margin : 2 * Margin), + rect.height - 2 * Margin), + statusRect = new Rect(labelRect.xMax + Margin, Margin, StatusRectWidth, + rect.height - 2 * Margin); // do the drawing - GUI.BeginGroup( rect ); + GUI.BeginGroup(rect); // draw label - Widgets.Label( labelRect, FullLabel ); - TooltipHandler.TipRegion( labelRect, () => Trigger.StatusTooltip, GetHashCode() ); + Widgets.Label(labelRect, FullLabel); + TooltipHandler.TipRegion(labelRect, () => Trigger.StatusTooltip, GetHashCode()); // if the bill has a manager job, give some more info. - if ( active ) this.DrawStatusForListEntry( statusRect, Trigger ); + if (active) this.DrawStatusForListEntry(statusRect, Trigger); GUI.EndGroup(); } - public override void DrawOverviewDetails( Rect rect ) + public override void DrawOverviewDetails(Rect rect) { - _history.DrawPlot( rect ); + _history.DrawPlot(rect); } public override void ExposeData() @@ -305,63 +305,63 @@ public override void ExposeData() base.ExposeData(); // settings, references first! - Scribe_References.Look( ref TameArea, "TameArea" ); - Scribe_References.Look( ref SlaughterArea, "SlaughterArea" ); - Scribe_References.Look( ref MilkArea, "MilkArea" ); - Scribe_References.Look( ref ShearArea, "ShearArea" ); - Scribe_References.Look( ref TrainingArea, "TrainingArea" ); - Scribe_References.Look( ref Master, "Master" ); - Scribe_References.Look( ref Trainer, "Trainer" ); - Scribe_Collections.Look( ref RestrictArea, "AreaRestrictions", LookMode.Reference ); - Scribe_Deep.Look( ref Trigger, "trigger", manager ); - Scribe_Deep.Look( ref Training, "Training" ); - Scribe_Deep.Look( ref _history, "History" ); - Scribe_Values.Look( ref ButcherExcess, "ButcherExcess", true ); - Scribe_Values.Look( ref ButcherTrained, "ButcherTrained" ); - Scribe_Values.Look( ref ButcherPregnant, "ButcherPregnant" ); - Scribe_Values.Look( ref ButcherBonded, "ButcherBonded" ); - Scribe_Values.Look( ref RestrictToArea, "RestrictToArea" ); - Scribe_Values.Look( ref SendToSlaughterArea, "SendToSlaughterArea" ); - Scribe_Values.Look( ref SendToMilkingArea, "SendToMilkingArea" ); - Scribe_Values.Look( ref SendToShearingArea, "SendToShearingArea" ); - Scribe_Values.Look( ref SendToTrainingArea, "SendToTrainingArea" ); - Scribe_Values.Look( ref TryTameMore, "TryTameMore" ); - Scribe_Values.Look( ref SetFollow, "SetFollow", true ); - Scribe_Values.Look( ref FollowDrafted, "FollowDrafted", true ); - Scribe_Values.Look( ref FollowFieldwork, "FollowFieldwork", true ); - Scribe_Values.Look( ref FollowTraining, "FollowTraining" ); - Scribe_Values.Look( ref Masters, "Masters" ); - Scribe_Values.Look( ref Trainers, "Trainers" ); - Scribe_Values.Look( ref RespectBonds, "RespectBonds", true ); + Scribe_References.Look(ref TameArea, "TameArea"); + Scribe_References.Look(ref SlaughterArea, "SlaughterArea"); + Scribe_References.Look(ref MilkArea, "MilkArea"); + Scribe_References.Look(ref ShearArea, "ShearArea"); + Scribe_References.Look(ref TrainingArea, "TrainingArea"); + Scribe_References.Look(ref Master, "Master"); + Scribe_References.Look(ref Trainer, "Trainer"); + Scribe_Collections.Look(ref RestrictArea, "AreaRestrictions", LookMode.Reference); + Scribe_Deep.Look(ref Trigger, "trigger", manager); + Scribe_Deep.Look(ref Training, "Training"); + Scribe_Deep.Look(ref _history, "History"); + Scribe_Values.Look(ref ButcherExcess, "ButcherExcess", true); + Scribe_Values.Look(ref ButcherTrained, "ButcherTrained"); + Scribe_Values.Look(ref ButcherPregnant, "ButcherPregnant"); + Scribe_Values.Look(ref ButcherBonded, "ButcherBonded"); + Scribe_Values.Look(ref RestrictToArea, "RestrictToArea"); + Scribe_Values.Look(ref SendToSlaughterArea, "SendToSlaughterArea"); + Scribe_Values.Look(ref SendToMilkingArea, "SendToMilkingArea"); + Scribe_Values.Look(ref SendToShearingArea, "SendToShearingArea"); + Scribe_Values.Look(ref SendToTrainingArea, "SendToTrainingArea"); + Scribe_Values.Look(ref TryTameMore, "TryTameMore"); + Scribe_Values.Look(ref SetFollow, "SetFollow", true); + Scribe_Values.Look(ref FollowDrafted, "FollowDrafted", true); + Scribe_Values.Look(ref FollowFieldwork, "FollowFieldwork", true); + Scribe_Values.Look(ref FollowTraining, "FollowTraining"); + Scribe_Values.Look(ref Masters, "Masters"); + Scribe_Values.Look(ref Trainers, "Trainers"); + Scribe_Values.Look(ref RespectBonds, "RespectBonds", true); // our current designations - if ( Scribe.mode == LoadSaveMode.PostLoadInit ) + if (Scribe.mode == LoadSaveMode.PostLoadInit) { // populate with all designations. _designations.AddRange( - manager.map.designationManager.SpawnedDesignationsOfDef( DesignationDefOf.Slaughter ) - .Where( des => ( (Pawn) des.target.Thing ).kindDef == Trigger.pawnKind ) ); + manager.map.designationManager.SpawnedDesignationsOfDef(DesignationDefOf.Slaughter) + .Where(des => ((Pawn)des.target.Thing).kindDef == Trigger.pawnKind)); _designations.AddRange( - manager.map.designationManager.SpawnedDesignationsOfDef( DesignationDefOf.Tame ) - .Where( des => ( (Pawn) des.target.Thing ).kindDef == Trigger.pawnKind ) ); + manager.map.designationManager.SpawnedDesignationsOfDef(DesignationDefOf.Tame) + .Where(des => ((Pawn)des.target.Thing).kindDef == Trigger.pawnKind)); } } - public Pawn GetMaster( Pawn animal, MasterMode mode ) + public Pawn GetMaster(Pawn animal, MasterMode mode) { - var master = animal.playerSettings.Master; - var options = animal.kindDef.GetMasterOptions( manager, mode ); + var master = animal.playerSettings.Master; + var options = animal.kindDef.GetMasterOptions(manager, mode); // if the animal is bonded, and we care about bonds, there's no discussion - if ( RespectBonds ) + if (RespectBonds) { - var bondee = animal.relations.GetFirstDirectRelationPawn( PawnRelationDefOf.Bond, p => !p.Dead ); - if ( bondee != null && TrainableUtility.CanBeMaster( bondee, animal ) ) + var bondee = animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, p => !p.Dead); + if (bondee != null && TrainableUtility.CanBeMaster(bondee, animal)) return bondee; } Logger.Follow( - $"Getting master for {animal.LabelShort}:\n\tcurrent: {master?.LabelShort ?? "None"}\n\toptions:\n" ); + $"Getting master for {animal.LabelShort}:\n\tcurrent: {master?.LabelShort ?? "None"}\n\toptions:\n"); #if DEBUG_FOLLOW foreach ( var option in options ) { @@ -370,71 +370,71 @@ public Pawn GetMaster( Pawn animal, MasterMode mode ) #endif // cop out if no options - if ( options.NullOrEmpty() ) + if (options.NullOrEmpty()) return null; // if we currently have a master, our current master is a valid option, // and all the options have roughly equal amounts of pets following them, we don't need to take action - if ( master != null && options.Contains( master ) && RoughlyEquallyDistributed( options ) ) + if (master != null && options.Contains(master) && RoughlyEquallyDistributed(options)) return master; // otherwise, assign a master that has the least amount of current followers. - return options.MinBy( p => p.GetFollowers().Count ); + return options.MinBy(p => p.GetFollowers().Count); } - public void SetFollowing( Pawn animal, bool drafted, bool fieldwork, ref bool actionTaken ) + public void SetFollowing(Pawn animal, bool drafted, bool fieldwork, ref bool actionTaken) { - if ( animal?.playerSettings == null ) + if (animal?.playerSettings == null) { - Log.Warning( "NULL!" ); + Log.Warning("NULL!"); return; } Logger.Follow( - $"Current: {animal.playerSettings.followDrafted} | {animal.playerSettings.followFieldwork}, {drafted} | {fieldwork}" ); - if ( animal.playerSettings.followDrafted != drafted ) + $"Current: {animal.playerSettings.followDrafted} | {animal.playerSettings.followFieldwork}, {drafted} | {fieldwork}"); + if (animal.playerSettings.followDrafted != drafted) { animal.playerSettings.followDrafted = drafted; - actionTaken = true; + actionTaken = true; } - if ( animal.playerSettings.followFieldwork != fieldwork ) + if (animal.playerSettings.followFieldwork != fieldwork) { animal.playerSettings.followFieldwork = fieldwork; - actionTaken = true; + actionTaken = true; } } - public void SetMaster( Pawn animal, MasterMode mode, Pawn specificMaster, ref bool actionTaken ) + public void SetMaster(Pawn animal, MasterMode mode, Pawn specificMaster, ref bool actionTaken) { - switch ( mode ) + switch (mode) { case MasterMode.Default: break; case MasterMode.Specific: - SetMaster( animal, specificMaster, ref actionTaken ); + SetMaster(animal, specificMaster, ref actionTaken); break; default: - var master = GetMaster( animal, mode ); - SetMaster( animal, master, ref actionTaken ); + var master = GetMaster(animal, mode); + SetMaster(animal, master, ref actionTaken); break; } } - public void SetMaster( Pawn animal, Pawn master, ref bool actionTaken ) + public void SetMaster(Pawn animal, Pawn master, ref bool actionTaken) { - Logger.Follow( $"Current: {master?.LabelShort ?? "None"}, New: {master?.LabelShort ?? "None"}" ); - if ( animal.playerSettings.Master != master ) + Logger.Follow($"Current: {master?.LabelShort ?? "None"}, New: {master?.LabelShort ?? "None"}"); + if (animal.playerSettings.Master != master) { animal.playerSettings.Master = master; - actionTaken = true; + actionTaken = true; } } public override void Tick() { - if ( _history.IsRelevantTick ) - _history.Update( Trigger.Counts ); + if (_history.IsRelevantTick) + _history.Update(Trigger.Counts); } public override bool TryDoJob() @@ -451,161 +451,165 @@ public override bool TryDoJob() // This should handle manual cancellations and natural completions. // it deliberately won't add new designations made manually. // Note that this also has the unfortunate side-effect of not re-adding designations after loading a game. - _designations = _designations.Intersect( manager.map.designationManager.allDesignations ).ToList(); + _designations = _designations.Intersect(manager.map.designationManager.allDesignations).ToList(); // handle butchery - DoButcherJobs( ref actionTaken ); + DoButcherJobs(ref actionTaken); // handle training - DoTrainingJobs( ref actionTaken ); + DoTrainingJobs(ref actionTaken); // area restrictions - DoAreaRestrictions( ref actionTaken ); + DoAreaRestrictions(ref actionTaken); // handle taming - DoTamingJobs( ref actionTaken ); + DoTamingJobs(ref actionTaken); // follow settings - DoFollowSettings( ref actionTaken ); + DoFollowSettings(ref actionTaken); return actionTaken; } - internal void DoTrainingJobs( ref bool actionTaken, bool assign = true ) + internal void DoTrainingJobs(ref bool actionTaken, bool assign = true) { actionTaken = false; - foreach ( var ageSex in Utilities_Livestock.AgeSexArray ) + foreach (var ageSex in Utilities_Livestock.AgeSexArray) { // skip juveniles if TrainYoung is not enabled. - if ( ageSex.Juvenile() && !Training.TrainYoung ) + if (ageSex.Juvenile() && !Training.TrainYoung) continue; - foreach ( var animal in Trigger.pawnKind.GetTame( manager, ageSex ) ) + foreach (var animal in Trigger.pawnKind.GetTame(manager, ageSex)) { - foreach ( var def in Training.Defs ) + foreach (var def in Training.Defs) if ( // only train if allowed. - animal.training.CanAssignToTrain( def, out _ ).Accepted && + animal.training.CanAssignToTrain(def, out _).Accepted && // only assign training, unless unassign is ticked. - animal.training.GetWanted( def ) != Training[def] && - ( Training[def] || Training.UnassignTraining ) ) + animal.training.GetWanted(def) != Training[def] && + (Training[def] || Training.UnassignTraining)) { - if ( assign ) SetWanted_MI.Invoke( animal.training, new object[] {def, Training[def]} ); + if (assign) SetWanted_MI.Invoke(animal.training, new object[] { def, Training[def] }); actionTaken = true; } } } } - private void DoAreaRestrictions( ref bool actionTaken ) + private void DoAreaRestrictions(ref bool actionTaken) { - for ( var i = 0; i < Utilities_Livestock.AgeSexArray.Length; i++ ) - foreach ( var p in Trigger.pawnKind.GetTame( manager, Utilities_Livestock.AgeSexArray[i] ) ) + // skip for roamers + if (Trigger.pawnKind.RaceProps.Roamer) + return; + + for (var i = 0; i < Utilities_Livestock.AgeSexArray.Length; i++) + foreach (var p in Trigger.pawnKind.GetTame(manager, Utilities_Livestock.AgeSexArray[i])) // slaughter - if ( SendToSlaughterArea && - manager.map.designationManager.DesignationOn( p, DesignationDefOf.Slaughter ) != null ) + if (SendToSlaughterArea && + manager.map.designationManager.DesignationOn(p, DesignationDefOf.Slaughter) != null) { - actionTaken = p.playerSettings.AreaRestriction != SlaughterArea; + actionTaken = p.playerSettings.AreaRestriction != SlaughterArea; p.playerSettings.AreaRestriction = SlaughterArea; } // milking - else if ( SendToMilkingArea && - p.GetComp() != null && - p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks ) + else if (SendToMilkingArea && + p.GetComp() != null && + p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks) { - if ( p.playerSettings.AreaRestriction != MilkArea ) + if (p.playerSettings.AreaRestriction != MilkArea) { - actionTaken = true; + actionTaken = true; p.playerSettings.AreaRestriction = MilkArea; } } // shearing - else if ( SendToShearingArea && - p.GetComp() != null && - p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks ) + else if (SendToShearingArea && + p.GetComp() != null && + p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks) { - if ( p.playerSettings.AreaRestriction != ShearArea ) + if (p.playerSettings.AreaRestriction != ShearArea) { - actionTaken = true; + actionTaken = true; p.playerSettings.AreaRestriction = ShearArea; } } // training - else if ( SendToTrainingArea && p.training.NextTrainableToTrain() != null ) + else if (SendToTrainingArea && p.training.NextTrainableToTrain() != null) { - if ( p.playerSettings.AreaRestriction != TrainingArea ) + if (p.playerSettings.AreaRestriction != TrainingArea) { - actionTaken = true; + actionTaken = true; p.playerSettings.AreaRestriction = TrainingArea; } } // all - else if ( RestrictToArea && p.playerSettings.AreaRestriction != RestrictArea[i] ) + else if (RestrictToArea && p.playerSettings.AreaRestriction != RestrictArea[i]) { - actionTaken = true; + actionTaken = true; p.playerSettings.AreaRestriction = RestrictArea[i]; } } - private void DoButcherJobs( ref bool actionTaken ) + private void DoButcherJobs(ref bool actionTaken) { - if ( !ButcherExcess ) return; + if (!ButcherExcess) return; #if DEBUG_LIFESTOCK Log.Message( "Doing butchery: " + Trigger.pawnKind.LabelCap ); #endif - foreach ( var ageSex in Utilities_Livestock.AgeSexArray ) + foreach (var ageSex in Utilities_Livestock.AgeSexArray) { // too many animals? - var surplus = Trigger.pawnKind.GetTame( manager, ageSex ).Count() - - DesignationsOfOn( DesignationDefOf.Slaughter, ageSex ).Count + var surplus = Trigger.pawnKind.GetTame(manager, ageSex).Count() + - DesignationsOfOn(DesignationDefOf.Slaughter, ageSex).Count - Trigger.CountTargets[ageSex]; #if DEBUG_LIFESTOCK Log.Message( "Butchering " + ageSex + ", surplus" + surplus ); #endif - if ( surplus > 0 ) + if (surplus > 0) { // should slaughter oldest adults, youngest juveniles. var oldestFirst = ageSex == AgeAndSex.AdultFemale || ageSex == AgeAndSex.AdultMale; // get list of animals in correct sort order. - var animals = Trigger.pawnKind.GetTame( manager, ageSex ) + var animals = Trigger.pawnKind.GetTame(manager, ageSex) .Where( p => manager.map.designationManager.DesignationOn( - p, DesignationDefOf.Slaughter ) == null - && ( ButcherTrained || - !p.training.HasLearned( TrainableDefOf.Obedience ) ) - && ( ButcherPregnant || !p.VisiblyPregnant() ) - && ( ButcherBonded || !p.BondedWithColonist() ) ) + p, DesignationDefOf.Slaughter) == null + && (ButcherTrained || + !p.training.HasLearned(TrainableDefOf.Obedience)) + && (ButcherPregnant || !p.VisiblyPregnant()) + && (ButcherBonded || !p.BondedWithColonist())) .OrderBy( - p => ( oldestFirst ? -1 : 1 ) * p.ageTracker.AgeBiologicalTicks ) + p => (oldestFirst ? -1 : 1) * p.ageTracker.AgeBiologicalTicks) .ToList(); #if DEBUG_LIFESTOCK Log.Message( "Tame animals: " + animals.Count ); #endif - for ( var i = 0; i < surplus && i < animals.Count; i++ ) + for (var i = 0; i < surplus && i < animals.Count; i++) { #if DEBUG_LIFESTOCK Log.Message( "Butchering " + animals[i].GetUniqueLoadID() ); #endif - AddDesignation( animals[i], DesignationDefOf.Slaughter ); + AddDesignation(animals[i], DesignationDefOf.Slaughter); } } // remove extra designations - while ( surplus < 0 ) - if ( TryRemoveDesignation( ageSex, DesignationDefOf.Slaughter ) ) + while (surplus < 0) + if (TryRemoveDesignation(ageSex, DesignationDefOf.Slaughter)) { #if DEBUG_LIFESTOCK Log.Message( "Removed extra butchery designation" ); @@ -620,58 +624,58 @@ private void DoButcherJobs( ref bool actionTaken ) } } - private void DoTamingJobs( ref bool actionTaken ) + private void DoTamingJobs(ref bool actionTaken) { - if ( !TryTameMore ) return; + if (!TryTameMore) return; - foreach ( var ageSex in Utilities_Livestock.AgeSexArray ) + foreach (var ageSex in Utilities_Livestock.AgeSexArray) { // not enough animals? var deficit = Trigger.CountTargets[ageSex] - - Trigger.pawnKind.GetTame( manager, ageSex ).Count() - - DesignationsOfOn( DesignationDefOf.Tame, ageSex ).Count; + - Trigger.pawnKind.GetTame(manager, ageSex).Count() + - DesignationsOfOn(DesignationDefOf.Tame, ageSex).Count; #if DEBUG_LIFESTOCK Log.Message( "Taming " + ageSex + ", deficit: " + deficit ); #endif - if ( deficit > 0 ) + if (deficit > 0) { // get the 'home' position var position = manager.map.GetBaseCenter(); // get list of animals in sorted by youngest weighted to distance. - var animals = Trigger.pawnKind.GetWild( manager, ageSex ) - .Where( p => p != null && - p.Spawned && - manager.map.designationManager.DesignationOn( p ) == null && - ( TameArea == null || - TameArea.ActiveCells.Contains( p.Position ) ) && - IsReachable( p ) ).ToList(); + var animals = Trigger.pawnKind.GetWild(manager, ageSex) + .Where(p => p != null && + p.Spawned && + manager.map.designationManager.DesignationOn(p) == null && + (TameArea == null || + TameArea.ActiveCells.Contains(p.Position)) && + IsReachable(p)).ToList(); // skip if no animals available. - if ( animals.Count == 0 ) + if (animals.Count == 0) continue; animals = - animals.OrderBy( p => p.ageTracker.AgeBiologicalTicks / Distance( p, position ) ).ToList(); + animals.OrderBy(p => p.ageTracker.AgeBiologicalTicks / Distance(p, position)).ToList(); #if DEBUG_LIFESTOCK Log.Message( "Wild: " + animals.Count ); #endif - for ( var i = 0; i < deficit && i < animals.Count; i++ ) + for (var i = 0; i < deficit && i < animals.Count; i++) { #if DEBUG_LIFESTOCK Log.Message( "Adding taming designation: " + animals[i].GetUniqueLoadID() ); #endif - AddDesignation( animals[i], DesignationDefOf.Tame ); + AddDesignation(animals[i], DesignationDefOf.Tame); } } // remove extra designations - while ( deficit < 0 ) - if ( TryRemoveDesignation( ageSex, DesignationDefOf.Tame ) ) + while (deficit < 0) + if (TryRemoveDesignation(ageSex, DesignationDefOf.Tame)) { #if DEBUG_LIFESTOCK Log.Message( "Removed extra taming designation" ); @@ -686,23 +690,23 @@ private void DoTamingJobs( ref bool actionTaken ) } } - private bool RoughlyEquallyDistributed( List masters ) + private bool RoughlyEquallyDistributed(List masters) { - var followerCounts = masters.Select( p => p.GetFollowers( Trigger.pawnKind ).Count ); + var followerCounts = masters.Select(p => p.GetFollowers(Trigger.pawnKind).Count); return followerCounts.Max() - followerCounts.Min() <= 1; } - private bool TryRemoveDesignation( AgeAndSex ageSex, DesignationDef def ) + private bool TryRemoveDesignation(AgeAndSex ageSex, DesignationDef def) { // get current designations - var currentDesignations = DesignationsOfOn( def, ageSex ); + var currentDesignations = DesignationsOfOn(def, ageSex); // if none, return false - if ( currentDesignations.Count == 0 ) return false; + if (currentDesignations.Count == 0) return false; // else, remove one from the game as well as our managed list. (delete last - this should be the youngest/oldest). var designation = currentDesignations.Last(); - _designations.Remove( designation ); + _designations.Remove(designation); designation.Delete(); return true; } @@ -711,15 +715,15 @@ private bool TryRemoveDesignation( AgeAndSex ageSex, DesignationDef def ) public class TrainingTracker : IExposable { public DefMap TrainingTargets = new DefMap(); - public bool TrainYoung; - public bool UnassignTraining; + public bool TrainYoung; + public bool UnassignTraining; public bool Any { get { - foreach ( var def in Defs ) - if ( TrainingTargets[def] ) + foreach (var def in Defs) + if (TrainingTargets[def]) return true; return false; @@ -730,42 +734,42 @@ public bool Any public List Defs => DefDatabase.AllDefsListForReading; - public bool this[ TrainableDef index ] + public bool this[TrainableDef index] { get => TrainingTargets[index]; - set => SetWantedRecursive( index, value ); + set => SetWantedRecursive(index, value); } public void ExposeData() { - Scribe_Values.Look( ref TrainYoung, "TrainYoung" ); - Scribe_Values.Look( ref UnassignTraining, "UnassignTraining" ); - Scribe_Deep.Look( ref TrainingTargets, "TrainingTargets" ); + Scribe_Values.Look(ref TrainYoung, "TrainYoung"); + Scribe_Values.Look(ref UnassignTraining, "UnassignTraining"); + Scribe_Deep.Look(ref TrainingTargets, "TrainingTargets"); } - private void SetWantedRecursive( TrainableDef td, bool wanted ) + private void SetWantedRecursive(TrainableDef td, bool wanted) { // cop out if nothing changed - if ( TrainingTargets[td] == wanted ) + if (TrainingTargets[td] == wanted) return; // make changes TrainingTargets[td] = wanted; - if ( wanted ) + if (wanted) { SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); - if ( td.prerequisites != null ) - foreach ( var trainable in td.prerequisites ) - SetWantedRecursive( trainable, true ); + if (td.prerequisites != null) + foreach (var trainable in td.prerequisites) + SetWantedRecursive(trainable, true); } else { SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); var enumerable = from t in DefDatabase.AllDefsListForReading where - t.prerequisites != null && t.prerequisites.Contains( td ) + t.prerequisites != null && t.prerequisites.Contains(td) select t; - foreach ( var current in enumerable ) SetWantedRecursive( current, false ); + foreach (var current in enumerable) SetWantedRecursive(current, false); } } } diff --git a/Source/ManagerTabs/ManagerTab_Livestock.cs b/Source/ManagerTabs/ManagerTab_Livestock.cs index 597a1c26..97ab3dc9 100644 --- a/Source/ManagerTabs/ManagerTab_Livestock.cs +++ b/Source/ManagerTabs/ManagerTab_Livestock.cs @@ -15,22 +15,22 @@ namespace FluffyManager { public class ManagerTab_Livestock : ManagerTab { - private List _availablePawnKinds; + private List _availablePawnKinds; private List _currentJobs; // init with 5's if new job. private Dictionary _newCounts = - Utilities_Livestock.AgeSexArray.ToDictionary( k => k, v => "5" ); + Utilities_Livestock.AgeSexArray.ToDictionary(k => k, v => "5"); - private bool _onCurrentTab; - private Vector2 _scrollPosition = Vector2.zero; - private PawnKindDef _selectedAvailable; + private bool _onCurrentTab; + private Vector2 _scrollPosition = Vector2.zero; + private PawnKindDef _selectedAvailable; private ManagerJob_Livestock _selectedCurrent; - private float optionsHeight = 1; + private float optionsHeight = 1; private Vector2 optionsScrollPosition = Vector2.zero; - public ManagerTab_Livestock( Manager manager ) : base( manager ) + public ManagerTab_Livestock(Manager manager) : base(manager) { } @@ -48,48 +48,48 @@ public override ManagerJob Selected { // set tab to current if we're moving to an actual job. // in either case, available selection can be cleared. - _onCurrentTab = value != null; + _onCurrentTab = value != null; _selectedAvailable = null; - _selectedCurrent = (ManagerJob_Livestock) value; + _selectedCurrent = (ManagerJob_Livestock)value; _newCounts = - _selectedCurrent?.Trigger?.CountTargets.ToDictionary( k => k.Key, v => v.Value.ToString() ); + _selectedCurrent?.Trigger?.CountTargets.ToDictionary(k => k.Key, v => v.Value.ToString()); } } - private List GetMasterModes => Enum.GetValues( typeof( MasterMode ) ).Cast().ToList(); + private List GetMasterModes => Enum.GetValues(typeof(MasterMode)).Cast().ToList(); - public override void DoWindowContents( Rect canvas ) + public override void DoWindowContents(Rect canvas) { - var leftRow = new Rect( 0f, 31f, DefaultLeftRowSize, canvas.height - 31f ); - var contentCanvas = new Rect( leftRow.xMax + Margin, 0f, - canvas.width - leftRow.width - Margin, canvas.height ); + var leftRow = new Rect(0f, 31f, DefaultLeftRowSize, canvas.height - 31f); + var contentCanvas = new Rect(leftRow.xMax + Margin, 0f, + canvas.width - leftRow.width - Margin, canvas.height); - DoLeftRow( leftRow ); - DoContent( contentCanvas ); + DoLeftRow(leftRow); + DoContent(contentCanvas); } - public void DrawTrainingSelector( Rect rect ) + public void DrawTrainingSelector(Rect rect) { var cellCount = _selectedCurrent.Training.Count; - var cellWidth = ( rect.width - Margin * ( cellCount - 1 ) ) / cellCount; - var keys = _selectedCurrent.Training.Defs; + var cellWidth = (rect.width - Margin * (cellCount - 1)) / cellCount; + var keys = _selectedCurrent.Training.Defs; - GUI.BeginGroup( rect ); - for ( var i = 0; i < _selectedCurrent.Training.Count; i++ ) + GUI.BeginGroup(rect); + for (var i = 0; i < _selectedCurrent.Training.Count; i++) { - var cell = new Rect( i * ( cellWidth + Margin ), 0f, cellWidth, rect.height ); + var cell = new Rect(i * (cellWidth + Margin), 0f, cellWidth, rect.height); bool visible; - var report = _selectedCurrent.CanBeTrained( _selectedCurrent.Trigger.pawnKind, keys[i], out visible ); - if ( visible && report.Accepted ) + var report = _selectedCurrent.CanBeTrained(_selectedCurrent.Trigger.pawnKind, keys[i], out visible); + if (visible && report.Accepted) { var checkOn = _selectedCurrent.Training[keys[i]]; - DrawToggle( cell, keys[i].LabelCap, keys[i].description, ref checkOn, size: 16f, - font: GameFont.Tiny, wrap: false ); + DrawToggle(cell, keys[i].LabelCap, keys[i].description, ref checkOn, size: 16f, + font: GameFont.Tiny, wrap: false); _selectedCurrent.Training[keys[i]] = checkOn; } - else if ( visible ) + else if (visible) { - Label( cell, keys[i].LabelCap, report.Reason, TextAnchor.MiddleCenter, GameFont.Tiny, Color.grey ); + Label(cell, keys[i].LabelCap, report.Reason, TextAnchor.MiddleCenter, GameFont.Tiny, Color.grey); } } @@ -98,7 +98,7 @@ public void DrawTrainingSelector( Rect rect ) public string GetMasterLabel() { - switch ( _selectedCurrent.Masters ) + switch (_selectedCurrent.Masters) { case MasterMode.Specific: return _selectedCurrent.Master?.LabelShort ?? "FM.None".Translate(); @@ -109,7 +109,7 @@ public string GetMasterLabel() public string GetTrainerLabel() { - switch ( _selectedCurrent.Trainers ) + switch (_selectedCurrent.Trainers) { case MasterMode.Specific: return _selectedCurrent.Trainer.LabelShort; @@ -123,15 +123,15 @@ public override void PreOpen() Refresh(); } - private void DoContent( Rect rect ) + private void DoContent(Rect rect) { // background - Widgets.DrawMenuSection( rect ); + Widgets.DrawMenuSection(rect); // cop out if nothing is selected. - if ( _selectedCurrent == null ) + if (_selectedCurrent == null) { - Label( rect, "FM.Livestock.SelectPawnKind".Translate(), TextAnchor.MiddleCenter ); + Label(rect, "FM.Livestock.SelectPawnKind".Translate(), TextAnchor.MiddleCenter); return; } @@ -140,127 +140,127 @@ private void DoContent( Rect rect ) rect.xMin, rect.yMin, rect.width * 3 / 5f, - rect.height - Margin - ButtonSize.y ); + rect.height - Margin - ButtonSize.y); var animalsColumnRect = new Rect( optionsColumnRect.xMax, rect.yMin, rect.width * 2 / 5f, - rect.height - Margin - ButtonSize.y ); + rect.height - Margin - ButtonSize.y); var buttonRect = new Rect( - rect.xMax - ButtonSize.x, - rect.yMax - ButtonSize.y, + rect.xMax - ButtonSize.x, + rect.yMax - ButtonSize.y, ButtonSize.x - Margin, - ButtonSize.y - Margin ); + ButtonSize.y - Margin); Vector2 position; - float width; - Widgets_Section.BeginSectionColumn( optionsColumnRect, "Livestock.Options", out position, out width ); - - Widgets_Section.Section( ref position, width, DrawTargetCountsSection, - "FM.Livestock.TargetCountsHeader".Translate() ); - Widgets_Section.Section( ref position, width, DrawTamingSection, "FM.Livestock.TamingHeader".Translate() ); - Widgets_Section.Section( ref position, width, DrawButcherSection, - "FM.Livestock.ButcherHeader".Translate() ); - Widgets_Section.Section( ref position, width, DrawTrainingSection, - "FM.Livestock.TrainingHeader".Translate() ); - Widgets_Section.Section( ref position, width, DrawAreaRestrictionsSection, - "FM.Livestock.AreaRestrictionsHeader".Translate() ); - Widgets_Section.Section( ref position, width, DrawFollowSection, "FM.Livestock.FollowHeader".Translate() ); - - Widgets_Section.EndSectionColumn( "Livestock.Options", position ); + float width; + Widgets_Section.BeginSectionColumn(optionsColumnRect, "Livestock.Options", out position, out width); + + Widgets_Section.Section(ref position, width, DrawTargetCountsSection, + "FM.Livestock.TargetCountsHeader".Translate()); + Widgets_Section.Section(ref position, width, DrawTamingSection, "FM.Livestock.TamingHeader".Translate()); + Widgets_Section.Section(ref position, width, DrawButcherSection, + "FM.Livestock.ButcherHeader".Translate()); + Widgets_Section.Section(ref position, width, DrawTrainingSection, + "FM.Livestock.TrainingHeader".Translate()); + Widgets_Section.Section(ref position, width, DrawAreaRestrictionsSection, + "FM.Livestock.AreaRestrictionsHeader".Translate()); + Widgets_Section.Section(ref position, width, DrawFollowSection, "FM.Livestock.FollowHeader".Translate()); + + Widgets_Section.EndSectionColumn("Livestock.Options", position); // Start animals list // get our pawnkind - Widgets_Section.BeginSectionColumn( animalsColumnRect, "Livestock.Animals", out position, out width ); + Widgets_Section.BeginSectionColumn(animalsColumnRect, "Livestock.Animals", out position, out width); - Widgets_Section.Section( ref position, width, DrawTamedAnimalSection, + Widgets_Section.Section(ref position, width, DrawTamedAnimalSection, "FM.Livestock.AnimalsHeader" - .Translate( "FML.Tame".Translate(), - _selectedCurrent.Trigger.pawnKind.GetLabelPlural() ) - .CapitalizeFirst() ); - Widgets_Section.Section( ref position, width, DrawWildAnimalSection, + .Translate("FML.Tame".Translate(), + _selectedCurrent.Trigger.pawnKind.GetLabelPlural()) + .CapitalizeFirst()); + Widgets_Section.Section(ref position, width, DrawWildAnimalSection, "FM.Livestock.AnimalsHeader" - .Translate( "FML.Wild".Translate(), - _selectedCurrent.Trigger.pawnKind.GetLabelPlural() ) - .CapitalizeFirst() ); + .Translate("FML.Wild".Translate(), + _selectedCurrent.Trigger.pawnKind.GetLabelPlural()) + .CapitalizeFirst()); - Widgets_Section.EndSectionColumn( "Livestock.Animals", position ); + Widgets_Section.EndSectionColumn("Livestock.Animals", position); // add / remove to the stack - if ( _selectedCurrent.Managed ) + if (_selectedCurrent.Managed) { - if ( Widgets.ButtonText( buttonRect, "FM.Delete".Translate() ) ) + if (Widgets.ButtonText(buttonRect, "FM.Delete".Translate())) { _selectedCurrent.Delete(); _selectedCurrent = null; - _onCurrentTab = false; + _onCurrentTab = false; Refresh(); return; // just skip to the next tick to avoid null reference errors. } - TooltipHandler.TipRegion( buttonRect, "FMP.DeleteBillTooltip".Translate() ); + TooltipHandler.TipRegion(buttonRect, "FMP.DeleteBillTooltip".Translate()); } else { - if ( Widgets.ButtonText( buttonRect, "FM.Manage".Translate() ) ) + if (Widgets.ButtonText(buttonRect, "FM.Manage".Translate())) { _selectedCurrent.Managed = true; - _onCurrentTab = true; - Manager.For( manager ).JobStack.Add( _selectedCurrent ); + _onCurrentTab = true; + Manager.For(manager).JobStack.Add(_selectedCurrent); Refresh(); } - TooltipHandler.TipRegion( buttonRect, "FMP.ManageBillTooltip".Translate() ); + TooltipHandler.TipRegion(buttonRect, "FMP.ManageBillTooltip".Translate()); } } - private void DoCountField( Rect rect, AgeAndSex ageSex ) + private void DoCountField(Rect rect, AgeAndSex ageSex) { - if ( _newCounts == null || _newCounts[ageSex] == null ) + if (_newCounts == null || _newCounts[ageSex] == null) _newCounts = - _selectedCurrent?.Trigger?.CountTargets.ToDictionary( k => k.Key, v => v.Value.ToString() ); + _selectedCurrent?.Trigger?.CountTargets.ToDictionary(k => k.Key, v => v.Value.ToString()); - if ( !_newCounts[ageSex].IsInt() ) + if (!_newCounts[ageSex].IsInt()) GUI.color = Color.red; else - _selectedCurrent.Trigger.CountTargets[ageSex] = int.Parse( _newCounts[ageSex] ); - _newCounts[ageSex] = Widgets.TextField( rect.ContractedBy( 1f ), _newCounts[ageSex] ); - GUI.color = Color.white; + _selectedCurrent.Trigger.CountTargets[ageSex] = int.Parse(_newCounts[ageSex]); + _newCounts[ageSex] = Widgets.TextField(rect.ContractedBy(1f), _newCounts[ageSex]); + GUI.color = Color.white; } - private void DoLeftRow( Rect rect ) + private void DoLeftRow(Rect rect) { // background (minus top line so we can draw tabs.) - Widgets.DrawMenuSection( rect ); + Widgets.DrawMenuSection(rect); // tabs var tabs = new List(); - var availableTabRecord = new TabRecord( "FMP.Available".Translate(), delegate - { - _onCurrentTab = false; - Refresh(); - }, !_onCurrentTab ); - tabs.Add( availableTabRecord ); - var currentTabRecord = new TabRecord( "FMP.Current".Translate(), delegate - { - _onCurrentTab = true; - Refresh(); - }, _onCurrentTab ); - tabs.Add( currentTabRecord ); - - TabDrawer.DrawTabs( rect, tabs ); - - var outRect = rect; + var availableTabRecord = new TabRecord("FMP.Available".Translate(), delegate + { + _onCurrentTab = false; + Refresh(); + }, !_onCurrentTab); + tabs.Add(availableTabRecord); + var currentTabRecord = new TabRecord("FMP.Current".Translate(), delegate + { + _onCurrentTab = true; + Refresh(); + }, _onCurrentTab); + tabs.Add(currentTabRecord); + + TabDrawer.DrawTabs(rect, tabs); + + var outRect = rect; var viewRect = outRect.AtZero(); - if ( _onCurrentTab ) - DrawCurrentJobList( outRect, viewRect ); + if (_onCurrentTab) + DrawCurrentJobList(outRect, viewRect); else - DrawAvailableJobList( outRect, viewRect ); + DrawAvailableJobList(outRect, viewRect); } - private void DrawAnimalListheader( ref Vector2 pos, Vector2 size, PawnKindDef pawnKind ) + private void DrawAnimalListheader(ref Vector2 pos, Vector2 size, PawnKindDef pawnKind) { var start = pos; @@ -273,369 +273,375 @@ private void DrawAnimalListheader( ref Vector2 pos, Vector2 size, PawnKindDef pa // extra columns? var milk = pawnKind.Milkable(); var wool = pawnKind.Shearable(); - if ( milk ) + if (milk) cols++; - if ( wool ) + if (wool) cols++; var colwidth = size.x * 2 / 3 / cols; // gender header - var genderRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var genderRect = new Rect(pos.x, pos.y, colwidth, size.y); var genderMale = - new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( genderRect, -SmallIconSize / 2 ); + new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(genderRect, -SmallIconSize / 2); var genderFemale = - new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( genderRect, SmallIconSize / 2 ); - GUI.DrawTexture( genderMale, Resources.MaleIcon ); - GUI.DrawTexture( genderFemale, Resources.FemaleIcon ); - TooltipHandler.TipRegion( genderRect, "FML.GenderHeader".Translate() ); + new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(genderRect, SmallIconSize / 2); + GUI.DrawTexture(genderMale, Resources.MaleIcon); + GUI.DrawTexture(genderFemale, Resources.FemaleIcon); + TooltipHandler.TipRegion(genderRect, "FML.GenderHeader".Translate()); pos.x += colwidth; // lifestage header - var ageRect = new Rect( pos.x, pos.y, colwidth, size.y ); - var ageRectC = new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( ageRect, SmallIconSize / 2 ); - var ageRectB = new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( ageRect ); - var ageRectA = new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( ageRect, -SmallIconSize / 2 ); - GUI.DrawTexture( ageRectC, Resources.LifeStages( 2 ) ); - GUI.DrawTexture( ageRectB, Resources.LifeStages( 1 ) ); - GUI.DrawTexture( ageRectA, Resources.LifeStages( 0 ) ); - TooltipHandler.TipRegion( ageRect, "FML.AgeHeader".Translate() ); + var ageRect = new Rect(pos.x, pos.y, colwidth, size.y); + var ageRectC = new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(ageRect, SmallIconSize / 2); + var ageRectB = new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(ageRect); + var ageRectA = new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(ageRect, -SmallIconSize / 2); + GUI.DrawTexture(ageRectC, Resources.LifeStages(2)); + GUI.DrawTexture(ageRectB, Resources.LifeStages(1)); + GUI.DrawTexture(ageRectA, Resources.LifeStages(0)); + TooltipHandler.TipRegion(ageRect, "FML.AgeHeader".Translate()); pos.x += colwidth; // meat header - var meatRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var meatRect = new Rect(pos.x, pos.y, colwidth, size.y); var meatIconRect = - new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( meatRect ); - GUI.DrawTexture( meatIconRect, Resources.MeatIcon ); - TooltipHandler.TipRegion( meatRect, "FML.MeatHeader".Translate() ); + new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(meatRect); + GUI.DrawTexture(meatIconRect, Resources.MeatIcon); + TooltipHandler.TipRegion(meatRect, "FML.MeatHeader".Translate()); pos.x += colwidth; // milk header - if ( milk ) + if (milk) { - var milkRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var milkRect = new Rect(pos.x, pos.y, colwidth, size.y); var milkIconRect = - new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( milkRect ); - GUI.DrawTexture( milkIconRect, Resources.MilkIcon ); - TooltipHandler.TipRegion( milkRect, "FML.MilkHeader".Translate() ); + new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(milkRect); + GUI.DrawTexture(milkIconRect, Resources.MilkIcon); + TooltipHandler.TipRegion(milkRect, "FML.MilkHeader".Translate()); pos.x += colwidth; } // wool header - if ( wool ) + if (wool) { - var woolRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var woolRect = new Rect(pos.x, pos.y, colwidth, size.y); var woolIconRect = - new Rect( 0f, 0f, MediumIconSize, MediumIconSize ).CenteredIn( woolRect ); - GUI.DrawTexture( woolIconRect, Resources.WoolIcon ); - TooltipHandler.TipRegion( woolRect, "FML.WoolHeader".Translate() ); + new Rect(0f, 0f, MediumIconSize, MediumIconSize).CenteredIn(woolRect); + GUI.DrawTexture(woolIconRect, Resources.WoolIcon); + TooltipHandler.TipRegion(woolRect, "FML.WoolHeader".Translate()); pos.x += colwidth; } // start next row - pos.x = start.x; + pos.x = start.x; pos.y += size.y; } - private void DrawAnimalRow( ref Vector2 pos, Vector2 size, Pawn p ) + private void DrawAnimalRow(ref Vector2 pos, Vector2 size, Pawn p) { var start = pos; // highlights and interactivity. - var row = new Rect( pos.x, pos.y, size.x, size.y ); - Widgets.DrawHighlightIfMouseover( row ); - if ( Widgets.ButtonInvisible( row ) ) + var row = new Rect(pos.x, pos.y, size.x, size.y); + Widgets.DrawHighlightIfMouseover(row); + if (Widgets.ButtonInvisible(row)) { // move camera and select Find.MainTabsRoot.EscapeCurrentTab(); - CameraJumper.TryJump( p.PositionHeld, p.Map ); + CameraJumper.TryJump(p.PositionHeld, p.Map); Find.Selector.ClearSelection(); - if ( p.Spawned ) - Find.Selector.Select( p ); + if (p.Spawned) + Find.Selector.Select(p); } // use a third of available screenspace for labels - var nameRect = new Rect( pos.x, pos.y, size.x / 3f, size.y ); - Label( nameRect, p.LabelCap, TextAnchor.MiddleCenter, GameFont.Tiny ); + var nameRect = new Rect(pos.x, pos.y, size.x / 3f, size.y); + Label(nameRect, p.LabelCap, TextAnchor.MiddleCenter, GameFont.Tiny); pos.x += size.x / 3f; // gender, lifestage, current meat (and if applicable, milking + shearing) var cols = 3; // extra columns? - if ( p.kindDef.Milkable() ) + if (p.kindDef.Milkable()) cols++; - if ( p.kindDef.Shearable() ) + if (p.kindDef.Shearable()) cols++; var colwidth = size.x * 2 / 3 / cols; // gender column - var genderRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var genderRect = new Rect(pos.x, pos.y, colwidth, size.y); var genderIconRect = - new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( genderRect ); - switch ( p.gender ) + new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(genderRect); + switch (p.gender) { case Gender.Female: - GUI.DrawTexture( genderIconRect, Resources.FemaleIcon ); + GUI.DrawTexture(genderIconRect, Resources.FemaleIcon); break; case Gender.Male: - GUI.DrawTexture( genderIconRect, Resources.MaleIcon ); + GUI.DrawTexture(genderIconRect, Resources.MaleIcon); break; case Gender.None: - GUI.DrawTexture( genderIconRect, Resources.UnkownIcon ); + GUI.DrawTexture(genderIconRect, Resources.UnkownIcon); break; } - TooltipHandler.TipRegion( genderRect, p.gender.GetLabel() ); + TooltipHandler.TipRegion(genderRect, p.gender.GetLabel()); pos.x += colwidth; // lifestage column - var ageRect = new Rect( pos.x, pos.y, colwidth, size.y ); - var ageIconRect = new Rect( 0f, 0f, SmallIconSize, SmallIconSize ).CenteredIn( ageRect ); - GUI.DrawTexture( ageIconRect, Resources.LifeStages( p.ageTracker.CurLifeStageIndex ) ); - TooltipHandler.TipRegion( ageRect, p.ageTracker.AgeTooltipString ); + var ageRect = new Rect(pos.x, pos.y, colwidth, size.y); + var ageIconRect = new Rect(0f, 0f, SmallIconSize, SmallIconSize).CenteredIn(ageRect); + GUI.DrawTexture(ageIconRect, Resources.LifeStages(p.ageTracker.CurLifeStageIndex)); + TooltipHandler.TipRegion(ageRect, p.ageTracker.AgeTooltipString); pos.x += colwidth; // meat column - var meatRect = new Rect( pos.x, pos.y, colwidth, size.y ); + var meatRect = new Rect(pos.x, pos.y, colwidth, size.y); // NOTE: When splitting tabs into separate mods; estimated meat count is defined in the Hunting helper. - Label( meatRect, p.EstimatedMeatCount().ToString(), - "FML.Yields".Translate( p.RaceProps.meatDef.LabelCap, p.EstimatedMeatCount() ), - TextAnchor.MiddleCenter, GameFont.Tiny ); + Label(meatRect, p.EstimatedMeatCount().ToString(), + "FML.Yields".Translate(p.RaceProps.meatDef.LabelCap, p.EstimatedMeatCount()), + TextAnchor.MiddleCenter, GameFont.Tiny); pos.x += colwidth; // milk column - if ( p.Milkable() ) + if (p.Milkable()) { - var milkRect = new Rect( pos.x, pos.y, colwidth, size.y ); - var comp = p.TryGetComp(); - Label( milkRect, comp.Fullness.ToString( "0%" ), - "FML.Yields".Translate( comp.Props.milkDef.LabelCap, comp.Props.milkAmount ), - TextAnchor.MiddleCenter, GameFont.Tiny ); + var milkRect = new Rect(pos.x, pos.y, colwidth, size.y); + var comp = p.TryGetComp(); + Label(milkRect, comp.Fullness.ToString("0%"), + "FML.Yields".Translate(comp.Props.milkDef.LabelCap, comp.Props.milkAmount), + TextAnchor.MiddleCenter, GameFont.Tiny); } - if ( p.kindDef.Milkable() ) + if (p.kindDef.Milkable()) pos.x += colwidth; // wool column - if ( p.Shearable() ) + if (p.Shearable()) { - var woolRect = new Rect( pos.x, pos.y, colwidth, size.y ); - var comp = p.TryGetComp(); - Label( woolRect, comp.Fullness.ToString( "0%" ), - "FML.Yields".Translate( comp.Props.woolDef.LabelCap, comp.Props.woolAmount ), - TextAnchor.MiddleCenter, GameFont.Tiny ); + var woolRect = new Rect(pos.x, pos.y, colwidth, size.y); + var comp = p.TryGetComp(); + Label(woolRect, comp.Fullness.ToString("0%"), + "FML.Yields".Translate(comp.Props.woolDef.LabelCap, comp.Props.woolAmount), + TextAnchor.MiddleCenter, GameFont.Tiny); } - if ( p.kindDef.Milkable() ) + if (p.kindDef.Milkable()) pos.x += colwidth; // do the carriage return on ref pos - pos.x = start.x; + pos.x = start.x; pos.y += size.y; } - private float DrawAnimalSection( ref Vector2 pos, float width, string type, PawnKindDef pawnKind, - IEnumerable animals ) + private float DrawAnimalSection(ref Vector2 pos, float width, string type, PawnKindDef pawnKind, + IEnumerable animals) { - if ( animals == null ) + if (animals == null) return 0; var start = pos; - DrawAnimalListheader( ref pos, new Vector2( width, ListEntryHeight / 3 * 2 ), pawnKind ); + DrawAnimalListheader(ref pos, new Vector2(width, ListEntryHeight / 3 * 2), pawnKind); - if ( !animals.Any() ) + if (!animals.Any()) { - Label( new Rect( pos.x, pos.y, width, ListEntryHeight ), - "FML.NoAnimals".Translate( type, pawnKind.GetLabelPlural() ), - TextAnchor.MiddleCenter, color: Color.grey ); + Label(new Rect(pos.x, pos.y, width, ListEntryHeight), + "FML.NoAnimals".Translate(type, pawnKind.GetLabelPlural()), + TextAnchor.MiddleCenter, color: Color.grey); pos.y += ListEntryHeight; } - foreach ( var animal in animals ) - DrawAnimalRow( ref pos, new Vector2( width, ListEntryHeight ), animal ); + foreach (var animal in animals) + DrawAnimalRow(ref pos, new Vector2(width, ListEntryHeight), animal); return pos.y - start.y; } - private float DrawAreaRestrictionsSection( Vector2 pos, float width ) + private float DrawAreaRestrictionsSection(Vector2 pos, float width) { var start = pos; + + // skip for animals that can't be restricted + if (_selectedCurrent.Trigger.pawnKind.race.race.Roamer) + return 0f; + + // restrict to area - var restrictAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var restrictAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); - DrawToggle( restrictAreaRect, + DrawToggle(restrictAreaRect, "FML.RestrictToArea".Translate(), "FML.RestrictToArea.Tip".Translate(), - ref _selectedCurrent.RestrictToArea ); + ref _selectedCurrent.RestrictToArea); pos.y += ListEntryHeight; - if ( _selectedCurrent.RestrictToArea ) + if (_selectedCurrent.RestrictToArea) { // area selectors table // set up a 3x3 table of rects - var cols = 3; - var fifth = width / 5; - float[] widths = {fifth, fifth * 2, fifth * 2}; - float[] heights = {ListEntryHeight * 2 / 3, ListEntryHeight, ListEntryHeight}; + var cols = 3; + var fifth = width / 5; + float[] widths = { fifth, fifth * 2, fifth * 2 }; + float[] heights = { ListEntryHeight * 2 / 3, ListEntryHeight, ListEntryHeight }; var areaRects = new Rect[cols, cols]; - for ( var x = 0; x < cols; x++ ) - for ( var y = 0; y < cols; y++ ) + for (var x = 0; x < cols; x++) + for (var y = 0; y < cols; y++) areaRects[x, y] = new Rect( - widths.Take( x ).Sum(), - pos.y + heights.Take( y ).Sum(), + widths.Take(x).Sum(), + pos.y + heights.Take(y).Sum(), widths[x], - heights[y] ); + heights[y]); // headers - Label( areaRects[1, 0], Gender.Female.ToString(), TextAnchor.LowerCenter, GameFont.Tiny ); - Label( areaRects[2, 0], Gender.Male.ToString(), TextAnchor.LowerCenter, GameFont.Tiny ); - Label( areaRects[0, 1], "FML.Adult".Translate(), TextAnchor.MiddleRight, GameFont.Tiny ); - Label( areaRects[0, 2], "FML.Juvenile".Translate(), TextAnchor.MiddleRight, GameFont.Tiny ); + Label(areaRects[1, 0], Gender.Female.ToString(), TextAnchor.LowerCenter, GameFont.Tiny); + Label(areaRects[2, 0], Gender.Male.ToString(), TextAnchor.LowerCenter, GameFont.Tiny); + Label(areaRects[0, 1], "FML.Adult".Translate(), TextAnchor.MiddleRight, GameFont.Tiny); + Label(areaRects[0, 2], "FML.Juvenile".Translate(), TextAnchor.MiddleRight, GameFont.Tiny); // do the selectors - _selectedCurrent.RestrictArea[0] = AreaAllowedGUI.DoAllowedAreaSelectors( areaRects[1, 1], + _selectedCurrent.RestrictArea[0] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 1], _selectedCurrent.RestrictArea[ - 0], manager, Margin ); - _selectedCurrent.RestrictArea[1] = AreaAllowedGUI.DoAllowedAreaSelectors( areaRects[2, 1], + 0], manager, Margin); + _selectedCurrent.RestrictArea[1] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 1], _selectedCurrent.RestrictArea[ - 1], manager, Margin ); - _selectedCurrent.RestrictArea[2] = AreaAllowedGUI.DoAllowedAreaSelectors( areaRects[1, 2], + 1], manager, Margin); + _selectedCurrent.RestrictArea[2] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[1, 2], _selectedCurrent.RestrictArea[ - 2], manager, Margin ); - _selectedCurrent.RestrictArea[3] = AreaAllowedGUI.DoAllowedAreaSelectors( areaRects[2, 2], + 2], manager, Margin); + _selectedCurrent.RestrictArea[3] = AreaAllowedGUI.DoAllowedAreaSelectors(areaRects[2, 2], _selectedCurrent.RestrictArea[ - 3], manager, Margin ); + 3], manager, Margin); - Text.Anchor = TextAnchor.UpperLeft; // DoAllowedAreaMode leaves the anchor in an incorrect state. - pos.y += 3 * ListEntryHeight; + Text.Anchor = TextAnchor.UpperLeft; // DoAllowedAreaMode leaves the anchor in an incorrect state. + pos.y += 3 * ListEntryHeight; } - var sendToSlaughterAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var sendToSlaughterAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); pos.y += ListEntryHeight; - if ( _selectedCurrent.ButcherExcess ) + if (_selectedCurrent.ButcherExcess) { - DrawToggle( sendToSlaughterAreaRect, + DrawToggle(sendToSlaughterAreaRect, "FML.SendToSlaughterArea".Translate(), "FML.SendToSlaughterArea.Tip".Translate(), - ref _selectedCurrent.SendToSlaughterArea ); + ref _selectedCurrent.SendToSlaughterArea); - if ( _selectedCurrent.SendToSlaughterArea ) + if (_selectedCurrent.SendToSlaughterArea) { - var slaughterAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - AreaAllowedGUI.DoAllowedAreaSelectors( slaughterAreaRect, ref _selectedCurrent.SlaughterArea, - manager ); + var slaughterAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + AreaAllowedGUI.DoAllowedAreaSelectors(slaughterAreaRect, ref _selectedCurrent.SlaughterArea, + manager); pos.y += ListEntryHeight; } } else { sendToSlaughterAreaRect.xMin += Margin; - Label( sendToSlaughterAreaRect, "FML.SendToSlaughterArea".Translate(), + Label(sendToSlaughterAreaRect, "FML.SendToSlaughterArea".Translate(), "FM.Livestock.DisabledBecauseSlaughterExcessDisabled".Translate(), TextAnchor.MiddleLeft, - color: Color.grey ); + color: Color.grey); } - if ( _selectedCurrent.Trigger.pawnKind.Milkable() ) + if (_selectedCurrent.Trigger.pawnKind.Milkable()) { - var sendToMilkingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var sendToMilkingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); pos.y += ListEntryHeight; - DrawToggle( sendToMilkingAreaRect, + DrawToggle(sendToMilkingAreaRect, "FML.SendToMilkingArea".Translate(), "FML.SendToMilkingArea.Tip".Translate(), - ref _selectedCurrent.SendToMilkingArea ); + ref _selectedCurrent.SendToMilkingArea); - if ( _selectedCurrent.SendToMilkingArea ) + if (_selectedCurrent.SendToMilkingArea) { - var milkingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - AreaAllowedGUI.DoAllowedAreaSelectors( milkingAreaRect, ref _selectedCurrent.MilkArea, - manager ); + var milkingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + AreaAllowedGUI.DoAllowedAreaSelectors(milkingAreaRect, ref _selectedCurrent.MilkArea, + manager); pos.y += ListEntryHeight; } } - if ( _selectedCurrent.Trigger.pawnKind.Shearable() ) + if (_selectedCurrent.Trigger.pawnKind.Shearable()) { - var sendToShearingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var sendToShearingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); pos.y += ListEntryHeight; - DrawToggle( sendToShearingAreaRect, + DrawToggle(sendToShearingAreaRect, "FML.SendToShearingArea".Translate(), "FML.SendToShearingArea.Tip".Translate(), - ref _selectedCurrent.SendToShearingArea ); + ref _selectedCurrent.SendToShearingArea); - if ( _selectedCurrent.SendToShearingArea ) + if (_selectedCurrent.SendToShearingArea) { - var shearingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - AreaAllowedGUI.DoAllowedAreaSelectors( shearingAreaRect, ref _selectedCurrent.ShearArea, - manager ); + var shearingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + AreaAllowedGUI.DoAllowedAreaSelectors(shearingAreaRect, ref _selectedCurrent.ShearArea, + manager); pos.y += ListEntryHeight; } } - var sendToTrainingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var sendToTrainingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); pos.y += ListEntryHeight; - if ( _selectedCurrent.Training.Any ) + if (_selectedCurrent.Training.Any) { - DrawToggle( sendToTrainingAreaRect, + DrawToggle(sendToTrainingAreaRect, "FML.SendToTrainingArea".Translate(), "FML.SendToTrainingArea.Tip".Translate(), - ref _selectedCurrent.SendToTrainingArea ); + ref _selectedCurrent.SendToTrainingArea); - if ( _selectedCurrent.SendToTrainingArea ) + if (_selectedCurrent.SendToTrainingArea) { - var trainingAreaRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - AreaAllowedGUI.DoAllowedAreaSelectors( trainingAreaRect, ref _selectedCurrent.TrainingArea, - manager ); + var trainingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + AreaAllowedGUI.DoAllowedAreaSelectors(trainingAreaRect, ref _selectedCurrent.TrainingArea, + manager); pos.y += ListEntryHeight; } } else { sendToTrainingAreaRect.xMin += Margin; - Label( sendToTrainingAreaRect, "FML.SendToTrainingArea".Translate(), + Label(sendToTrainingAreaRect, "FML.SendToTrainingArea".Translate(), "FM.Livestock.DisabledBecauseNoTrainingSet".Translate(), TextAnchor.MiddleLeft, - color: Color.grey ); + color: Color.grey); } return pos.y - start.y; } - private void DrawAvailableJobList( Rect outRect, Rect viewRect ) + private void DrawAvailableJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _availablePawnKinds.Count * LargeListEntryHeight; - if ( viewRect.height > outRect.height ) + if (viewRect.height > outRect.height) viewRect.width -= ScrollbarWidth; - Widgets.BeginScrollView( outRect, ref _scrollPosition, viewRect ); - GUI.BeginGroup( viewRect ); + Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); + GUI.BeginGroup(viewRect); - for ( var i = 0; i < _availablePawnKinds.Count; i++ ) + for (var i = 0; i < _availablePawnKinds.Count; i++) { // set up rect - var row = new Rect( 0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight ); + var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights - Widgets.DrawHighlightIfMouseover( row ); - if ( i % 2 == 0 ) Widgets.DrawAltRect( row ); - if ( _availablePawnKinds[i] == _selectedAvailable ) Widgets.DrawHighlightSelected( row ); + Widgets.DrawHighlightIfMouseover(row); + if (i % 2 == 0) Widgets.DrawAltRect(row); + if (_availablePawnKinds[i] == _selectedAvailable) Widgets.DrawHighlightSelected(row); // draw label var label = _availablePawnKinds[i].LabelCap + "\n" + "FML.TameWildCount".Translate( - _availablePawnKinds[i].GetTame( manager ).Count(), - _availablePawnKinds[i].GetWild( manager ).Count() ) + ""; - Label( row, label, TextAnchor.MiddleLeft, margin: Margin * 2 ); + _availablePawnKinds[i].GetTame(manager).Count(), + _availablePawnKinds[i].GetWild(manager).Count()) + ""; + Label(row, label, TextAnchor.MiddleLeft, margin: Margin * 2); // button - if ( Widgets.ButtonInvisible( row ) ) + if (Widgets.ButtonInvisible(row)) { _selectedAvailable = _availablePawnKinds[i]; // for highlighting to work - Selected = new ManagerJob_Livestock( _availablePawnKinds[i], manager ); // for details + Selected = new ManagerJob_Livestock(_availablePawnKinds[i], manager); // for details } } @@ -643,39 +649,39 @@ private void DrawAvailableJobList( Rect outRect, Rect viewRect ) Widgets.EndScrollView(); } - private float DrawButcherSection( Vector2 pos, float width ) + private float DrawButcherSection(Vector2 pos, float width) { var start = pos; // butchery stuff - var butcherExcessRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - DrawToggle( butcherExcessRect, + var butcherExcessRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + DrawToggle(butcherExcessRect, "FML.ButcherExcess".Translate(), "FML.ButcherExcess.Tip".Translate(), - ref _selectedCurrent.ButcherExcess ); + ref _selectedCurrent.ButcherExcess); pos.y += ListEntryHeight; - if ( _selectedCurrent.ButcherExcess ) + if (_selectedCurrent.ButcherExcess) { - var cellWidth = ( width - Margin * 2 ) / 3f; - var butcherOptionRect = new Rect( pos.x, pos.y, cellWidth, ListEntryHeight ); + var cellWidth = (width - Margin * 2) / 3f; + var butcherOptionRect = new Rect(pos.x, pos.y, cellWidth, ListEntryHeight); - DrawToggle( butcherOptionRect, + DrawToggle(butcherOptionRect, "FML.ButcherTrained".Translate(), "FML.ButcherTrained.Tip".Translate(), - ref _selectedCurrent.ButcherTrained, font: GameFont.Tiny, wrap: false ); + ref _selectedCurrent.ButcherTrained, font: GameFont.Tiny, wrap: false); butcherOptionRect.x += cellWidth + Margin; - DrawToggle( butcherOptionRect, + DrawToggle(butcherOptionRect, "FML.ButcherPregnant".Translate(), "FML.ButcherPregnant.Tip".Translate(), - ref _selectedCurrent.ButcherPregnant, font: GameFont.Tiny, wrap: false ); + ref _selectedCurrent.ButcherPregnant, font: GameFont.Tiny, wrap: false); butcherOptionRect.x += cellWidth + Margin; - DrawToggle( butcherOptionRect, + DrawToggle(butcherOptionRect, "FML.ButcherBonded".Translate(), "FML.ButcherBonded.Tip".Translate(), - ref _selectedCurrent.ButcherBonded, font: GameFont.Tiny, wrap: false ); + ref _selectedCurrent.ButcherBonded, font: GameFont.Tiny, wrap: false); pos.y += ListEntryHeight; } @@ -683,279 +689,279 @@ private float DrawButcherSection( Vector2 pos, float width ) return pos.y - start.y; } - private void DrawCurrentJobList( Rect outRect, Rect viewRect ) + private void DrawCurrentJobList(Rect outRect, Rect viewRect) { // set sizes viewRect.height = _currentJobs.Count * LargeListEntryHeight; - if ( viewRect.height > outRect.height ) + if (viewRect.height > outRect.height) viewRect.width -= ScrollbarWidth; - Widgets.BeginScrollView( outRect, ref _scrollPosition, viewRect ); - GUI.BeginGroup( viewRect ); + Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); + GUI.BeginGroup(viewRect); - for ( var i = 0; i < _currentJobs.Count; i++ ) + for (var i = 0; i < _currentJobs.Count; i++) { // set up rect - var row = new Rect( 0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight ); + var row = new Rect(0f, LargeListEntryHeight * i, viewRect.width, LargeListEntryHeight); // highlights - Widgets.DrawHighlightIfMouseover( row ); - if ( i % 2 == 0 ) Widgets.DrawAltRect( row ); - if ( _currentJobs[i] == _selectedCurrent ) Widgets.DrawHighlightSelected( row ); + Widgets.DrawHighlightIfMouseover(row); + if (i % 2 == 0) Widgets.DrawAltRect(row); + if (_currentJobs[i] == _selectedCurrent) Widgets.DrawHighlightSelected(row); // draw label - _currentJobs[i].DrawListEntry( row, false ); + _currentJobs[i].DrawListEntry(row, false); // button - if ( Widgets.ButtonInvisible( row ) ) Selected = _currentJobs[i]; + if (Widgets.ButtonInvisible(row)) Selected = _currentJobs[i]; } GUI.EndGroup(); Widgets.EndScrollView(); } - private float DrawFollowSection( Vector2 pos, float width ) + private float DrawFollowSection(Vector2 pos, float width) { - var start = pos; - var rowRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); + var start = pos; + var rowRect = new Rect(pos.x, pos.y, width, ListEntryHeight); var buttonRect = new Rect( rowRect.xMax * 3 / 4, 0f, - width * 1 / 4, - ListEntryHeight * 2 / 3 ) - .CenteredOnYIn( rowRect ); + width * 1 / 4, + ListEntryHeight * 2 / 3) + .CenteredOnYIn(rowRect); // master selection - Label( rowRect, "FM.Livestock.MasterDefault".Translate(), "FM.Livestock.MasterDefault.Tip".Translate(), - TextAnchor.MiddleLeft, margin: Margin ); - if ( Widgets.ButtonText( buttonRect, GetMasterLabel() ) ) + Label(rowRect, "FM.Livestock.MasterDefault".Translate(), "FM.Livestock.MasterDefault.Tip".Translate(), + TextAnchor.MiddleLeft, margin: Margin); + if (Widgets.ButtonText(buttonRect, GetMasterLabel())) { var options = new List(); // modes - foreach ( var _mode in GetMasterModes.Where( mm => ( mm & MasterMode.All ) == mm ) ) - options.Add( new FloatMenuOption( $"FM.Livestock.MasterMode.{_mode}".Translate(), - () => _selectedCurrent.Masters = _mode ) ); + foreach (var _mode in GetMasterModes.Where(mm => (mm & MasterMode.All) == mm)) + options.Add(new FloatMenuOption($"FM.Livestock.MasterMode.{_mode}".Translate(), + () => _selectedCurrent.Masters = _mode)); // specific pawns - foreach ( var pawn in _selectedCurrent.Trigger.pawnKind.GetMasterOptions( manager, MasterMode.All ) ) - options.Add( new FloatMenuOption( - "FM.Livestock.Master".Translate( pawn.LabelShort, + foreach (var pawn in _selectedCurrent.Trigger.pawnKind.GetMasterOptions(manager, MasterMode.All)) + options.Add(new FloatMenuOption( + "FM.Livestock.Master".Translate(pawn.LabelShort, pawn.skills.AverageOfRelevantSkillsFor( - WorkTypeDefOf.Handling ) ), + WorkTypeDefOf.Handling)), () => { - _selectedCurrent.Master = pawn; + _selectedCurrent.Master = pawn; _selectedCurrent.Masters = MasterMode.Specific; - } ) ); + })); - Find.WindowStack.Add( new FloatMenu( options ) ); + Find.WindowStack.Add(new FloatMenu(options)); } // respect bonds? rowRect.y += ListEntryHeight; - if ( _selectedCurrent.Masters != MasterMode.Default && _selectedCurrent.Masters != MasterMode.Specific ) - DrawToggle( rowRect, + if (_selectedCurrent.Masters != MasterMode.Default && _selectedCurrent.Masters != MasterMode.Specific) + DrawToggle(rowRect, "FM.Livestock.RespectBonds".Translate(), "FM.Livestock.RespectBonds.Tip".Translate(), - ref _selectedCurrent.RespectBonds ); + ref _selectedCurrent.RespectBonds); else - Label( rowRect, + Label(rowRect, "FM.Livestock.RespectBonds".Translate(), "FM.Livestock.RespectBonds.DisabledBecauseMastersNotSet".Translate(), - color: Color.grey, margin: Margin ); + color: Color.grey, margin: Margin); // default follow rowRect.y += ListEntryHeight; - DrawToggle( rowRect, + DrawToggle(rowRect, "FM.Livestock.Follow".Translate(), "FM.Livestock.Follow.Tip".Translate(), - ref _selectedCurrent.SetFollow ); + ref _selectedCurrent.SetFollow); - if ( _selectedCurrent.SetFollow ) + if (_selectedCurrent.SetFollow) { rowRect.y += ListEntryHeight; var followRect = rowRect; followRect.width /= 2f; - DrawToggle( followRect, + DrawToggle(followRect, "FM.Livestock.FollowDrafted".Translate(), "FM.Livestock.FollowDrafted.Tip".Translate(), ref _selectedCurrent.FollowDrafted, - font: GameFont.Tiny ); + font: GameFont.Tiny); followRect.x += followRect.width; - DrawToggle( followRect, + DrawToggle(followRect, "FM.Livestock.FollowFieldwork".Translate(), "FM.Livestock.FollowFieldwork.Tip".Translate(), ref _selectedCurrent.FollowFieldwork, - font: GameFont.Tiny ); + font: GameFont.Tiny); } // follow when training rowRect.y += ListEntryHeight; - TooltipHandler.TipRegion( rowRect, "FM.Livestock.FollowTraining.Tip".Translate() ); - DrawToggle( rowRect, + TooltipHandler.TipRegion(rowRect, "FM.Livestock.FollowTraining.Tip".Translate()); + DrawToggle(rowRect, "FM.Livestock.FollowTraining".Translate(), "FM.Livestock.FollowTraining.Tip".Translate(), - ref _selectedCurrent.FollowTraining ); + ref _selectedCurrent.FollowTraining); // master selection - if ( _selectedCurrent.FollowTraining ) + if (_selectedCurrent.FollowTraining) { rowRect.y += ListEntryHeight; - Label( rowRect, "FM.Livestock.MasterTraining".Translate(), + Label(rowRect, "FM.Livestock.MasterTraining".Translate(), "FM.Livestock.MasterTraining.Tip".Translate(), - TextAnchor.MiddleLeft, margin: Margin ); + TextAnchor.MiddleLeft, margin: Margin); - buttonRect = buttonRect.CenteredOnYIn( rowRect ); - if ( Widgets.ButtonText( buttonRect, GetTrainerLabel() ) ) + buttonRect = buttonRect.CenteredOnYIn(rowRect); + if (Widgets.ButtonText(buttonRect, GetTrainerLabel())) { var options = new List(); // modes - foreach ( var _mode in GetMasterModes.Where( mm => ( mm & MasterMode.Trainers ) == mm ) ) - options.Add( new FloatMenuOption( $"FM.Livestock.MasterMode.{_mode}".Translate(), - () => _selectedCurrent.Trainers = _mode ) ); + foreach (var _mode in GetMasterModes.Where(mm => (mm & MasterMode.Trainers) == mm)) + options.Add(new FloatMenuOption($"FM.Livestock.MasterMode.{_mode}".Translate(), + () => _selectedCurrent.Trainers = _mode)); // specific pawns - foreach ( var pawn in _selectedCurrent.Trigger.pawnKind.GetTrainers( manager, MasterMode.Trainers ) + foreach (var pawn in _selectedCurrent.Trigger.pawnKind.GetTrainers(manager, MasterMode.Trainers) ) - options.Add( new FloatMenuOption( - "FM.Livestock.Master".Translate( pawn.LabelShort, + options.Add(new FloatMenuOption( + "FM.Livestock.Master".Translate(pawn.LabelShort, pawn.skills.AverageOfRelevantSkillsFor( - WorkTypeDefOf.Handling ) ), + WorkTypeDefOf.Handling)), () => { - _selectedCurrent.Trainer = pawn; + _selectedCurrent.Trainer = pawn; _selectedCurrent.Trainers = MasterMode.Specific; - } ) ); + })); - Find.WindowStack.Add( new FloatMenu( options ) ); + Find.WindowStack.Add(new FloatMenu(options)); } } return rowRect.yMax - start.y; } - private float DrawTamedAnimalSection( Vector2 pos, float width ) + private float DrawTamedAnimalSection(Vector2 pos, float width) { var pawnKind = _selectedCurrent.Trigger.pawnKind; - var animals = pawnKind?.GetTame( manager ); - return DrawAnimalSection( ref pos, width, "FML.Tame".Translate(), pawnKind, animals ); + var animals = pawnKind?.GetTame(manager); + return DrawAnimalSection(ref pos, width, "FML.Tame".Translate(), pawnKind, animals); } - private float DrawTamingSection( Vector2 pos, float width ) + private float DrawTamingSection(Vector2 pos, float width) { var start = pos; - DrawToggle( ref pos, width, + DrawToggle(ref pos, width, "FML.TameMore".Translate(), "FML.TameMore.Tip".Translate(), - ref _selectedCurrent.TryTameMore ); + ref _selectedCurrent.TryTameMore); // area to tame from (if taming more); - if ( _selectedCurrent.TryTameMore ) + if (_selectedCurrent.TryTameMore) { - AreaAllowedGUI.DoAllowedAreaSelectors( ref pos, width, ref _selectedCurrent.TameArea, manager ); - DrawReachabilityToggle( ref pos, width, ref _selectedCurrent.CheckReachable ); - DrawToggle( ref pos, width, + AreaAllowedGUI.DoAllowedAreaSelectors(ref pos, width, ref _selectedCurrent.TameArea, manager); + DrawReachabilityToggle(ref pos, width, ref _selectedCurrent.CheckReachable); + DrawToggle(ref pos, width, "FM.PathBasedDistance".Translate(), "FM.PathBasedDistance.Tip".Translate(), - ref _selectedCurrent.PathBasedDistance, true ); + ref _selectedCurrent.PathBasedDistance, true); } return pos.y - start.y; } - private float DrawTargetCountsSection( Vector2 pos, float width ) + private float DrawTargetCountsSection(Vector2 pos, float width) { // counts table - var cols = 3; - var rows = 3; - var fifth = width / 5; - float[] widths = {fifth, fifth * 2, fifth * 2}; - float[] heights = {ListEntryHeight * 2 / 3, ListEntryHeight, ListEntryHeight}; + var cols = 3; + var rows = 3; + var fifth = width / 5; + float[] widths = { fifth, fifth * 2, fifth * 2 }; + float[] heights = { ListEntryHeight * 2 / 3, ListEntryHeight, ListEntryHeight }; // set up a 3x3 table of rects var countRects = new Rect[rows, cols]; - for ( var x = 0; x < cols; x++ ) + for (var x = 0; x < cols; x++) { - for ( var y = 0; y < rows; y++ ) + for (var y = 0; y < rows; y++) // kindof overkill for a 3x3 table, but ok. countRects[y, x] = new Rect( - pos.x + widths.Take( x ).Sum(), - pos.y + heights.Take( y ).Sum(), + pos.x + widths.Take(x).Sum(), + pos.y + heights.Take(y).Sum(), widths[x], - heights[y] ); + heights[y]); } // headers - Label( countRects[0, 1], Gender.Female.ToString(), TextAnchor.LowerCenter, GameFont.Tiny ); - Label( countRects[0, 2], Gender.Male.ToString(), TextAnchor.LowerCenter, GameFont.Tiny ); - Label( countRects[1, 0], "FML.Adult".Translate(), TextAnchor.MiddleRight, GameFont.Tiny ); - Label( countRects[2, 0], "FML.Juvenile".Translate(), TextAnchor.MiddleRight, GameFont.Tiny ); + Label(countRects[0, 1], Gender.Female.ToString(), TextAnchor.LowerCenter, GameFont.Tiny); + Label(countRects[0, 2], Gender.Male.ToString(), TextAnchor.LowerCenter, GameFont.Tiny); + Label(countRects[1, 0], "FML.Adult".Translate(), TextAnchor.MiddleRight, GameFont.Tiny); + Label(countRects[2, 0], "FML.Juvenile".Translate(), TextAnchor.MiddleRight, GameFont.Tiny); // fields - DoCountField( countRects[1, 1], AgeAndSex.AdultFemale ); - DoCountField( countRects[1, 2], AgeAndSex.AdultMale ); - DoCountField( countRects[2, 1], AgeAndSex.JuvenileFemale ); - DoCountField( countRects[2, 2], AgeAndSex.JuvenileMale ); + DoCountField(countRects[1, 1], AgeAndSex.AdultFemale); + DoCountField(countRects[1, 2], AgeAndSex.AdultMale); + DoCountField(countRects[2, 1], AgeAndSex.JuvenileFemale); + DoCountField(countRects[2, 2], AgeAndSex.JuvenileMale); return 3 * ListEntryHeight; } - private float DrawTrainingSection( Vector2 pos, float width ) + private float DrawTrainingSection(Vector2 pos, float width) { - var trainingRect = new Rect( pos.x, pos.y, width, ListEntryHeight ); - DrawTrainingSelector( trainingRect ); + var trainingRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + DrawTrainingSelector(trainingRect); var height = ListEntryHeight; - var unassignTrainingRect = new Rect( pos.x, pos.y + height, width, ListEntryHeight ); - DrawToggle( unassignTrainingRect, + var unassignTrainingRect = new Rect(pos.x, pos.y + height, width, ListEntryHeight); + DrawToggle(unassignTrainingRect, "FML.UnassignTraining".Translate(), "FML.UnassignTraining.Tip".Translate(), - ref _selectedCurrent.Training.UnassignTraining ); + ref _selectedCurrent.Training.UnassignTraining); height += ListEntryHeight; - if ( _selectedCurrent.Training.Any ) + if (_selectedCurrent.Training.Any) { - var trainYoungRect = new Rect( pos.x, pos.y + height, width, ListEntryHeight ); - DrawToggle( trainYoungRect, + var trainYoungRect = new Rect(pos.x, pos.y + height, width, ListEntryHeight); + DrawToggle(trainYoungRect, "FML.TrainYoung".Translate(), "FML.TrainYoung.Tip".Translate(), - ref _selectedCurrent.Training.TrainYoung ); + ref _selectedCurrent.Training.TrainYoung); height += ListEntryHeight; } return height; } - private float DrawWildAnimalSection( Vector2 pos, float width ) + private float DrawWildAnimalSection(Vector2 pos, float width) { var pawnKind = _selectedCurrent.Trigger.pawnKind; - var animals = pawnKind?.GetWild( manager ); - return DrawAnimalSection( ref pos, width, "FML.Wild".Translate(), pawnKind, animals ); + var animals = pawnKind?.GetWild(manager); + return DrawAnimalSection(ref pos, width, "FML.Wild".Translate(), pawnKind, animals); } private void Refresh() { // currently managed - _currentJobs = Manager.For( manager ).JobStack.FullStack(); + _currentJobs = Manager.For(manager).JobStack.FullStack(); // concatenate lists of animals on biome and animals in colony. _availablePawnKinds = manager.map.Biome.AllWildAnimals.ToList(); _availablePawnKinds.AddRange( manager.map.mapPawns.AllPawns - .Where( p => p.RaceProps.Animal ) - .Select( p => p.kindDef ) ); + .Where(p => p.RaceProps.Animal) + .Select(p => p.kindDef)); _availablePawnKinds = _availablePawnKinds - // get distinct pawnkinds from the merges + // get distinct pawnkinds from the merges .Distinct() - // remove already managed pawnkinds - .Where( pk => !_currentJobs.Select( job => job.Trigger.pawnKind ).Contains( pk ) ) + // remove already managed pawnkinds + .Where(pk => !_currentJobs.Select(job => job.Trigger.pawnKind).Contains(pk)) - // order by label - .OrderBy( def => def.LabelCap.RawText ) + // order by label + .OrderBy(def => def.LabelCap.RawText) .ToList(); } } diff --git a/modinfo.json b/modinfo.json index dfcb4335..81910c27 100644 --- a/modinfo.json +++ b/modinfo.json @@ -6,7 +6,7 @@ "version": { "major": 5, "minor": 0, - "build": 658 + "build": 662 }, "author": { "name": "Fluffy", @@ -19,6 +19,15 @@ "url": "https://github.com/fluffy-mods/ColonyManager" }, "changelog": [ + { + "date": "2021-07-27T09:17:29.000Z", + "message": "req squiglies be gone, switch to sdk style project", + "author": { + "name": "Fluffy", + "email": "fluffy.l2032@gmail.com" + }, + "hash": "334cce3db7b65cd52b0dd1da24e974580755d53a" + }, { "date": "2021-07-24T20:37:40.000Z", "message": "changed version in About.xml", @@ -60,22 +69,25 @@ { "hash": "7e8f6ca644461bfe9d800bdf26de900388155a49", "author": "Lion Kerger", - "description": "changed version in About.xml" + "description": "changed version in About.xml", + "suppressed": true }, { "hash": "fbc9d1d195575cd27877a70ae4c2795050d23ade", "author": "Lion Kerger", - "description": "corrected misplaced using-directive" + "description": "corrected misplaced using-directive", + "suppressed": true }, { "hash": "1c3cd63279a42e5e65046f7dc84a569d8454f3f2", "author": "Lion Kerger", - "description": "updated package-reference to 2.1.0" + "description": "updated package-reference to 2.1.0", + "suppressed": true }, { "hash": "ff78394d8f0b5d72375fd4171188cfc09147fc9b", "author": "Lion Kerger", - "description": "Fixed minor UI/Window bugs" + "description": "Initial update for 1.3" }, { "hash": "2cec8c107c17fff71ffb809fed9dff706f42b24e", @@ -100,7 +112,8 @@ { "hash": "ffd77e202de2c624538174317e71a2f02f4bb22f", "author": "maarxx", - "description": "Change Order to Milk -> Shear -> Train" + "description": "Change Order to Milk -> Shear -> Train", + "suppressed": true }, { "hash": "b638b376dd0bf67e6808f74e65da3b685c1b1b57", @@ -110,7 +123,8 @@ { "hash": "a0c451a56e6a1672b5a5ab99c968a0347f054356", "author": "maarxx", - "description": "Fix settings not persisting, fix resultant \"No language\" translation errors. (#145)" + "description": "Fix settings not persisting, fix resultant \"No language\" translation errors. (#145)", + "suppressed": true }, { "hash": "9171dfc951792439fb818e34f5110dff2073855e", @@ -150,7 +164,8 @@ { "hash": "775396c602584f24ce44c15202c7f26801359dc3", "author": "duduluu", - "description": "Update Chinese translations (#84)" + "description": "Update Chinese translations (#84)", + "suppressed": true }, { "hash": "12d4e484a7fe3cd8895632ac0f5300867f9ea28c", @@ -160,7 +175,8 @@ { "hash": "b731a01db3b5bd6805e456f30abfcb0123c66237", "author": "Kirill", - "description": "Russian translation, pt. 2" + "description": "Russian translation, pt. 2", + "suppressed": true }, { "hash": "3fa14f8d18b1a77741b4bce471ed3b324bf6c946", @@ -185,25 +201,10 @@ ], "contributors": { "Lion Kerger": [ - { - "hash": "7e8f6ca", - "author": "Lion Kerger", - "description": "changed version in About.xml" - }, - { - "hash": "fbc9d1d", - "author": "Lion Kerger", - "description": "corrected misplaced using-directive" - }, - { - "hash": "1c3cd63", - "author": "Lion Kerger", - "description": "updated package-reference to 2.1.0" - }, { "hash": "ff78394", "author": "Lion Kerger", - "description": "Fixed minor UI/Window bugs" + "description": "Initial update for 1.3" } ], "InsanityPrelude": [ @@ -233,20 +234,10 @@ "author": "maarxx", "description": "Add Husbandry job option to Unassign Training" }, - { - "hash": "ffd77e2", - "author": "maarxx", - "description": "Change Order to Milk -> Shear -> Train" - }, { "hash": "b638b37", "author": "maarxx", "description": "Add Feature to Restrict Animals Ready for Milking or Shearing" - }, - { - "hash": "a0c451a", - "author": "maarxx", - "description": "Fix settings not persisting, fix resultant \"No language\" translation errors. (#145)" } ], "Marcos Villar": [ @@ -297,11 +288,6 @@ } ], "duduluu": [ - { - "hash": "775396c", - "author": "duduluu", - "description": "Update Chinese translations (#84)" - }, { "hash": "12d4e48", "author": "duduluu", @@ -314,11 +300,6 @@ } ], "Kirill": [ - { - "hash": "b731a01", - "author": "Kirill", - "description": "Russian translation, pt. 2" - }, { "hash": "3fa14f8", "author": "Kirill",