Apply Rider cleanup

This commit is contained in:
Louis Hobbs 2023-06-23 21:06:18 +01:00
parent 9bd298bd6e
commit b5088f3bae
42 changed files with 177 additions and 190 deletions

View File

@ -1,11 +1,10 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class NakatomiTarget : TargetRules
{
public NakatomiTarget( TargetInfo Target) : base(Target)
public NakatomiTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;

View File

@ -14,24 +14,25 @@ void ADemolitionCharacter::Explode()
if (ExplosionParticleSystem)
{
UGameplayStatics::SpawnEmitterAtLocation(this,
ExplosionParticleSystem,
this->ActorToWorld().GetLocation(),
FRotator::ZeroRotator,
true);
ExplosionParticleSystem,
this->ActorToWorld().GetLocation(),
FRotator::ZeroRotator,
true);
}
TArray<FOverlapResult> outOverlaps;
GetWorld()->OverlapMultiByObjectType(outOverlaps,
ActorToWorld().GetLocation(),
FQuat::Identity,
FCollisionObjectQueryParams::AllObjects,
FCollisionShape::MakeSphere(ExplosionRadius));
ActorToWorld().GetLocation(),
FQuat::Identity,
FCollisionObjectQueryParams::AllObjects,
FCollisionShape::MakeSphere(ExplosionRadius));
for (FOverlapResult Overlaps : outOverlaps)
{
if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>())
{
float distance = FVector::Distance(ActorToWorld().GetLocation(), Overlaps.GetActor()->ActorToWorld().GetLocation());
float distance = FVector::Distance(ActorToWorld().GetLocation(),
Overlaps.GetActor()->ActorToWorld().GetLocation());
float scale = 1.f - (distance / ExplosionRadius);
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
}

View File

@ -31,8 +31,6 @@ protected:
float MaxDamage = 150.f;
public:
UFUNCTION()
void Explode();
};

View File

@ -26,7 +26,5 @@ protected:
virtual void BeginPlay() override;
public:
void Destruct();
};

View File

@ -72,7 +72,7 @@ void AEnemyAIController::OnDeath(FDamageInfo info)
enemy->DetachFromControllerPendingDestroy();
enemy->GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
enemy->GetCapsuleComponent()->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
enemy->GetCapsuleComponent()->SetCollisionResponseToAllChannels(ECR_Ignore);
enemy->GetMesh()->SetCollisionProfileName("Ragdoll");
enemy->SetActorEnableCollision(true);

View File

@ -21,7 +21,6 @@ class NAKATOMI_API AEnemyAIController : public AAIController
GENERATED_BODY()
private:
UBlackboardComponent* Blackboard;
UBehaviorTreeComponent* BehaviorTree;

View File

@ -40,7 +40,7 @@ UAIPerceptionComponent* AEnemyCharacter::GetPerceptionComponent()
void AEnemyCharacter::OnFire()
{
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Firing);
CurrentWeapon->SetCurrentWeaponStatus(Firing);
TArray<FHitResult> Hits = TArray<FHitResult>();
CalculateHits(&Hits);
@ -50,7 +50,7 @@ void AEnemyCharacter::OnFire()
// TODO: Play some animation here
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
}
void AEnemyCharacter::BeginPlay()
@ -84,7 +84,8 @@ void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits)
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
{
// Calculate the maximum distance the weapon can fire
FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread), FMath::DegreesToRadians(Spread));
FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread),
FMath::DegreesToRadians(Spread));
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
@ -108,7 +109,8 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
// Spawn field actor
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform,
SpawnParameters);
if (Hit.GetActor())
{
@ -119,7 +121,8 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
if (auto healthComponent = Hit.GetActor()->GetComponentByClass<UHealthComponent>())
{
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, GetController(), this);
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this);
}
}
}

View File

@ -20,7 +20,6 @@ class NAKATOMI_API AEnemyCharacter : public ANakatomiCharacter
GENERATED_BODY()
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
UAIPerceptionComponent* PerceptionComponent;
@ -45,7 +44,6 @@ protected:
virtual void BeginPlay() override;
private:
virtual void CalculateHits(TArray<FHitResult>* hits) override;
virtual void ProcessHits(TArray<FHitResult> hits) override;

View File

