GASATHON/Project/Source/Gasa/Characters/GasaCharacter.cpp

120 lines
3.2 KiB
C++
Raw Normal View History

2024-04-12 11:49:22 -07:00
#include "GasaCharacter.h"
2024-04-13 08:09:22 -07:00
#include "AbilitySystemComponent.h"
2024-04-12 16:55:34 -07:00
#include "Camera/CameraComponent.h"
2024-04-12 19:05:09 -07:00
#include "Components/CapsuleComponent.h"
2024-04-12 16:55:34 -07:00
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/SpringArmComponent.h"
2024-04-12 19:05:09 -07:00
#include "Kismet/KismetSystemLibrary.h"
2024-04-12 16:55:34 -07:00
2024-04-13 08:09:22 -07:00
#include "AbilitySystem/GasaAbilitySystemComponent.h"
#include "Game/GasaLevelScriptActor.h"
2024-04-12 19:05:09 -07:00
void AGasaCharacter::SetHighlight(EHighlight Desired)
{
2024-04-12 19:05:09 -07:00
HighlightState = Desired;
}
2024-04-12 11:49:22 -07:00
AGasaCharacter::AGasaCharacter()
{
PrimaryActorTick.bCanEverTick = false;
2024-04-12 19:37:31 -07:00
HighlightColor = FLinearColor(0.8, 0.32, 0.05f, 1.f);
2024-04-12 16:55:34 -07:00
UCharacterMovementComponent*
Movement = GetCharacterMovement();
Movement->bOrientRotationToMovement = true;
Movement->bConstrainToPlane = true;
Movement->bSnapToPlaneAtStart = true;
Movement->RotationRate = FRotator(0.0, 400.f, 0.0);
bUseControllerRotationPitch = false;
bUseControllerRotationRoll = false;
bUseControllerRotationYaw = false;
USceneComponent* root_component = GetRootComponent();
USkeletalMeshComponent* mesh = GetMesh();
2024-04-12 11:49:22 -07:00
Weapon = CreateDefaultSubobject<USkeletalMeshComponent>("Weapon");
2024-04-12 16:55:34 -07:00
Weapon->SetupAttachment(mesh, FName("WeaponAttach"));
2024-04-12 11:49:22 -07:00
Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision);
2024-04-13 08:09:22 -07:00
if (bAutoAbilitySystem)
{
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
AbilitySystem->SetIsReplicated(true);
2024-04-13 08:56:19 -07:00
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);
2024-04-13 08:09:22 -07:00
Attributes = CreateDefaultSubobject<UAttributeSet>("Attributes");
}
2024-04-12 11:49:22 -07:00
}
2024-04-13 08:56:19 -07:00
#pragma region Pawn
void AGasaCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
if (bAutoAbilitySystem)
{
// TODO(Ed): Do we need to do this for enemies?
AbilitySystem->InitAbilityActorInfo(this, this);
}
}
void AGasaCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
}
#pragma endregion Pawn
#pragma region Actor
2024-04-12 11:49:22 -07:00
void AGasaCharacter::BeginPlay()
{
Super::BeginPlay();
}
2024-04-12 19:05:09 -07:00
void AGasaCharacter::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
USkeletalMeshComponent* mesh = GetMesh();
2024-04-12 19:05:09 -07:00
switch (HighlightState)
{
case EHighlight::Disabled:
{
mesh->SetRenderCustomDepth(false);
mesh->SetCustomDepthStencilValue(0.f);
Weapon->SetRenderCustomDepth(false);
Weapon->SetCustomDepthStencilValue(0.f);
}
2024-04-12 19:05:09 -07:00
break;
case EHighlight::Enabled:
{
mesh->SetRenderCustomDepth(true);
mesh->SetCustomDepthStencilValue(HighlightStencilDepth);
Weapon->SetRenderCustomDepth(true);
Weapon->SetCustomDepthStencilValue(HighlightStencilDepth);
APostProcessVolume* PPV = Gasa::GetLevelActor(this)->GlobalPPV;
TObjectPtr<UObject> Blendable = PPV->Settings.WeightedBlendables.Array[0].Object;
UMaterialInstanceDynamic*
MID = Cast<UMaterialInstanceDynamic>(Blendable);
MID->SetVectorParameterValue("Depth Highlight Color", HighlightColor);
#if 0
2024-04-12 19:05:09 -07:00
UCapsuleComponent* Capsule = GetCapsuleComponent();
UKismetSystemLibrary::DrawDebugCapsule(this
, Capsule->GetComponentLocation()
, Capsule->GetScaledCapsuleHalfHeight()^
2024-04-12 19:05:09 -07:00
, Capsule->GetScaledCapsuleRadius()
, Capsule->GetComponentRotation()
2024-04-12 19:37:31 -07:00
, HighlightColor
2024-04-12 19:05:09 -07:00
, 0.f
, 1.f
);
#endif
2024-04-12 19:05:09 -07:00
}
break;
}
}
2024-04-13 08:56:19 -07:00
#pragma endregion Actor