ULimenCreditsComponent
Overview
ULimenCreditsComponent is a custom actor component that manages credits for an actor. It provides functionality to deposit and withdraw credits, as well as retrieve the current credit balance. The component supports replication of credit changes across the network, making it suitable for multiplayer games where credit balances need to be synchronized between clients.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| OnCreditsUpdated | BlueprintAssignable | A multicast delegate that is triggered when credits are updated. |
| bAllowNegativeBalance | EditDefaultsOnly, BlueprintReadOnly | Determines if negative credit balances are allowed. |
| StartingCredits | EditDefaultsOnly | The initial number of credits the component starts with. |
| Multiplier | Private | A multiplier applied to deposited credits. |
| CurrentCredits | ReplicatedUsing=OnRep_CurrentCredits, Transient | The current number of credits, replicated across the network. |
Functions
Return Type | Signature | Description |
|---|---|---|
| DepositCredits(const int64 NewCredits) | Deposits a specified amount of credits into the component's balance. |
| WithdrawCredits(const int64 OutCredits) | Attempts to withdraw a specified amount of credits from the component's balance. Returns true if successful, false otherwise. |
| GetCreditsString() const | Returns the current credit balance as a formatted string. |
| GetCredits() const | Returns the current credit balance as an integer. |
| SetStartingCredits(const int32 NewStartingCredits) | Sets the initial number of credits for the component. |
| SetCreditsMultiplier(const float NewMultiplier) | Sets a multiplier that is applied to deposited credits. |
| CreditsUpdated() | Broadcasts the |
| OnRep_CurrentCredits() | Handles replication of the |
Usage & Implementation Notes
Threading Constraints: This component is designed to be used on the game thread.
Replication Requirements: The
CurrentCreditsproperty is replicated usingREPNOTIFY_OnChanged, ensuring that credit changes are synchronized across the network.Memory Lifetime Management: The
CurrentCreditsproperty is marked asTransient, meaning it will not be saved or loaded from disk. It is only relevant during gameplay.Initialization Dependencies: The component must be attached to an actor with authority, as it performs operations that require server-side control (e.g., depositing and withdrawing credits).