setup teamID placeholder
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
[/Script/EngineSettings.GameMapsSettings]
|
[/Script/EngineSettings.GameMapsSettings]
|
||||||
GameDefaultMap=/Game/TempLevel.TempLevel
|
GameDefaultMap=/Game/Maps/GameLevel.GameLevel
|
||||||
EditorStartupMap=/Game/TempLevel.TempLevel
|
EditorStartupMap=/Game/Maps/GameLevel.GameLevel
|
||||||
|
|
||||||
[/Script/Engine.RendererSettings]
|
[/Script/Engine.RendererSettings]
|
||||||
r.AllowStaticLighting=False
|
r.AllowStaticLighting=False
|
||||||
|
|||||||
BIN
Content/Maps/GameLevel.umap
LFS
BIN
Content/Maps/GameLevel.umap
LFS
Binary file not shown.
@@ -16,13 +16,14 @@ public class Crunch : ModuleRules
|
|||||||
"EnhancedInput",
|
"EnhancedInput",
|
||||||
"GameplayAbilities",
|
"GameplayAbilities",
|
||||||
"GameplayTasks",
|
"GameplayTasks",
|
||||||
"GameplayTags"
|
"GameplayTags",
|
||||||
|
"AIModule"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
PrivateDependencyModuleNames.AddRange([
|
PrivateDependencyModuleNames.AddRange([
|
||||||
"UMG",
|
"UMG",
|
||||||
"Slate",
|
"Slate",
|
||||||
"SlateCore"
|
"SlateCore",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Uncomment if you are using Slate UI
|
// Uncomment if you are using Slate UI
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "GAS/CAttributeSet.h"
|
#include "GAS/CAttributeSet.h"
|
||||||
#include "GAS/UCAbilitySystemStatics.h"
|
#include "GAS/UCAbilitySystemStatics.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Net/UnrealNetwork.h"
|
||||||
|
#include "Player/CPlayerController.h"
|
||||||
#include "Widgets/OverHeadStatsGauge.h"
|
#include "Widgets/OverHeadStatsGauge.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -69,6 +71,12 @@ void ACCharacter::PossessedBy(AController* NewController)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACCharacter::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
|
||||||
|
{
|
||||||
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
DOREPLIFETIME(ACCharacter, TeamId);
|
||||||
|
}
|
||||||
|
|
||||||
UAbilitySystemComponent* ACCharacter::GetAbilitySystemComponent() const
|
UAbilitySystemComponent* ACCharacter::GetAbilitySystemComponent() const
|
||||||
{
|
{
|
||||||
return CAbilitySystemComponent;
|
return CAbilitySystemComponent;
|
||||||
@@ -146,7 +154,7 @@ void ACCharacter::PlayDeathAnimation()
|
|||||||
{
|
{
|
||||||
if (DeathMontage)
|
if (DeathMontage)
|
||||||
{
|
{
|
||||||
const auto MontageDuration {PlayAnimMontage(DeathMontage)};
|
const auto MontageDuration{PlayAnimMontage(DeathMontage)};
|
||||||
GetWorldTimerManager().SetTimer(
|
GetWorldTimerManager().SetTimer(
|
||||||
DeathMontageTimerHandle,
|
DeathMontageTimerHandle,
|
||||||
this,
|
this,
|
||||||
@@ -184,7 +192,7 @@ void ACCharacter::StartDeathSequence()
|
|||||||
OnDead();
|
OnDead();
|
||||||
PlayDeathAnimation();
|
PlayDeathAnimation();
|
||||||
SetStatusGaugeEnabled(false);
|
SetStatusGaugeEnabled(false);
|
||||||
|
|
||||||
GetCharacterMovement()->SetMovementMode(MOVE_None);
|
GetCharacterMovement()->SetMovementMode(MOVE_None);
|
||||||
GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
}
|
}
|
||||||
@@ -210,3 +218,13 @@ void ACCharacter::OnDead()
|
|||||||
void ACCharacter::OnRespawn()
|
void ACCharacter::OnRespawn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACCharacter::SetGenericTeamId(const FGenericTeamId& NewTeamID)
|
||||||
|
{
|
||||||
|
TeamId = NewTeamID;
|
||||||
|
}
|
||||||
|
|
||||||
|
FGenericTeamId ACCharacter::GetGenericTeamId() const
|
||||||
|
{
|
||||||
|
return TeamId;
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,14 +5,22 @@
|
|||||||
|
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "Character/CPlayerCharacter.h"
|
#include "Character/CPlayerCharacter.h"
|
||||||
|
#include "Net/UnrealNetwork.h"
|
||||||
#include "Widgets/GameplayWidget.h"
|
#include "Widgets/GameplayWidget.h"
|
||||||
|
|
||||||
|
void ACPlayerController::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
|
||||||
|
{
|
||||||
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
DOREPLIFETIME(ACPlayerController, TeamId);
|
||||||
|
}
|
||||||
|
|
||||||
void ACPlayerController::OnPossess(APawn* InPawn)
|
void ACPlayerController::OnPossess(APawn* InPawn)
|
||||||
{
|
{
|
||||||
Super::OnPossess(InPawn);
|
Super::OnPossess(InPawn);
|
||||||
if (CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn); IsValid(CPlayerCharacter))
|
if (CPlayerCharacter = Cast<ACPlayerCharacter>(InPawn); IsValid(CPlayerCharacter))
|
||||||
{
|
{
|
||||||
CPlayerCharacter->ServerSideInit();
|
CPlayerCharacter->ServerSideInit();
|
||||||
|
CPlayerCharacter->SetGenericTeamId(TeamId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +34,16 @@ void ACPlayerController::AcknowledgePossession(APawn* P)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FGenericTeamId ACPlayerController::GetGenericTeamId() const
|
||||||
|
{
|
||||||
|
return TeamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACPlayerController::SetGenericTeamId(const FGenericTeamId& NewTeamID)
|
||||||
|
{
|
||||||
|
TeamId = NewTeamID;
|
||||||
|
}
|
||||||
|
|
||||||
void ACPlayerController::SpawnGameplayWidget()
|
void ACPlayerController::SpawnGameplayWidget()
|
||||||
{
|
{
|
||||||
if (!IsLocalPlayerController()) return;
|
if (!IsLocalPlayerController()) return;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "AbilitySystemInterface.h"
|
#include "AbilitySystemInterface.h"
|
||||||
#include "GameplayTagContainer.h"
|
#include "GameplayTagContainer.h"
|
||||||
|
#include "GenericTeamAgentInterface.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "CCharacter.generated.h"
|
#include "CCharacter.generated.h"
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ class UCAbilitySystemComponent;
|
|||||||
class UCAttributeSet;
|
class UCAttributeSet;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class CRUNCH_API ACCharacter : public ACharacter, public IAbilitySystemInterface
|
class CRUNCH_API ACCharacter : public ACharacter, public IAbilitySystemInterface, public IGenericTeamAgentInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ public:
|
|||||||
bool IsLocallyControlledByPlayer() const;
|
bool IsLocallyControlledByPlayer() const;
|
||||||
// Only called on the server
|
// Only called on the server
|
||||||
virtual void PossessedBy(AController* NewController) override;
|
virtual void PossessedBy(AController* NewController) override;
|
||||||
|
virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
/* Gameplay Ability */
|
/* Gameplay Ability */
|
||||||
@@ -78,4 +80,14 @@ private:
|
|||||||
void ReSpawn();
|
void ReSpawn();
|
||||||
virtual void OnDead();
|
virtual void OnDead();
|
||||||
virtual void OnRespawn();
|
virtual void OnRespawn();
|
||||||
|
public:
|
||||||
|
/********************************************************************************************/
|
||||||
|
/* Team */
|
||||||
|
/********************************************************************************************/
|
||||||
|
virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
|
||||||
|
virtual FGenericTeamId GetGenericTeamId() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(Replicated)
|
||||||
|
FGenericTeamId TeamId;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameFramework/PlayerController.h"
|
#include "GameFramework/PlayerController.h"
|
||||||
|
#include "GenericTeamAgentInterface.h"
|
||||||
#include "CPlayerController.generated.h"
|
#include "CPlayerController.generated.h"
|
||||||
|
|
||||||
class UGameplayWidget;
|
class UGameplayWidget;
|
||||||
class ACPlayerCharacter;
|
class ACPlayerCharacter;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class CRUNCH_API ACPlayerController : public APlayerController
|
class CRUNCH_API ACPlayerController : public APlayerController, public IGenericTeamAgentInterface
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
@@ -18,13 +19,23 @@ public:
|
|||||||
virtual void OnPossess(APawn* InPawn) override;
|
virtual void OnPossess(APawn* InPawn) override;
|
||||||
virtual void AcknowledgePossession(APawn* P) override;
|
virtual void AcknowledgePossession(APawn* P) override;
|
||||||
|
|
||||||
|
virtual FGenericTeamId GetGenericTeamId() const override;
|
||||||
|
virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
|
||||||
|
virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SpawnGameplayWidget();
|
void SpawnGameplayWidget();
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TObjectPtr<ACPlayerCharacter> CPlayerCharacter;
|
TObjectPtr<ACPlayerCharacter> CPlayerCharacter;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category= "UI")
|
UPROPERTY(EditDefaultsOnly, Category= "UI")
|
||||||
TSubclassOf<UGameplayWidget> GameplayWidgetClass;
|
TSubclassOf<UGameplayWidget> GameplayWidgetClass;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TObjectPtr<UGameplayWidget> GameplayWidget;
|
TObjectPtr<UGameplayWidget> GameplayWidget;
|
||||||
|
|
||||||
|
UPROPERTY(Replicated)
|
||||||
|
FGenericTeamId TeamId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user