Player Farming System has some key functions you may wish to modify when adding it to your own project, these function handle removing and checking if the player has the required resources to place an object. What is collected when a plant is harvested or when an object is picked up and how to select which object is selected for preview placement.
Below is the DeductPlacementCost function found in the BP_PlayerFarmingComponent, this is the code used to remove resources from the player.
It includes some example variables that you can use to for example access your own inventory to remove items from it when the object is placed.
Below is the CheckPlacementCost function found in the BP_PlayerFarmingComponent, this checks the player has the required resource to place the object.
It includes some example variables that you can use to for example access your own inventory to check if it has the items required to place the object.
The Cost struct is an array of the S_Resource structure which contains a Name variable for the resource it should use and an Integer variable which is the amount of that resource that should be used, you can use this array to specify which item from your inventory should be removed or checked for.
The function below is the HarvestVegetables function found in the BP_PlayerFarmingComponent, its used to add the resources from the plant to the players resources.
In here is where you would implement you own code to add items to your inventory, it uses an array of the S_Resource structure the same as the previous 2 functions. These provide the name of the resource and the amount of that resource to add, you can use this to specify to your inventory which items it should add.
The function below is the Pickup function found in the BP_PlayerFarmingComponent, it is used to add resource to the players resource when an object is picked up.
Here like previous function there is a Pickup Resource output from the PFS Pickup function, it uses the same S_Resources struct as an array to provide the name and amount of a resource that should be added to the player resources, you can use this to specify to your inventory which items it should add.
Selecting Placement Object
The event below is the ClientSelectPlacementActor event, it is used to tell the player farming system which object the player is selecting to preview.
To call it you will need a valid reference of the Player Farming Component like in the BP_FarmingCharacter. You set the Row Name to the Row Name from the data tables like the PlantList or ToolsList data table like shown in the image below.
This function can also be called from a widget like in the BP_SelectionMenuPanel like shown below.
For this code to work in the widget the Player Farming Component variable must be valid, this can be done like in the image below and can be done in any widget blueprint.