fluffy-mods / ColonyManager

Colony manager for RimWorld
Other
71 stars 39 forks source link

Add Feature to Restrict Animals Ready for Milking or Shearing #147

Closed maarxx closed 4 years ago

maarxx commented 4 years ago

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 commented 4 years ago

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

maarxx commented 4 years ago

~#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 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

The opposite can also be true though too. Factoring in the delay of the Manage Husbandry Job actually getting executed (imagine the job getting executed at 99% and waiting to be ran again next time), plus the time for the animal to walk to the destination, you can have cases where animal hits 100% before being moved, and then the Handler might (worst case) walk all the way to the opposite corner of the map to shear it.

In my colony, at least, it was much preferable to get the animals in position a little early, rather than risk the Handler make such an enormously wasteful trip.

I can understand it being a configurable setting though. Not sure if Fluffy wants to go that route, and if it should be configured per job or in global mod settings. Don't want to clutter anything too badly with corner cases. I can add the configurable setting with Fluffy's confirmation and preferred direction.

On Sat, Oct 26, 2019, 6:45 AM dandiez notifications@github.com wrote:

@maarxx https://github.com/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)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fluffy-mods/ColonyManager/pull/147?email_source=notifications&email_token=ABYST24C5A3SKZHBYVAPP4LQQQNVRA5CNFSM4I2T6CM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECKFH4I#issuecomment-546591729, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYST26LVBUDI2F7OTLGMRLQQQNVRANCNFSM4I2T6CMQ .

dandiez commented 4 years ago

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 commented 4 years ago

I have added an example of the slider to #151