PotatoSapling
A class in Root.Township, the global namespace.
Server: a plant that spawns a random number of pullable crops (potatoes and the like) at set positions, and disposes of itself once all are pulled.
- Listed in Global namespace: P
- Inherits or implements
GeneratedNetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
PotatoSapling() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private DisposablePickup disposable | Disposes the plant once empty. |
private GrowerGroup growerGroup | Optional group that grows crops over time. |
private GrowthDefinition growth | Growth to plant at each position. Use this or prefab. |
private int maximum | Most crops to spawn (default 5). |
private int minimum | Fewest crops to spawn (default 1). |
private SpawnPositions positions | Spawn positions for the crops. |
private NetworkPrefab prefab | Crop prefab spawned directly when growth is not set. |
private AnimationCurve probabilityCurve | Curve that weights the crop count. |
private PullPickupGroup pullPickupGroup | Group of crops that can be pulled out. |
Methods
| Member | What it is |
|---|---|
override void InitializeAsServer(SpawnData spawnData) | Hooks the grower group and pull group, adds existing crops, and disposes at once if there are none. |
protected override void Generate(SpawnData spawnData) | At generation, spawns the picked number of crops. |
7 private and internal methods
| Member | What it is |
|---|---|
private void AddPickup(Pickup pickup) | Adds a grown pickup to the pull group. |
private void CheckDispose() | Disposes the plant if nothing is left to pull. |
private int EvaluateCount() | Picks a count between minimum and maximum, weighted by probabilityCurve. |
private void PickupPulled(Pickup pickup) | When the last crop is pulled, checks a frame later whether to dispose. |
private void RemovePickup(Pickup pickup) | Removes a pickup from the pull group. |
private void Setup(NetworkEntity child, int index) | Adds a spawned crop's pickup to the pull group. |
private void SpawnChildren(SpawnData spawnData, int quantity) | Spawns each crop as prefab or, if growth is set, adds it to the grower group to grow. |