haxis/Source/UnrealProject/GameState/PlayerStateBase.h

52 lines
1.5 KiB
C++

#pragma once
#include "PlayerStateBase.Generated.h"
/*
Base player state, keeping the team the player is in
this class also keeps the ready state of players in the lobby and contains some functionality for joining/switching teams
*/
UCLASS()
class APlayerStateBase : public APlayerState
{
GENERATED_BODY()
friend class AGameStateBase;
friend class AMenuGameMode;
public:
APlayerStateBase();
virtual void BeginPlay() override;
UFUNCTION(Server, Reliable, WithValidation, Category = "Lobby")
void SetReadyState(bool state);
UFUNCTION(BlueprintCallable, Category = "Lobby")
bool GetReadyState() const;
// Used for seamless travel, this copies the previous player state into the current one
void Transfer(APlayerStateBase* oldState);
// Requests entry to a team
UFUNCTION(Server, Reliable, WithValidation, Category = "Lobby")
void RequestTeamEntry(uint8 team);
// Automatically join the prefered team by the server
UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = "Lobby")
void AutoAssignTeam();
UFUNCTION(BlueprintCallable, Category = "Lobby")
int32 GetTeam() const;
// Updates the nickname and the avatar of the player using the online subsystem
UFUNCTION(BlueprintCallable, Category = "Character")
void UpdatePersona();
UPROPERTY(BlueprintReadOnly, Category = "Character")
UTexture2D* avatar;
UPROPERTY(BlueprintReadOnly, Category = "Character")
FString nickname;
private:
UPROPERTY(Replicated)
bool m_readyToStart;
UPROPERTY(Replicated)
int32 m_team;
};