Initial Commit - Lesson 31 (Commit #1)
This commit is contained in:
92
Source/FPSTemplate/Public/Player/MatchPlayerState.h
Normal file
92
Source/FPSTemplate/Public/Player/MatchPlayerState.h
Normal file
@@ -0,0 +1,92 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "Data/SpecialElimData.h"
|
||||
|
||||
#include "MatchPlayerState.generated.h"
|
||||
|
||||
enum class ESpecialElimType : uint16;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnScoreChanged, int32, NewScore);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API AMatchPlayerState : public APlayerState
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
AMatchPlayerState();
|
||||
|
||||
void AddScoredElim();
|
||||
void AddDefeat();
|
||||
void AddHit();
|
||||
void AddMiss();
|
||||
APlayerState* GetLastAttacker() const { return LastAttacker; }
|
||||
void SetLastAttacker(APlayerState* Attacker) { LastAttacker = Attacker; }
|
||||
bool IsOnStreak() const { return bOnStreak; }
|
||||
void SetOnStreak(bool bIsOnStreak) { bOnStreak = bIsOnStreak; }
|
||||
int32 GetScoredElims() const { return ScoredElims; }
|
||||
|
||||
void AddHeadShotElim();
|
||||
void AddSequentialElim(int32 SequenceCount);
|
||||
void UpdateHighestStreak(int32 StreakCount);
|
||||
void AddRevengeElim();
|
||||
void AddDethroneElim();
|
||||
void AddShowStopperElim();
|
||||
void GotFirstBlood();
|
||||
void IsTheWinner();
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void Client_SpecialElim(const ESpecialElimType& SpecialElim, int32 SequentialElimCount, int32 StreakCount, int32 ElimScore);
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void Client_ScoredElim(int32 ElimScore);
|
||||
|
||||
UFUNCTION(Client, Reliable)
|
||||
void Client_LostTheLead();
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnScoreChanged OnScoreChanged;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TObjectPtr<USpecialElimData> SpecialElimData;
|
||||
|
||||
TArray<ESpecialElimType> DecodeElimBitmask(ESpecialElimType ElimTypeBitmask);
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "UI")
|
||||
TSubclassOf<UUserWidget> SpecialElimWidgetClass;
|
||||
|
||||
private:
|
||||
int32 ScoredElims;
|
||||
int32 Defeats;
|
||||
int32 Hits;
|
||||
int32 Misses;
|
||||
bool bOnStreak;
|
||||
|
||||
int32 HeadShotElims;
|
||||
TMap<int32, int32> SequentialElims;
|
||||
int32 HighestStreak;
|
||||
int32 RevengeElims;
|
||||
int32 DethroneElims;
|
||||
int32 ShowStopperElims;
|
||||
bool bFirstBlood;
|
||||
bool bWinner;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<APlayerState> LastAttacker;
|
||||
|
||||
TQueue<FSpecialElimInfo> SpecialElimQueue;
|
||||
bool bIsProcessingQueue;
|
||||
|
||||
void ProcessNextSpecialElim();
|
||||
void ShowSpecialElim(const FSpecialElimInfo& ElimMessageInfo);
|
||||
};
|
||||
|
||||
|
||||
58
Source/FPSTemplate/Public/Player/ShooterPlayerController.h
Normal file
58
Source/FPSTemplate/Public/Player/ShooterPlayerController.h
Normal file
@@ -0,0 +1,58 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "ShooterPlayerController.generated.h"
|
||||
|
||||
struct FInputActionValue;
|
||||
class UInputMappingContext;
|
||||
class UInputAction;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnPlayerStateReplicated);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API AShooterPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
AShooterPlayerController();
|
||||
bool bPawnAlive;
|
||||
virtual void OnPossess(APawn* InPawn) override;
|
||||
virtual void OnRep_PlayerState() override;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnPlayerStateReplicated OnPlayerStateReplicated;
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void SetupInputComponent() override;
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, Category="Input")
|
||||
TObjectPtr<UInputMappingContext> ShooterIMC;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Input")
|
||||
TObjectPtr<UInputAction> MoveAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Input")
|
||||
TObjectPtr<UInputAction> LookAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Input")
|
||||
TObjectPtr<UInputAction> CrouchAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Input")
|
||||
TObjectPtr<UInputAction> JumpAction;
|
||||
|
||||
|
||||
void Input_Move(const FInputActionValue& InputActionValue);
|
||||
void Input_Look(const FInputActionValue& InputActionValue);
|
||||
void Input_Crouch();
|
||||
void Input_Jump();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user