BP_UGS_ResourceNode_Base

This is the base class for all of the resource nodes, including the example content.

If you want to create your own node then this is the class you want to create a child class from.

Functions

Initialize Resource Tags

This function initializes the resource tags and is essential for the system to function correctly. If you override the BeginPlay function when creating a subclass of the BP_UGS_ResourceNode_Base, make sure to call the parent method. This function is private and cannot be called outside of the this base class.

Try Harvest

Use this function to harvest a resource node. It handles:

  • Checking if the resource node is harvestable.

  • Calculating the gathering rate.

  • Verifying depletion conditions

The function returns true if the node is successfully harvested and false if the harvest fails.

Harvest

This function should be overridden in your child class. It is executed only when all Harvest Conditions, such as Can Harvest and Has Required Item Tags has been met.

You should handle item transferring from the resource node to the characters inventory here.

Example of Giving an Item to the Gathering Character upon successfully harvesting a node.

On Node Depleted

This event will be executed when the Depletion Condition has been met.

Address post-depletion logic here, such as managing events like chaos destruction or modifying the mesh to reflect a depleted state.

OnNodeDepleted() Event Example, setting the Static Mesh to a mesh that indicates its been depleted.

Can Harvest

If you need to have extra logic for when a resource node can be harvested, then override this function.

Examples could be:

  • Resource availability

  • Environmental factors

  • Time of day

  • Harvest Count

Example of CanHarvest() with Harvest Count

Has Required Item Tags

This function returns true if the resource node matches the Gatherer Tag.

Depletion Condition

This function allows you to determine when the resource node should be depleted.

Examples of this could be:

  • No more available resources left.

  • Health has been depleted

This function should be overridden.

Example of DepletionCondition() for a harvest count type resource node.
circle-exclamation

Calculate Gathering Rate

This guide explains various calculation methods for determining gathering rates based on the Base Resource Rate and the Item Gathering Rate.

  • Average: Computes the average of the Base Resource Rate and the Item Gathering Rate.

  • Max: Selects the higher value between the Base Resource Rate and the Item Gathering Rate.

  • Min: Selects the lower value between the Base Resource Rate and the Item Gathering Rate.

  • Divide: Divides the Base Resource Rate by the Item Gathering Rate.

  • Multiply: Multiplies the Item Gathering Rate by the Base Resource Rate.

  • Add: Sums the Base Resource Rate with the Item Gathering Rate.

  • Base Only: Utilizes only the Base Resource Gathering Rate.

This system allows you to decide different calculation types based on the Base Resource Gathering Rate and the Item Gathering Rate values.

Calculate Resource Rate Remainder

Determine the remaining resources. Use this to track leftover resources in a resource node and account for them over time.

Is Node Depleted

Returns true if node has been depleted.

Last updated