-
Notifications
You must be signed in to change notification settings - Fork 0
2. Resource Component Base (Actor Component)
Cutter Hodnett edited this page Nov 9, 2024
·
1 revision
Resource Component Base (child of Actor Component)
#include "Components/ResourceComponentBase.h"
- OnCurrentAmountChange(Float NewValue)
- Called when any change to Current Amount occurs.
- OnDrain(Float NewValue)
- Called when any Drain occurs.
- OnAdd(Float NewValue)
- Called when any Add occurs.
- OnFill
- Called when Add results in CurrentAmount meets MaximumAmount.
- OnEmpty
- Called when Drain results in CurrentAmount meets 0.
- OnRegenStart
- Called when Regeneration begins. (Immediately before the first RegenTick occurs.)
- OnRegenEnd
- Called when Regeneration ends, whether through fill or a new drain occurring.
- OnRegenTick(Float NewValue)
- Called on every tick Regen occurs.
- Resource Name Name
- The name used to identify this resource.
- Max Amount Float
- The base maximum amount of this resource.
- Regen Amount Float
- How much resource is filled per regen tick.
- Regen Rate Float
- How many regen ticks occur per second.
- Regen Delay Float
- The delay after draining the resource when regen begins.
- Additional Exhausted Delay Float
- This is added to RegenDelay if regen begins when CurrentAmount is 0.
- Regen After Depletion Bool
- If true the resource will generate even after depletion. Useful for renewable resources such as Stamina.
- AddResource (Float AddAmount)
- Increases the resource by a certain amount.
- DrainResource (Float DrainAmount)
- Reduces the resource by a certain amount.
- AddResourceByPercent (Float AddPercent, EResourcePercentType PercentType)
- Increases the resource by a percent relative to the current value or max value.
- DrainResourceByPercent (Float DrainPercent, EResourcePercentType PercentType)
- Reduces the resource by a percent relative to the current value or max value.
-
Float GetCurrentAmount()
- Gets the value of the current amount of resource.
-
Float GetMaxAmount()
- Gets the value of the max amount of resource
-
Float GetCurrentPercent()
- Returns a percent (0 - 1.0) available of the resource.
-
Float GetTimeSinceLastDrain()
- Gets time in seconds since the last drain attempt.
- SetRegenAmount (Float NewRegenAmount)
- Modifies how much resource is filled per regen tick.
- SetRegenRate (Float NewRegenRate)
- Modifies the speed of regeneration.
- SetRegenDelay(Float NewRegenDelay)
- Modifies how long until regen begins after draining.
- SetAdditionalExhaustedDelay(Float NewValue)
- Modifies how long until regen begins after reaching 0.
- SetRegenAfterDepletion(Bool NewValue)
- Sets whether the resource regenerates at 0 resource.
-
Bool GetCanBeDrained()
- Checks if the resource can be drained.
- SetCanBeDrained(Bool NewParam)
- Sets whether the resource can be drained.
- Setting any of the Regen variables to an invalid amount, for example: RegenAmount, Rate, or Delay being negative will disable regeneration.
- Many variables have Get and Set functions that can be overridden. This is to allow for modifications to the resource, such as an increase upon leveling where you may override GetMaxAmount() as MaxAmount * Level.
- Dispatchers are called on all instances, but may be called prior to replication. Related functions have a float that provides the soon-to-be replicated value. It is highly recommended to use this output instead of GetCurrentAmount.
- Setting the Regen variables during runtime should not affect delays or ticks unless modified as such, and should continue regenerating with the modification.