HarvestSystem
Purpose: Used for collecting wild plants, trees, and rocks
APrimalHarvest: Harvest entity Actor, with health, interaction component (UUltimateCommandComponent), and Harvest component (UHarvestComponent)
Variable/Function | Explain |
---|---|
bDestroyed | Has it been destroyed? After destruction, it will not be possible to harvest again |
Health/MaxHealth | Health/MaxHealth |
SavedDamage | Store damage, used to store damage from players or monsters to plants. After reaching the maximum health * 0.1f, the stored damage will be cleared and items will be given according to the type of damage |
BreakSound | Destroy the sound effect, play the sound effect when the plant is destroyed |
PickupSound | Picking up sound effects, E key interactive picking up objects on the ground or picking up bushes to play sound effects |
DestructableActorClass | Destroy entity type, used to play the effect of falling trees or dissipating rocks after being destroyed. This entity is only generated on non dedicated servers (generated on clients) and has no collisions,The original entity will be hidden and collision removed, and will not be destroyed (it will be restored after a period of time, and the recovery code has not been written yet) |
MulticastBreak(FVector Location, FVector Direction) | The multicast is destroyed, and then OnBreak is called to remove the collision playing sound effect and generate DestructableActor |
MulticastOnHit(FVector Location, FVector Direction) | Multicast is injured and then calls OnHit |
ASmallHarvest (inheriting APrimalHarvest): A physical actor that can be picked up, such as small stones, branches, and shrubs
Variable/Function | Explain |
---|---|
Meshs | Static grid body array, which will randomly use the grid bodies in the list |
OnPickup(ACharacter* Character) | Pick up the item, and then call OnPickupInternal to apply damage to the entity. By default, 10. f damage will be given once. This function is for players to interact manually, instead of using tools to do direct damage |
ADestructableHarvest/ADestructable_ Tree: Destroyed entity, used to display the entities generated by the destruction of harvested plants,Generated only on the client side for decoration purposes
Variable/Function | Explain |
---|---|
Mesh | Static mesh |
ForceDirection | The direction of force, used for the direction of force when a tree falls |
AddForce | Add force, called in BeginPlay |
EHarvestAdditionType:The bonus type, for example, the axe damage type has the bonus of cutting wood, and the Pickaxe has the bonus of iron ore
FHarvestAddition:Bonus type structure, used in damage type (UPrimalDamageType)
Variable | Explain |
---|---|
HarvestAdditionType | Type of bonus, such as bonus wood, iron ore, etc |
ProbabilityMultiplication | Bonus chance, such as axe, will make it easier to harvest wood |
AddtionMultiplication | Addition rate, such as axe, will yield more wood |
FHarvestResource:Harvested materials for harvesting data lists(FTableHarvest)
Variable | Explain |
---|---|
Resource | Resource(UPrimalItemBasic) |
Quantity | Quantity |
Probability | Probability |
Empty | Is Empty,For example, collecting bushes has a chance of not giving items |
AdditionType | AdditionType |
FTableHarvest:Structure of the Harvest Table,You need to create a table,Add a material list for example: Shrub 1 (berries, branches), each harvest will randomly obtain one material from the material list (randomly based on probability)
UHarvestComponent:Components do not need to be networked, used to select harvest material forms and experiences, and provide items
Variable/Function | Explain |
---|---|
HarvestResourceTable | Harvest Table, Structure FTableHarvest |
BaseExp | GiveExp |
bCanPickup | Can you pick it up? For example, small stones and bushes can be picked up, trees and rocks cannot be picked up, and only tools or fists can be used to inflict damage |
GiveHarvestResource(UPrimalDamageType* DamageType,ACharacter* Character) | Provide harvest materials, including bonus data in DamageType |
GetCanPickup | Can pick up |