ULimenUpgrade
Overview
ULimenUpgrade is a blueprintable UObject that handles the logic for applying upgrades to players. It manages upgrade levels, costs, values, and replication across the network. This class provides functions to process upgrades, check if an upgrade can be applied, and get current upgrade details.
Properties
Type | Name | Access | Description |
|---|---|---|---|
FText | UpgradeName | EditDefaultsOnly, BlueprintReadOnly | The name of the upgrade. |
FText | UpgradeDescription | EditDefaultsOnly, BlueprintReadOnly | A description of the upgrade. |
int32 | MaxLevel | EditDefaultsOnly, BlueprintReadOnly | The maximum level the upgrade can reach. |
TObjectPtr | CostFunction | EditDefaultsOnly, BlueprintReadOnly | Curve defining the cost of upgrades at different levels. |
TObjectPtr | UpgradeFunction | EditDefaultsOnly, BlueprintReadOnly | Curve defining the value of upgrades at different levels. |
int32 | CurrentLevel | ReplicatedUsing=OnRep_CurrentLevel, BlueprintReadOnly | The current level of the upgrade. |
TWeakObjectPtr | BoundController | Replicated | The controller bound to this upgrade. |
TWeakObjectPtr | BoundPawn | Replicated | The pawn bound to this upgrade. |
float | UpgradeCostMultiplier | Replicated | Multiplier for the cost of upgrades. |
TPair<int32, float> | LastUpgradeCostMultiplierLevel | Replicated | Last known level and multiplier for cost. |
float | UpgradeValueMultiplier | Replicated | Multiplier for the value of upgrades. |
TPair<int32, float> | LastUpgradeValueMultiplierLevel | Replicated | Last known level and multiplier for value. |
Functions
Return Type | Signature | Description |
|---|---|---|
void | ProcessUpgrade(AController* InController, APawn* InPawn, ULimenCreditsComponent* CreditsComponent) | Processes the application of an upgrade to a player. |
bool | CanApplyUpgrade(AController* InController, APawn* InPawn, const ULimenCreditsComponent* CreditsComponent) const | Checks if an upgrade can be applied based on current level and credits. |
int32 | GetCurrentUpgradeLevel() const | Returns the current level of the upgrade. |
int32 | GetCost(int32 Level) const | Calculates the cost of an upgrade at a given level. |
void | SetCostMultiplier(const float NewMultiplier) | Sets a new multiplier for the cost of upgrades. |
float | GetUpgradeValue(int32 Level) const | Calculates the value of an upgrade at a given level. |
void | SetValueMultiplier(const float NewMultiplier) | Sets a new multiplier for the value of upgrades. |
Usage & Implementation Notes
The
ProcessUpgradefunction handles the logic for applying an upgrade, including checking if it can be applied and updating the current level.The
Multicast_ProcessUpgrade_Implementationfunction is used to replicate the application of an upgrade across the network.The class uses replication to ensure that all relevant properties are synchronized between the server and clients.