@ -8,7 +8,7 @@
// Sets default values
AExplosiveActor::AExplosiveActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
@ -22,7 +22,6 @@ AExplosiveActor::AExplosiveActor()
void AExplosiveActor::BeginPlay()
{
Super::BeginPlay();
}
void AExplosiveActor::Explode()
@ -34,24 +33,25 @@ void AExplosiveActor::Explode()
if (ExplosionParticleSystem)
{
UGameplayStatics::SpawnEmitterAtLocation(this,
ExplosionParticleSystem,
this->ActorToWorld().GetLocation(),
FRotator::ZeroRotator,
true);
ExplosionParticleSystem,
this->ActorToWorld().GetLocation(),
FRotator::ZeroRotator,
true);
}
TArray<FOverlapResult> outOverlaps;
GetWorld()->OverlapMultiByObjectType(outOverlaps,
ActorToWorld().GetLocation(),
FQuat::Identity,
FCollisionObjectQueryParams::AllObjects,
FCollisionShape::MakeSphere(ExplosionRadius));
ActorToWorld().GetLocation(),
FQuat::Identity,
FCollisionObjectQueryParams::AllObjects,
FCollisionShape::MakeSphere(ExplosionRadius));
for (FOverlapResult Overlaps : outOverlaps)
{
if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>())
{
float distance = FVector::Distance(ActorToWorld().GetLocation(), Overlaps.GetActor()->ActorToWorld().GetLocation());
float distance = FVector::Distance(ActorToWorld().GetLocation(),
Overlaps.GetActor()->ActorToWorld().GetLocation());
float scale = 1.f - (distance / ExplosionRadius);
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
}
@ -71,4 +71,3 @@ void AExplosiveActor::Explode()
this->Destroy();
}

View File

@ -15,7 +15,6 @@ class NAKATOMI_API AExplosiveActor : public AActor
GENERATED_BODY()
protected:
UPROPERTY(EditDefaultsOnly)
UStaticMeshComponent* StaticMeshComponent;
@ -35,11 +34,9 @@ protected:
float MaxDamage = 150.f;
private:
UPROPERTY(VisibleDefaultsOnly)
UHealthComponent* HealthComponent = nullptr;
public:
// Sets default values for this actor's properties
AExplosiveActor();
@ -49,7 +46,6 @@ protected:
virtual void BeginPlay() override;
public:
UFUNCTION()
void Explode();
};

View File

@ -26,7 +26,8 @@ EBTNodeResult::Type UGetDistanceToPlayerTask::ExecuteTask(UBehaviorTreeComponent
if (distance < DistanceThreshold)
{
enemyPawn->Explode();
enemyPawn->GetHealthComponent()->TakeDamage(enemyPawn, enemyPawn->GetHealthComponent()->GetMaxHealth(), nullptr, nullptr, nullptr);
enemyPawn->GetHealthComponent()->TakeDamage(enemyPawn, enemyPawn->GetHealthComponent()->GetMaxHealth(), nullptr,
nullptr, nullptr);
return EBTNodeResult::Succeeded;
}

View File

@ -13,8 +13,8 @@ UCLASS()
class NAKATOMI_API UGetDistanceToPlayerTask : public UBTTaskNode
{
GENERATED_BODY()
private:
private:
UPROPERTY()
UBehaviorTreeComponent* behaviourTreeOwner = nullptr;
@ -25,12 +25,9 @@ private:
float DistanceThreshold = 5.0f;
public:
UGetDistanceToPlayerTask();
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
virtual EBTNodeResult::Type AbortTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};

View File

@ -13,7 +13,8 @@ UHealthComponent::UHealthComponent()
// ...
}
void UHealthComponent::TakeDamage(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy, AActor* damageCauser)
void UHealthComponent::TakeDamage(AActor* damagedActor, float damage, const UDamageType* damageType,
AController* instigatedBy, AActor* damageCauser)
{
if (damagedActor == nullptr || IsDead || !CanDamage)
{
@ -22,12 +23,12 @@ void UHealthComponent::TakeDamage(AActor* damagedActor, float damage, const UDam
CurrentHealth -= damage;
OnDamaged.ExecuteIfBound({ damagedActor, damage, damageType, instigatedBy, damageCauser });
OnDamaged.ExecuteIfBound({damagedActor, damage, damageType, instigatedBy, damageCauser});
if (CurrentHealth <= 0.0f)
{
IsDead = true;
OnDeath.ExecuteIfBound({ damagedActor, damage, damageType, instigatedBy, damageCauser });
OnDeath.ExecuteIfBound({damagedActor, damage, damageType, instigatedBy, damageCauser});
}
}
@ -104,9 +105,4 @@ void UHealthComponent::BeginPlay()
Super::BeginPlay();
ResetHealth();
}

View File

@ -30,18 +30,16 @@ struct FDamageInfo
DECLARE_DELEGATE_OneParam(FOnDamageDelegate, FDamageInfo)
DECLARE_DELEGATE_OneParam(FOnDeathDelegate, FDamageInfo)
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class NAKATOMI_API UHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
FOnDamageDelegate OnDamaged;
FOnDeathDelegate OnDeath;
private:
UPROPERTY(EditDefaultsOnly)
float MaxHealth = 100.f;
@ -53,12 +51,12 @@ private:
bool CanDamage = true;
public:
// Sets default values for this component's properties
UHealthComponent();
UFUNCTION()
void TakeDamage(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy, AActor* damageCauser);
void TakeDamage(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy,
AActor* damageCauser);
UFUNCTION()
void IncrementHealth(float value);
@ -96,6 +94,4 @@ public:
protected:
// Called when the game starts
virtual void BeginPlay() override;
};

