Skip to content

Conversation

@maarxx
Copy link
Contributor

@maarxx maarxx commented Sep 26, 2019

Add Feature to Restrict Animals Ready for Milking or Shearing

When an animal is over 94% fullness for milking or shearing, restrict it to a particular area.

Bring the animals to the Handlers, rather than making the Handlers walk to the animals.

@FluffierThanThou
Copy link
Member

cool addition, thanks for the work! I'll have a closer look tonight to see if everything is still somewhat working ;).

@maarxx
Copy link
Contributor Author

maarxx commented Sep 26, 2019

#147 is based on #146, although that is unnecessary artifact of my workflow.

Your initial comments on #146 indicate a preference to do it differently, so I will rebase this #147 out of it to separate them.

EDIT: Done

@maarxx maarxx force-pushed the add_milk_and_shear_2 branch from 464fea6 to b638b37 Compare October 9, 2019 09:00
@maarxx maarxx force-pushed the add_milk_and_shear_2 branch from 05da133 to ffd77e2 Compare October 9, 2019 09:54
@maarxx
Copy link
Contributor Author

maarxx commented Oct 9, 2019

@FluffierThanThou

PR updated, ready for review again. PR now just contains the milk/shear code, no longer contains the unrelated feature, and no longer contains the compiled .DLL.

Moved the new Milk and Shear options to be in between Slaughter and Train, so that the ordering is Slaughter -> Milk -> Shear -> Train, because that is the same order in which the WorkGivers actually appear in the WorkType.

Sorry for delay. Thanks for the mod.

@dandiez
Copy link

dandiez commented Oct 26, 2019

@maarxx
Thank you for this update! I find it really useful and thought about learning how to mod Rimworld just to do the same! XD
I have done some testing and noticed that the 94% might be too early. For instance a Muffalo takes quite a while until it gets from the 94% to 100% wool growth.
At least in my case, the handler always has enough to do, so the time it takes the animals to get to him is quite small in comparison (they will have to wait anyway).
Would it be possible to change it to 100% by default (or have a setting to control it)?

@maarxx
Copy link
Contributor Author

maarxx commented Oct 27, 2019 via email

@dandiez
Copy link

dandiez commented Oct 27, 2019

Yep, I can see how that could happen.

I gave it a try to add a slider (under the area selectors) and it seems to work, however as you mention, it is one extra thing in the UI.

If you want to have a test I can do a pull request to your pull request(?)
It was not much (other than adding a new float variable).
In utilities I added a slider element (it was important to have a smaller rect height so its hitbox does not overlap with the next UI element)

        public static void DrawSlider(Rect rect, string label, string tooltip, ref float value, float size = 5*SmallIconSize,
                                       float margin = Margin, bool wrap = true)
        {
            // set up rects
            var labelRect = rect;
            var sliderRect = new Rect(rect.xMax - size - margin, 0f, size, labelRect.height/2f);
            labelRect.xMax = sliderRect.xMin - Margin / 2f;
            
            // finetune rects
            sliderRect = sliderRect.CenteredOnYIn(labelRect);
            // draw label
            Label(rect, label, TextAnchor.MiddleLeft, GameFont.Small, margin: margin, wrap: wrap);
            // tooltip
            if (!tooltip.NullOrEmpty()) TooltipHandler.TipRegion(rect, tooltip );
            // draw slider
            value = Widgets.HorizontalSlider(sliderRect, value, 0f, 1f, true, String.Format("{0:P0}", value)); // GUI.HorizontalSlider(sliderRect, value, 0f, 1f);
        }

in ManagerTab_Livestock, just below the area selectors:

                    var ShearingWoolGrowthRect = new Rect(pos.x, pos.y, width, ListEntryHeight);
                    ShearingWoolGrowthRect.xMin += 3 * Margin;
                    DrawSlider(ShearingWoolGrowthRect, "FML.SendToShearingAreaMinimumWoolGrowthLabel".Translate(), "FML.SendToShearingAreaMinimumWoolGrowthTip".Translate(),
                         ref _selectedCurrent.SendToShearingAreaMinimumWoolGrowth);
                    pos.y += ListEntryHeight;

and where the logic goes, instead of the hardcoded value, pointing to the new variable:


                                  p.GetComp<CompShearable>() != null &&
                                  p.GetComp<CompShearable>().Fullness >= SendToShearingAreaMinimumWoolGrowth

@dandiez
Copy link

dandiez commented Oct 27, 2019

I have added an example of the slider to #151

<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"?

@FluffierThanThou FluffierThanThou merged commit c8f2850 into fluffy-mods:master Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants