Table of Contents

Class CropContainerBehaviour

Namespace
GrindFest
Assembly
GrindFest.dll

State machine and crop lifecycle manager for any object that can hold a planted crop: tilled farm plots, plant pots, planter boxes, greenhouse benches, etc.

Call Initialize(Vector3) (done automatically by TillingSkill) to mark the container as a tilled terrain plot. Set Rows and Columns in the Inspector on the prefab. Use standalone on pot/planter prefabs without calling Initialize.

After planting, this component instantiates the FirstStagePrefab as a child. That child carries a CropBehaviour which drives the growth timer, visual transitions, and tooltip display autonomously. Growth state is derived on-demand via IsEmpty, IsMature, and IsOvergrown.

[AddComponentMenu("GrindFest/Farming/Crop Container")]
[RequireComponent(typeof(LiquidContainerBehaviour))]
[RequireComponent(typeof(InteractiveBehaviour))]
public class CropContainerBehaviour : MonoBehaviour, ISerializableComponent
Inheritance
object
CropContainerBehaviour
Implements

Fields

Columns

Number of plants per row, spaced along RowDirection.

ContainerGridSpacing

Spacing in metres between plants when spawning in a grid.

Rows

Properties

CropType

The crop type (e.g. "Wheat", "Tomato"), derived from the first live crop stage.

Crops

All CropBehaviour instances currently managed by this container. Populated by PlantSeed(SeedsBehaviour) and pruned when crops are destroyed.

IsEmpty
IsMature
IsOvergrown
IsPlanted
IsTilledPlot

Whether this container was tilled on terrain (set to true by Initialize(Vector3)). Use this to distinguish farm plots from free-standing pots/planters.

RowDirection

Direction the hero was facing when the plot was tilled. Used for gizmo rendering.

StateDescription

Human-readable state name. Useful for debug logs and assertions.

WasWatered

True when the soil has water in it (i.e. the watering can poured at least one unit in). Backed by the sibling LiquidContainerBehaviour that represents soil moisture.

Methods

ClearAfterHarvest()

Clears the container after harvest — destroys all crop stage children and resets to Empty. Crop objects drop their own loot via DropTableLootBehaviour when they die; this method only resets the container's state.

Deserialize(Dictionary<string, string>)
FindNearest(Vector3, FarmState, float)

Finds the nearest CropContainerBehaviour in the given state within maxDistance. Searches all containers in the active scene — tilled farm plots, pots, planters, etc.

Initialize(Vector3)

Called by TillingSkill when the plot is created on terrain. Sets IsTilledPlot and row direction. Rows and Columns are configured on the prefab in the Inspector.

PlantSeed(SeedsBehaviour)

Plants a seed. Instantiates the crop's first stage prefab as a child of this container.

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

Waters this container's crop. Halves the remaining growth time on the current stage.