View File

@ -24,6 +24,7 @@ void UInteractableComponent::Interact()
{
}
void UInteractableComponent::Interact(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy, AActor* damageCauser)
void UInteractableComponent::Interact(AActor* damagedActor, float damage, const UDamageType* damageType,
AController* instigatedBy, AActor* damageCauser)
{
}

View File

@ -7,7 +7,7 @@
#include "InteractableComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class NAKATOMI_API UInteractableComponent : public UActorComponent
{
GENERATED_BODY()
@ -21,9 +21,8 @@ protected:
virtual void BeginPlay() override;
public:
void Interact();
void Interact(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy, AActor* damageCauser);
void Interact(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy,
AActor* damageCauser);
};

View File

@ -8,9 +8,13 @@ public class Nakatomi : ModuleRules
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine", "GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem" });
PublicDependencyModuleNames.AddRange(new[]
{
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine",
"GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

View File

@ -3,4 +3,4 @@
#include "Nakatomi.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Nakatomi, "Nakatomi" );
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, Nakatomi, "Nakatomi");

View File

@ -3,4 +3,3 @@
#pragma once
#include "CoreMinimal.h"

View File

@ -6,7 +6,7 @@
// Sets default values
ANakatomiCharacter::ANakatomiCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
@ -24,7 +24,6 @@ void ANakatomiCharacter::BeginPlay()
void ANakatomiCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input

View File

@ -17,7 +17,6 @@ class NAKATOMI_API ANakatomiCharacter : public ACharacter
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TArray<TSubclassOf<class AWeapon>> DefaultWeaponInventory;
@ -28,7 +27,6 @@ public:
AWeapon* CurrentWeapon = nullptr;
private:
UPROPERTY(VisibleDefaultsOnly)
UHealthComponent* HealthComponent = nullptr;
@ -82,7 +80,6 @@ public:
virtual void OnFire();
protected:
virtual void CalculateHits(TArray<FHitResult>* hits);
virtual void ProcessHits(TArray<FHitResult> hits);

View File

@ -14,14 +14,15 @@ ANakatomiFieldSystemActor::ANakatomiFieldSystemActor()
RadialVector = CreateDefaultSubobject<URadialVector>(TEXT("Radial Vector"));
CullingField = CreateDefaultSubobject<UCullingField>(TEXT("Culling Field"));
SphereComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
SphereComponent->SetCollisionResponseToAllChannels(ECR_Overlap);
}
void ANakatomiFieldSystemActor::BeginPlay()
{
Radius = SphereComponent->GetScaledSphereRadius();
Position = GetActorLocation();
RadialFalloff = RadialFalloff->SetRadialFalloff(StrainMagnitude, MinRange, MaxRange, Default, Radius, Position, EFieldFalloffType::Field_FallOff_None);
RadialFalloff = RadialFalloff->SetRadialFalloff(StrainMagnitude, MinRange, MaxRange, Default, Radius, Position,
Field_FallOff_None);
GetFieldSystemComponent()->ApplyPhysicsField(true, Field_ExternalClusterStrain, nullptr, RadialFalloff);
RadialVector = RadialVector->SetRadialVector(ForceMagnitude, Position);

View File

@ -16,9 +16,7 @@ class NAKATOMI_API ANakatomiFieldSystemActor : public AFieldSystemActor
{
GENERATED_BODY()
private:
UPROPERTY()
USphereComponent* SphereComponent;
@ -50,11 +48,9 @@ private:
FVector Position = FVector::ZeroVector;
public:
ANakatomiFieldSystemActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
};

View File

@ -2,4 +2,3 @@
#include "NakatomiGameModeBase.h"

View File

@ -13,5 +13,4 @@ UCLASS()
class NAKATOMI_API ANakatomiGameModeBase : public AGameModeBase
{
GENERATED_BODY()
};

View File

@ -15,5 +15,4 @@ class NAKATOMI_API ANakatomiPlayerController : public APlayerController
GENERATED_BODY()
public:
};

