Class CropBehaviour
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
Drives a crop's lifecycle on a single GameObject.
Two modes:
- Multi-mesh stage mode – for harvestable individual plants (wheat stalks, tomato bushes). Add child GameObjects (one per visual age) to VisualStages. The component cycles through them by timer. When all stages are done the crop is harvestable. Combine with HealthBehaviour + DropTableLootBehaviour — the plant is destroyed by normal attacks.
- Spawn-grid mode – for the seedling row prefab that spawns many individual plant objects when it matures. Set NextStagePrefab + SpawnCount. When the timer expires the seedling is destroyed and N plant prefabs are spawned in a grid, each carrying their own CropBehaviour in multi-mesh mode.
WheatSeedling.prefab → CropStageBehaviour { NextStagePrefab=WheatStalk, Duration=120s, SpawnCount=16, GridSpacing=0.4f }
WheatStalk.prefab → CropStageBehaviour { VisualStages=[S,M,L], StageDurations=[30,30,0], IsHarvestable=true } + HealthBehaviour + DropTable
Tomato setup:
TomatoSprout.prefab → CropStageBehaviour { NextStagePrefab=TomatoBush, Duration=60s, SpawnCount=4, GridSpacing=1.2f }
TomatoBush.prefab → CropStageBehaviour { VisualStages=[S,M,Mature], StageDurations=[20,20,0], IsHarvestable=true } + HealthBehaviour + DropTable
public class CropBehaviour : MonoBehaviour, ISerializableComponent
- Inheritance
-
objectCropBehaviour
- Implements
Fields
- CropType
The crop type name (e.g. "Wheat", "Tomato"). Set in the prefab Inspector.
Properties
- Elapsed
Raw elapsed seconds into the current growth stage. Set on load to restore progress.
- IsAtFinalStage
True when in multi-mesh mode and at the last visual stage (ready to harvest).
- IsOvergrown
True when the crop has been mature for longer than OvergrownAfterSeconds.
- OvergrownIn
Seconds remaining before this crop becomes overgrown. -1 if the timer is disabled.
- SaveKey
Where this component's payload lives inside Components: stable, unique, and not to be changed - renaming it silently orphans the payload of every save that already exists. Ours are named after what they store ("GrindFest.ResourcePotion", not "...LiquidContainerBehaviour"); a mod must use its own prefix ("MyMod.Whatever").
The default is the component's type name. That is stable for a plain C# component but not for a generated/proxied one, so a mod should always declare this explicitly rather than rely on it.
- TimeToNextStage
Seconds remaining until the current visual stage advances.
Methods
- DisplayTooltip(StringBuilder, HeroController, CropContainerBehaviour)
Appends crop tooltip lines to
sb(called by OnDisplayTooltip(StringBuilder, HeroController, InteractiveBehaviour)).
- ForceAdvance()
Force the next visual stage transition immediately (skip timer).
- GetContainerName(string, CropContainerBehaviour)
Returns the nameplate text for the parent container (called by GrindFest.CropContainerBehaviour.GetContainerName()).
- Water()
Watering the crop: halves the remaining growth time on the current stage.