diff --git a/About/About.xml b/About/About.xml index 06baf318..228b5266 100644 --- a/About/About.xml +++ b/About/About.xml @@ -68,9 +68,11 @@ Suh. Junmin: Korean translation harrisongarya: Research tab rw-chaos: German translation (update) Marcos Villar: Portuguese (Brazilian) translation (update) +CrapoFR: French translation update +maarxx: Fix for settings persistance bug, Add unassign training option <size=24>Version</size> -This is version 4.14.589, for RimWorld 1.0.2282. +This is version 4.16.591, for RimWorld 1.0.2408. diff --git a/Assemblies/Fluffy_ColonyManager.dll b/Assemblies/Fluffy_ColonyManager.dll index e3710cd1..29c652b9 100644 Binary files a/Assemblies/Fluffy_ColonyManager.dll and b/Assemblies/Fluffy_ColonyManager.dll differ diff --git a/Languages/English/Keyed/Manager_Keyed.xml b/Languages/English/Keyed/Manager_Keyed.xml index 8e8cb447..1635f96d 100644 --- a/Languages/English/Keyed/Manager_Keyed.xml +++ b/Languages/English/Keyed/Manager_Keyed.xml @@ -190,6 +190,10 @@ Train young animals Restrict animals marked for slaughter Restrict animals designated for slaughtering to a specific area + Restrict animals ready to be milked + 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 Target counts Area restrictions Training diff --git a/Readme.md b/Readme.md index 369ef9f7..66c56008 100644 --- a/Readme.md +++ b/Readme.md @@ -55,19 +55,21 @@ In theory there is no real limit to the number of manager jobs that can be creat - harrisongarya: Research tab - rw-chaos: German translation (update) - Marcos Villar: Portuguese (Brazilian) translation (update) + - CrapoFR: French translation update + - maarxx: Fix for settings persistance bug, Add unassign training option # Think you found a bug? Please read [this guide](http://steamcommunity.com/sharedfiles/filedetails/?id=725234314) before creating a bug report, - and then create a bug report [here](https://github.com/FluffierThanThou/ColonyManager/issues) + and then create a bug report [here](https://github.com/fluffy-mods/ColonyManager/issues) # Older versions -All current and past versions of this mod can be downloaded from [GitHub](https://github.com/FluffierThanThou/ColonyManager/releases). +All current and past versions of this mod can be downloaded from [GitHub](https://github.com/fluffy-mods/ColonyManager/releases). # License All original code in this mod is licensed under the [MIT license](https://opensource.org/licenses/MIT). Do what you want, but give me credit. All original content (e.g. text, imagery, sounds) in this mod is licensed under the [CC-BY-SA 4.0 license](http://creativecommons.org/licenses/by-sa/4.0/). -Parts of the code in this mod, and some content may be licensed by their original authors. If this is the case, the original author & license will either be given in the source code, or be in a LICENSE file next to the content. Please do not decompile my mods, but use the original source code available on [GitHub](https://github.com/FluffierThanThou/ColonyManager/), so license information in the source code is preserved. +Parts of the code in this mod, and some content may be licensed by their original authors. If this is the case, the original author & license will either be given in the source code, or be in a LICENSE file next to the content. Please do not decompile my mods, but use the original source code available on [GitHub](https://github.com/fluffy-mods/ColonyManager/), so license information in the source code is preserved. # Are you enjoying my mods? Show your appreciation by buying me a coffee (or contribute towards a nice single malt). @@ -77,4 +79,4 @@ Show your appreciation by buying me a coffee (or contribute towards a nice singl [![I Have a Black Dog](https://i.ibb.co/ss59Rwy/New-Project-2.png)](https://www.youtube.com/watch?v=XiCrniLQGYc) # Version -This is version 4.14.589, for RimWorld 1.0.2282. \ No newline at end of file +This is version 4.16.591, for RimWorld 1.0.2408. \ No newline at end of file diff --git a/Source/Helpers/Clock.cs b/Source/Helpers/Clock.cs index 4fc48746..c4d66a5b 100644 --- a/Source/Helpers/Clock.cs +++ b/Source/Helpers/Clock.cs @@ -71,7 +71,7 @@ public static void DrawMarker( Rect canvas, float hour, float thickness, Color c var vector = new Vector2( Mathf.Cos( angle ), Mathf.Sin( angle ) ); var from = radius * start * vector + canvas.center; var to = radius * end * vector + canvas.center; - Logger.Debug( $"{canvas}, {from}, {to}" ); +// Logger.Debug( $"{canvas}, {from}, {to}" ); Widgets.DrawLine( from, to, color, thickness ); } } diff --git a/Source/Helpers/Livestock/Utilities_Livestock.cs b/Source/Helpers/Livestock/Utilities_Livestock.cs index f0c94771..12f016c3 100644 --- a/Source/Helpers/Livestock/Utilities_Livestock.cs +++ b/Source/Helpers/Livestock/Utilities_Livestock.cs @@ -6,6 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using Harmony; using RimWorld; using UnityEngine; using Verse; @@ -394,5 +395,19 @@ private static bool _shearable( this Pawn pawn ) if ( comp != null ) active = comp.GetPrivatePropertyValue( "Active" ); return (bool) active; } + + public static int TicksTillHarvestable( this CompHasGatherableBodyResource comp ) + { + var interval = Traverse.Create( comp ).Property( "GatherResourcesIntervalDays" ).GetValue(); + var growthRatePerTick = 1f / ( interval * GenDate.TicksPerDay ); + + var pawn = comp.parent as Pawn; + if ( pawn == null ) throw new ArgumentException( "harvestable should always be on a Pawn" ); + growthRatePerTick *= PawnUtility.BodyResourceGrowthSpeed( (Pawn) comp.parent ); + + // Logger.Debug( $"rate: {growthRatePerTick}, interval: {interval}"); + + return Mathf.CeilToInt(( 1 - comp.Fullness ) / growthRatePerTick ); + } } } \ No newline at end of file diff --git a/Source/ManagerJobs/ManagerJob_Livestock.cs b/Source/ManagerJobs/ManagerJob_Livestock.cs index 1443bc21..21ec6102 100644 --- a/Source/ManagerJobs/ManagerJob_Livestock.cs +++ b/Source/ManagerJobs/ManagerJob_Livestock.cs @@ -32,9 +32,13 @@ public class ManagerJob_Livestock : ManagerJob public List RestrictArea; public bool RestrictToArea; public bool SendToSlaughterArea; + public bool SendToMilkingArea; + public bool SendToShearingArea; public bool SendToTrainingArea; public bool SetFollow; public Area SlaughterArea; + public Area MilkArea; + public Area ShearArea; public Area TameArea; public Pawn Trainer; public MasterMode Trainers; @@ -76,6 +80,14 @@ public ManagerJob_Livestock( Manager manager ) : base( manager ) SendToSlaughterArea = false; SlaughterArea = null; + // set up milking area + SendToMilkingArea = false; + MilkArea = null; + + // set up shearing area + SendToShearingArea = false; + ShearArea = null; + // set up training area SendToTrainingArea = false; TrainingArea = null; @@ -137,6 +149,8 @@ public override void 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" ); @@ -150,6 +164,8 @@ 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 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 ); @@ -221,6 +237,30 @@ private void DoAreaRestrictions( ref bool actionTaken ) p.playerSettings.AreaRestriction = SlaughterArea; } + // milking + else if ( SendToMilkingArea && + p.GetComp() != null && + p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks ) + { + if (p.playerSettings.AreaRestriction != MilkArea) + { + actionTaken = true; + p.playerSettings.AreaRestriction = MilkArea; + } + } + + // shearing + else if ( SendToShearingArea && + p.GetComp() != null && + p.GetComp().TicksTillHarvestable() < UpdateInterval.ticks ) + { + if (p.playerSettings.AreaRestriction != ShearArea) + { + actionTaken = true; + p.playerSettings.AreaRestriction = ShearArea; + } + } + // training else if ( SendToTrainingArea && p.training.NextTrainableToTrain() != null ) { diff --git a/Source/ManagerTabs/ManagerTab_Livestock.cs b/Source/ManagerTabs/ManagerTab_Livestock.cs index b3a4d262..3067d749 100644 --- a/Source/ManagerTabs/ManagerTab_Livestock.cs +++ b/Source/ManagerTabs/ManagerTab_Livestock.cs @@ -426,6 +426,42 @@ private float DrawAreaRestrictionsSection( Vector2 pos, float width ) color: Color.grey ); } + if (_selectedCurrent.Trigger.pawnKind.Milkable()) + { + var sendToMilkingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + pos.y += ListEntryHeight; + DrawToggle(sendToMilkingAreaRect, + "FML.SendToMilkingArea".Translate(), + "FML.SendToMilkingArea.Tip".Translate(), + ref _selectedCurrent.SendToMilkingArea); + + if (_selectedCurrent.SendToMilkingArea) + { + 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()) + { + var sendToShearingAreaRect = new Rect(pos.x, pos.y, width, ListEntryHeight); + pos.y += ListEntryHeight; + DrawToggle(sendToShearingAreaRect, + "FML.SendToShearingArea".Translate(), + "FML.SendToShearingArea.Tip".Translate(), + ref _selectedCurrent.SendToShearingArea); + + if (_selectedCurrent.SendToShearingArea) + { + 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 ); pos.y += ListEntryHeight; if ( _selectedCurrent.Training.Any ) diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index c935a78a..7482180f 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -40,4 +40,4 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("4.0.0")] -[assembly: AssemblyFileVersion("4.14.589")] \ No newline at end of file +[assembly: AssemblyFileVersion("4.16.591")] \ No newline at end of file