View File

@ -33,13 +33,13 @@ APlayerCharacter::APlayerCharacter()
CameraBoom->TargetArmLength = 350.0f;
CameraBoom->bEnableCameraLag = true;
CameraBoom->CameraLagSpeed = 10.0f;
CameraBoom->SocketOffset = { 0.0f, 75.0f, 110.0f };
CameraBoom->SocketOffset = {0.0f, 75.0f, 110.0f};
// Setup the camera component
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
CameraComponent->bUsePawnControlRotation = false;
CameraComponent->SetRelativeRotation({ -5.0f,0.0f,0.0f });
CameraComponent->SetRelativeRotation({-5.0f, 0.0f, 0.0f});
// Setup the character movement
UCharacterMovementComponent* CharacterMovementComponent = GetCharacterMovement();
@ -89,7 +89,8 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
if (APlayerController* PC = Cast<APlayerController>(GetController()))
{
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = ULocalPlayer::GetSubsystem<
UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
{
if (!InputMappingContext.IsNull())
{
@ -134,7 +135,8 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
if (WeaponSwitchingAction)
{
Input->BindAction(WeaponSwitchingAction, ETriggerEvent::Triggered, this, &APlayerCharacter::WeaponSwitchingCallback);
Input->BindAction(WeaponSwitchingAction, ETriggerEvent::Triggered, this,
&APlayerCharacter::WeaponSwitchingCallback);
}
}
}
@ -168,7 +170,7 @@ void APlayerCharacter::JumpCallback(const FInputActionInstance& Instance)
void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
{
if (CurrentWeapon == nullptr || CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != WeaponState::Idle)
if (CurrentWeapon == nullptr || CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != Idle)
{
return;
}
@ -184,12 +186,15 @@ void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
if (CurrentWeapon->GetWeaponProperties()->IsAutomatic)
{
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler, CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
GetWorldTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire, CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler,
CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
GetWorldTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire,
CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
}
else
{
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler, CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler,
CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
}
}
@ -243,7 +248,8 @@ void APlayerCharacter::CalculateHits(TArray<FHitResult>* hits)
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
{
// Calculate the maximum distance the weapon can fire
FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread), FMath::DegreesToRadians(Spread));
FVector ShootDir = WeaponRandomStream.VRandCone(AimDir, FMath::DegreesToRadians(Spread),
FMath::DegreesToRadians(Spread));
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
@ -269,7 +275,8 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
{
FTransform transform;
transform.SetLocation(Hit.ImpactPoint);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform,
SpawnParameters);
if (field)
{
@ -286,7 +293,8 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
if (auto healthComponent = Hit.GetActor()->GetComponentByClass<UHealthComponent>())
{
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, GetController(), this);
healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr,
GetController(), this);
}
}
}
@ -313,7 +321,7 @@ void APlayerCharacter::OnFire()
return;
}
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Firing);
CurrentWeapon->SetCurrentWeaponStatus(Firing);
TArray<FHitResult> Hits = TArray<FHitResult>();
CalculateHits(&Hits);
@ -325,7 +333,7 @@ void APlayerCharacter::OnFire()
// TODO: Play some animation here
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
if (CurrentWeapon->GetAmmoCount() == 0)
{
@ -335,9 +343,9 @@ void APlayerCharacter::OnFire()
void APlayerCharacter::WeaponCooldownHandler()
{
if (CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != WeaponState::Idle)
if (CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != Idle)
{
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Idle);
CurrentWeapon->SetCurrentWeaponStatus(Idle);
}
if (!IsFiring)

View File

@ -28,7 +28,6 @@ class NAKATOMI_API APlayerCharacter : public ANakatomiCharacter
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* MovementAction;
@ -60,12 +59,10 @@ public:
TSubclassOf<class UUserWidget> PlayerHUD;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
float SprintSpeedMultiplier = 2.0f;
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
USpringArmComponent* CameraBoom = nullptr;
@ -131,7 +128,6 @@ public:
float GetCurrentHealthCount();
protected:
virtual void CalculateHits(TArray<FHitResult>* hits) override;
virtual void ProcessHits(TArray<FHitResult> hits) override;

View File

@ -16,5 +16,4 @@ class NAKATOMI_API UPlayerHealthComponent : public UHealthComponent
protected:
virtual void BeginPlay() override;
};

View File

@ -16,12 +16,10 @@ class NAKATOMI_API ARandomWeapon : public AWeapon
GENERATED_BODY()
private:
UPROPERTY(VisibleAnywhere, Category = "Random Weapon Parameters")
URandomWeaponParameters* RandomWeaponParameters;
public:
ARandomWeapon();
protected:

View File

@ -24,7 +24,7 @@ FWeaponProperties URandomWeaponParameters::GenerateRandomWeaponProperties()
}
else
{
weaponProperties.IsAutomatic = bool(FMath::Rand() % 2);
weaponProperties.IsAutomatic = static_cast<bool>(FMath::Rand() % 2);
}
return weaponProperties;

View File

@ -18,52 +18,67 @@ class NAKATOMI_API URandomWeaponParameters : public UActorComponent
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Cooldown", DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "5" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Cooldown", DisplayName = "Min",
meta = ( ClampMin = "0", ClampMax = "5" ))
float CooldownMin = 0.1f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Cooldown", DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "5"))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Cooldown", DisplayName = "Max",
meta = ( ClampMin = "0", ClampMax = "5"))
float CooldownMax = 2.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Damage", DisplayName = "Min", meta = ( ClampMin = "0" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Damage", DisplayName = "Min",
meta = ( ClampMin = "0" ))
float DamageMin = 10.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Damage", DisplayName = "Max", meta = ( ClampMin = "0"))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Damage", DisplayName = "Max",
meta = ( ClampMin = "0"))
float DamageMax = 10.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Change Time", DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "5" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Change Time", DisplayName = "Min",
meta = ( ClampMin = "0", ClampMax = "5" ))
float ChangeTimeMin = 0.1f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Change Time", DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "5" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Change Time", DisplayName = "Max",
meta = ( ClampMin = "0", ClampMax = "5" ))
float ChangeTimeMax = 2.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Max Ammo", DisplayName = "Min", meta = ( ClampMin = "0" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Max Ammo", DisplayName = "Min",
meta = ( ClampMin = "0" ))
int MaxAmmoMin = 4;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Max Ammo", DisplayName = "Max", meta = ( ClampMin = "0" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Max Ammo", DisplayName = "Max",
meta = ( ClampMin = "0" ))
int MaxAmmoMax = 200;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Default Ammo", DisplayName = "Min", meta = ( ClampMin = "0" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Default Ammo", DisplayName = "Min",
meta = ( ClampMin = "0" ))
int DefaultAmmoMin = 4;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Default Ammo", DisplayName = "Max")
int DefaultAmmoMax = 200;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Per Shot", DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "50" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Per Shot",
DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "50" ))
int ProjectilePerShotMin = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Per Shot", DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "50" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Per Shot",
DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "50" ))
int ProjectilePerShotMax = 20;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Range", DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "1000000" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Range",
DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "1000000" ))
float ProjectileRangeMin = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Range", DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "1000000" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Projectile Range",
DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "1000000" ))
float ProjectileRangeMax = 25000.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Weapon Spread", DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "360" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Weapon Spread",
DisplayName = "Min", meta = ( ClampMin = "0", ClampMax = "360" ))
float WeaponSpreadMin = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Weapon Spread", DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "360" ))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Weapon Spread",
DisplayName = "Max", meta = ( ClampMin = "0", ClampMax = "360" ))
float WeaponSpreadMax = 15.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Is Automatic")

View File

@ -15,9 +15,9 @@ class NAKATOMI_API UTaskFireWeapon : public UBTTaskNode
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "Options", Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
UPROPERTY(EditAnywhere, Category = "Options",
Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
FBlackboardKeySelector TargetActor;
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};

View File

@ -13,15 +13,16 @@ UCLASS()
class NAKATOMI_API UTaskGetRandomLocation : public UBTTaskNode
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "Options", Meta = (AllowPrivateAccess = "true", DisplayName = "Patrol Location Key"))
public:
UPROPERTY(EditAnywhere, Category = "Options",
Meta = (AllowPrivateAccess = "true", DisplayName = "Patrol Location Key"))
FBlackboardKeySelector PatrolLocationKey;
UPROPERTY(EditAnywhere, Category = "Options", Meta = (AllowPrivateAccess = "true", DisplayName = "Maximum Distance"))
UPROPERTY(EditAnywhere, Category = "Options",
Meta = (AllowPrivateAccess = "true", DisplayName = "Maximum Distance"))
float MaximumDistance = 500.0f;
public:
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};

View File

@ -7,7 +7,6 @@
// Sets default values
AWeapon::AWeapon()
{
}
// Called when the game starts or when spawned
@ -16,7 +15,6 @@ void AWeapon::BeginPlay()
Super::BeginPlay();
SetAmmoCountToDefault();
}
USkeletalMesh* AWeapon::GetSkeletalMesh()

View File

@ -26,7 +26,6 @@ class NAKATOMI_API AWeapon : public AActor
GENERATED_BODY()
protected:
UPROPERTY(EditDefaultsOnly)
USkeletalMesh* WeaponSkeletalMesh = nullptr;

View File

@ -6,7 +6,7 @@
// Sets default values
AWeaponPickup::AWeaponPickup()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.SetTickFunctionEnable(true);
PrimaryActorTick.bStartWithTickEnabled = true;
@ -52,13 +52,15 @@ void AWeaponPickup::Tick(float DeltaTime)
WeaponComponent->SetActorLocation(WeaponStartingLocation + ((MovementDirection * Sine) * MovementDistance));
}
PointLightComponent->MarkRenderStateDirty(); // We have to do this because Unreal doesn't like it when you create lights in c++ apparently ::pain::
PointLightComponent->MarkRenderStateDirty();
// We have to do this because Unreal doesn't like it when you create lights in c++ apparently ::pain::
float sin = FMath::Abs(FMath::Sin(GetWorld()->GetRealTimeSeconds() * (MovementSpeed / 2)));
PointLightComponent->SetLightBrightness(sin * MaxLightBrightness);
}
void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
const FHitResult& SweepResult)
{
// TODO: Add extra checking here
auto player = Cast<APlayerCharacter>(OtherActor);
@ -100,7 +102,8 @@ void AWeaponPickup::SpawnWeapon()
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
WeaponComponent = GetWorld()->SpawnActor<AWeapon>(Weapon, SpawnParameters);
FAttachmentTransformRules TransformRules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true);
FAttachmentTransformRules TransformRules = FAttachmentTransformRules(
EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true);
WeaponComponent->AttachToComponent(RootComponent, TransformRules);
WeaponComponent->SetActorRelativeLocation(FVector(0.0f, 0.0f, 5.0f));
WeaponComponent->SetActorEnableCollision(false);
@ -108,4 +111,3 @@ void AWeaponPickup::SpawnWeapon()
WeaponStartingLocation = WeaponComponent->GetActorLocation();
WeaponStartingLocation += ((MovementDirection * MovementDistance) / 2);
}

View File

@ -16,7 +16,6 @@ class NAKATOMI_API AWeaponPickup : public AActor
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class AWeapon> Weapon;
@ -42,7 +41,6 @@ public:
FColor LightColor = FColor::White;
private:
UPROPERTY()
USphereComponent* SphereComponent;
@ -70,7 +68,8 @@ public:
virtual void Tick(float DeltaTime) override;
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
void OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
void SetWeapon(TSubclassOf<class AWeapon> weapon);
@ -79,6 +78,5 @@ public:
void SetWeaponProperties(FWeaponProperties FWeaponProperties);
private:
void SpawnWeapon();
};

View File

@ -1,11 +1,10 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class NakatomiEditorTarget : TargetRules
{
public NakatomiEditorTarget( TargetInfo Target) : base(Target)
public NakatomiEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;