Table of Contents

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.
Wheat setup:
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
object
CropBehaviour
Implements

Fields

CropType

The crop type name (e.g. "Wheat", "Tomato"). Set in the prefab Inspector.

FruitPrefab
FruitSpawnPoints
LifetimeAfterMatureSeconds
OvergrownAfterSeconds
StageDurations
VisualStages

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.

TimeToNextStage

Seconds remaining until the current visual stage advances.

Methods

Deserialize(Dictionary<string, string>)
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()).

Serialize(Dictionary<string, string>)
Water()

Watering the crop: halves the remaining growth time on the current stage.