Why does "CacheAccessibleThings" use Plant.HarvestableSoon?

Started by dninemfive, January 11, 2019, 12:39:07 AM

Previous topic - Next topic

dninemfive

I'm working on a mod which implements a new class inheriting from Plant which inverts fertility behavior (i.e. low fertility is counted as high and vice versa). Luckily, there are only two uses of GrowthRateFactor_Fertility, so I replaced those references with a reference to a different variable with the behavior described above. Luckily, one, GrowthRate, is a virtual float so I overrode it. Unfortunately, the latter is HarvestableSoon, though this is only referenced in one other place: "CacheAccessibleThings" in PlayerItemAccessibilityUtility.

It's above my head, honestly, and I don't get why something which I assume reserves items for future use cares whether plants might be harvested soon in addition to immediately. What would be the long-run AI consequences if this method got incorrect information about whether certain plants are harvestable?

Mehni

QuoteI don't get why something which I assume reserves items for future use cares whether plants might be harvested soon in addition to immediately.

Why risk a false assumption when you can use a decompiler to see what it is really used for? Right-click any method/field/Type and hit Analyse.

CacheAccessibleThings is used by PossiblyAccessibleThings, which is used by IncidentWorker_QuestTradeRequest. In other words, your allies are after your devilstrand harvest and they want to know if it's ready soon ;)

Quick edit: can't you use negative values for fertility instead?

dninemfive

Thanks! I guess I just assumed that that had many more than just one use. I'll just leave the method as-is since that incident blacklists the yield type (stone chunks) anyway.

As for using negative fertility, the term base.def.plant.fertilitySensitivity + (1f - base.def.plant.fertilitySensitivity) cancels out negative fertility sensitivity values, unfortunately.

LWM

Quote from: dninemfive on January 11, 2019, 03:52:13 PM
As for using negative fertility, the term base.def.plant.fertilitySensitivity + (1f - base.def.plant.fertilitySensitivity) cancels out negative fertility sensitivity values, unfortunately.
?  What "term" is this?  In get GrowthRateFactor_Fertility?

If it helps, use your PreAlgebra to re-factor the terms:
return (FertilityAt(base.Position) -1)* this.def.plant.fertilitySensitivity + 1f;

If fertility is less than one (stony), FertilityAt(position) is negative, so a negative fertilitySensitivity gives a positive growth term.

Apologies if I misunderstood.

--LWM