Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</description>
<supportedVersions>
Expand Down
Binary file modified Assemblies/Fluffy_ColonyManager.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions Languages/English/Keyed/Manager_Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@
<FML.TrainYoung>Train young animals</FML.TrainYoung>
<FML.SendToSlaughterArea>Restrict animals marked for slaughter</FML.SendToSlaughterArea>
<FML.SendToSlaughterArea.Tip>Restrict animals designated for slaughtering to a specific area</FML.SendToSlaughterArea.Tip>
<FML.SendToMilkingArea>Restrict animals ready to be milked</FML.SendToMilkingArea>
<FML.SendToMilkingArea.Tip>Restrict animals with milk fullness above 94% to a specific area.</FML.SendToMilkingArea.Tip>
<FML.SendToShearingArea>Restrict animals ready to be sheared</FML.SendToShearingArea>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"shearing fullness" --> "wool growth"?

<FML.SendToShearingArea.Tip>Restrict animals with shearing fullness above 94% to a specific area</FML.SendToShearingArea.Tip>
<FM.Livestock.TargetCountsHeader>Target counts</FM.Livestock.TargetCountsHeader>
<FM.Livestock.AreaRestrictionsHeader>Area restrictions</FM.Livestock.AreaRestrictionsHeader>
<FM.Livestock.TrainingHeader>Training</FM.Livestock.TrainingHeader>
Expand Down
10 changes: 6 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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.
This is version 4.16.591, for RimWorld 1.0.2408.
2 changes: 1 addition & 1 deletion Source/Helpers/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down
15 changes: 15 additions & 0 deletions Source/Helpers/Livestock/Utilities_Livestock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Harmony;
using RimWorld;
using UnityEngine;
using Verse;
Expand Down Expand Up @@ -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<int>();
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 );
}
}
}
40 changes: 40 additions & 0 deletions Source/ManagerJobs/ManagerJob_Livestock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ public class ManagerJob_Livestock : ManagerJob
public List<Area> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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" );
Expand All @@ -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 );
Expand Down Expand Up @@ -221,6 +237,30 @@ private void DoAreaRestrictions( ref bool actionTaken )
p.playerSettings.AreaRestriction = SlaughterArea;
}

// milking
else if ( SendToMilkingArea &&
p.GetComp<CompMilkable>() != null &&
p.GetComp<CompMilkable>().TicksTillHarvestable() < UpdateInterval.ticks )
{
if (p.playerSettings.AreaRestriction != MilkArea)
{
actionTaken = true;
p.playerSettings.AreaRestriction = MilkArea;
}
}

// shearing
else if ( SendToShearingArea &&
p.GetComp<CompShearable>() != null &&
p.GetComp<CompShearable>().TicksTillHarvestable() < UpdateInterval.ticks )
{
if (p.playerSettings.AreaRestriction != ShearArea)
{
actionTaken = true;
p.playerSettings.AreaRestriction = ShearArea;
}
}

// training
else if ( SendToTrainingArea && p.training.NextTrainableToTrain() != null )
{
Expand Down
36 changes: 36 additions & 0 deletions Source/ManagerTabs/ManagerTab_Livestock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("4.0.0")]
[assembly: AssemblyFileVersion("4.14.589")]
[assembly: AssemblyFileVersion("4.16.591")]