HarvestableChild
Introduction
HarvestableChild is a class in the Harvester system which defines the properties and behaviors of the child objects that can be harvested by the Harvester. These child objects are generated by the Harvester when it interacts with a parent object in the scene that has been marked as harvestable.
Each HarvestableChild has a unique ID which is used to track it within the system. It also has a reference to its parent object, which is used to determine where it should be spawned when it is harvested. HarvestableChildren have a number of properties that can be set by the user to customize their behavior and appearance, such as their offset from the parent object, the probability that they will be spawned when the parent is harvested, and whether or not they should be destroyed when they are harvested.
HarvestableChildren can also define their own OnHarvest event, which is called when they are harvested. This event can be used to trigger custom behaviors such as particle effects or sound effects. When a HarvestableChild is harvested, it is removed from the scene and added to the Harvester’s inventory.
The Harvester system uses a configurable spawning algorithm to determine how many HarvestableChildren should be spawned when the parent object is harvested. This algorithm takes into account the number of HarvestableChildren that exist on the parent object, the probability that each child will be spawned, and the maximum number of children that can be spawned in a single harvest.
HarvestableChildren can also be configured to use the Harvester’s Network Manager to synchronize their state across a network. This allows multiple players to harvest the same parent object and receive the same child objects, ensuring that the state of the game remains consistent for all players.
Overall, HarvestableChild is a flexible and powerful system for defining and managing child objects that can be harvested in a game. Its customizable properties and events allow developers to create a wide variety of different harvestable objects with unique behaviors and appearances, while its network synchronization capabilities ensure that the game remains consistent across all players.
Overview
The HarvestableChild
class is a C# script that is used to define child objects of a HarvestableObject
in a game developed with the HNGamers framework. This script is responsible for adding and removing the child object to and from the parent HarvestableObject
‘s list of child objects when the child object is created and destroyed.
Interface pages:
None.
Constructor pages:
None.
Method pages:
Method Name | Return Type | Description |
---|---|---|
Start() | void | Unity method that is called when the script is first initialized. Sets the parent object of the child object, retrieves the HarvestableObject component from the parent object, retrieves the HarvestableChild component from the child object, and adds the child object to the parent HarvestableObject ‘s list of child objects if it is not already present. |
OnDestroy() | void | Unity method that is called when the child object is destroyed. Removes the child object from the parent HarvestableObject ‘s list of child objects if it is present. |
Property pages:
Property Name | Type | Description |
---|---|---|
parent | Transform | The transform of the parent object of the child object. |
parentObject | GameObject | The parent object of the child object. |
thisObject | HarvestableObject | The HarvestableObject component of the parent object of the child object. |
thisChild | HarvestableChild | The HarvestableChild component of the child object. |
Event pages:
None.
Concept/guide pages:
None.
Examples:
None.