Skip to main content

Farming, woodcutting and carpentry

Root.Township: top-level growth types, Alta.Woodcutting and Alta.Carpentry. Server only for the rules.

Farming​

Plants grow through stages. A GrowthDefinition lists the stages, and something runs through them on timers: a GrowerComponent for one plant, or a GrowerGroup holding many GrowthItems (a planted potato patch uses a GrowerGroup through PotatoSapling).

GrowthDefinition and GrowthStage​

GrowthDefinition : HashedGeneralValue<GrowthDefinition>: GrowthStage[] Stages and IsChildingToParentAtEnd.

GrowthStage (serializable class) describes one stage:

MemberWhat it means
float DurationSeconds in this stage before trying the next.
float SurvivalRateChance to survive into the next stage (checked when moving on from it).
bool IsUsingRadius, float MinSeparationRadius, LayerMask RadiusCheckLayersFail if something is too close.
bool IsUsingRaycastCheck, float RaycastDistance, Vector3 RaycastDirectionFail if the way is blocked (room to grow).
bool RetryStageOn a failed check, try again later instead of dying.
ObjectPipeline Prefabs, bool IsUsingPreviousPrefabWhat to spawn for this stage.
KinematicForceMode ForceKinematicForce the spawned body kinematic or not.

Representative stage timings from the GrowthDefinition assets (build main-1.7.2.1.42203, 17 in all, checked against a live server; the reference tables don't list them). Durations are Timeline seconds, so they shorten with the host's TimeSpeedMultiplier:

DefinitionStages (duration, survival rate)
Apple Tree Growth StagesSeedling (2 h, 0.3), Sapling (5 h), Young Tree (15 h), Final Tree
Apple Fruit Growth StagesBud (1 h, 0.5), Flower (2 h, 0.75), Unripe (5 h), Ripe (10 h), Ripe fall off (1 h)
Potato Vegetable Growth StagesUnripe (3 h), Ripe
Oak Tree Growth StagesSeedling (1 h), Sapling (2 h), Young Tree (5 h), Final Tree, with RetryStage on the later stages

A survival rate of 1 is left out. Several durations carry an extra 5 seconds (3,605, 18,005 and so on) in the assets.

GrowerComponent​

GrowerComponent : NetworkEntityBehaviour, top level.

MemberWhat it does
void StartGrowing()Starts at stage 0. Called automatically on the server if autoStart is set.
void StopGrowth(bool isKeepingChild)Stops and destroys the grower, optionally keeping the current plant.
int CurrentStageIndex { get; }, GrowthStage CurrentStage { get; }, NetworkEntity CurrentStageEntity { get; }Where it is.
bool IsRunning { get; }, bool IsSetup { get; }

Each stage, the private GoToStage rolls survival and runs the checks. On success it spawns the stage's prefab and schedules the next stage on the game's Timeline after Duration. After the last stage it stops and keeps the plant. A failed check either retries (at least every 5 seconds) or kills the plant. The grower saves its state (GrowthSaveData), so growth carries on across restarts.

To speed up growth, a prefix on GoToStage can't change the delay (it's scheduled from inside the private HandleChecksResult). Patch HandleChecksResult's timeLeft argument, or the stage Duration fields on the shared GrowthDefinition asset.

Woodcutting​

TypeWhat it is
TreeSpawnerA spot in the world that grows a tree. On the server it spawns a random PresetTree with a random species and size, and when the tree is cut down at the base or split, waits 300 to 600 seconds (the code defaults, which every spawner in the dumped prefabs and scenes keeps) and spawns a new one. The wait is saved.
WoodcutTreeThe tree: a tree of MapNodes (Root), each with a WoodcutTreeModel segment. HealthObject, Rigidbody, TotalSize, Species. Raises Cut.
WoodcutTreeModelOne segment. Takes hits on its WoodcutPoints; when chopped through (PieceChopped, server) it spawns the species' wedge or stick drops at its drop locations and destroys itself.
TreeSpeciesSpecies asset: physical material, hit effects, Wedge and Stick drop distributions, damage and break multipliers, DropVelocity, leaf materials.
TreeDecayA BasicDecay on a tree: once a felled tree has come loose from its spawner (no chunking parent), it decays, but not while it's kinematic or within 120 seconds of its last hit. Follows the host's DecayMultiplier.
PresetTree, TreeBuilder, TreeSizeTree shapes and building them at runtime.
WoodcutTreeBaker and the *Baker typesMesh baking. Client and build side.

Woodcutting XP comes from tool hits through the impact channel system; see Progression.

Carpentry (chiselling)​

Alta.Carpentry. You put a timber block on a ChisellingDeck, place a chisel guide, and chisel the block's pieces away in stages.

TypeWhat it is
ChisellingDeckNetworkEntityBehaviour. Holds the current TimberBlock (CurrentBlock), the Guide (ChiselDefinition), its size and MaxSize. Resize(ChiselBlockSize) is server only.
ChiselDefinitionSimpleHashedGeneralValue<ChiselDefinition> under Carpentry/Chisel Definitions: a recipe page for chiselling. Size, ChiselOrder (12 shards), Prefabs to spawn when done.
TimberBlockThe block being chiselled, in stages (outer, inner, core). When finished it frees the resulting pickups and reports a SpecificSpawnItemTaskArgument per item type, with whether the guide was followed.
TimberPiece, TimberPieceGroup, TimberBlockSpawnerPieces of a block and spawning them.
ChiselingTool, ChiselableThe chisel and things it can hit. CraftingPieceChiselable lets generic crafting pieces be chiselled.
RecipePlacer, BuilderDockParts of a chiselling deck: the guide's light and pulse effects, and the dock that shows the piece being built.

See also​