FReplicatedPlayerArrayItem
Overview
This struct is used within the FReplicatedPlayerArray to store individual player states. It includes a weak pointer to an APlayerState and provides comparison operators for equality checks.
Properties
Type | Name | Access | Description |
|---|---|---|---|
TWeakObjectPtr | PlayerState | Public | Weak pointer to the associated player state. |
Functions
Return Type | Signature | Description |
|---|---|---|
bool | operator==(const FReplicatedPlayerArrayItem& Other) const | Compares this item with another |
bool | operator==(const APlayerState* Test) const | Checks if the weak pointer to |
FReplicatedPlayerArray
Overview
This struct inherits from FFastArraySerializer and manages an array of FReplicatedPlayerArrayItem, which in turn hold weak pointers to APlayerState. It provides a method for delta serialization to optimize network traffic during state changes.
Properties
Type | Name | Access | Description |
|---|---|---|---|
TArray | Items | Public | Array of items, each containing a weak pointer to an |
Functions
Return Type | Signature | Description |
|---|---|---|
bool | NetDeltaSerialize(FNetDeltaSerializeInfo & DeltaParms) | Serializes the array for network transmission using delta encoding. |
ALimenGameStateBase
Overview
This class inherits from AGameStateBase and manages a list of players through replicated properties. It provides functions to add/remove players and notifies when the player list changes.
Properties
Type | Name | Access | Description |
|---|---|---|---|
FPlayerListChanged | OnPlayerListChanged | Public | Multicast delegate that is called when the player list changes. |
FReplicatedPlayerArray | ReplicatedPlayerList | Private | Replicated array of player states for network synchronization. |
TArray<APlayerState*> | PlayerList | Private | Local copy of the player list, updated from |
Functions
Return Type | Signature | Description |
|---|---|---|
void | AddPlayerToPlayerList(APlayerState* NewPlayer) | Adds a new player to the player list if they are not already present. |
void | RemovePlayerFromPlayerList(APlayerState* Player) | Removes a player from the player list if they exist. |
const TArray<APlayerState*>& | GetPlayerList() const | Returns the current list of players. |
void | GetLifetimeReplicatedProps(TArray & OutLifetimeProps) const | Registers properties for replication, including |
void | PlayersListChanged() | Updates the local |
void | OnRep_LimenPlayerList() | Handles the replication of |
Usage & Implementation Notes
The class uses a replicated array to manage player states, ensuring that all players in the game can see the current list of active players.
The
OnPlayerListChangeddelegate is used to notify other parts of the game when the player list changes, allowing for synchronization and updates across different systems or clients.The
ReplicatedPlayerArrayItemstruct uses weak pointers to avoid holding strong references to player states, which could prevent garbage collection.