Apply Rider cleanup
This commit is contained in:
parent
9bd298bd6e
commit
b5088f3bae
|
@ -1,15 +1,14 @@
|
|||
// 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;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
|
||||
ExtraModuleNames.Add("Nakatomi");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,31 +7,32 @@
|
|||
void ADemolitionCharacter::Explode()
|
||||
{
|
||||
GetHealthComponent()->TakeDamage(this, this->GetHealthComponent()->GetMaxHealth(), nullptr, nullptr, nullptr);
|
||||
|
||||
|
||||
FActorSpawnParameters SpawnParameters;
|
||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ UCLASS()
|
|||
class NAKATOMI_API ADemolitionCharacter : public AEnemyCharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USoundBase* ExplosionSound;
|
||||
|
@ -31,8 +31,6 @@ protected:
|
|||
float MaxDamage = 150.f;
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION()
|
||||
void Explode();
|
||||
|
||||
};
|
||||
|
|
|
@ -10,8 +10,8 @@ UCLASS()
|
|||
class NAKATOMI_API ADestructable : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
class UParticleSystem* ParticleEffect;
|
||||
|
||||
|
@ -26,7 +26,5 @@ protected:
|
|||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
||||
void Destruct();
|
||||
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ void AEnemyAIController::OnPossess(APawn* InPawn)
|
|||
enemy->GetCharacterMovement()->MaxWalkSpeed = 500.f;
|
||||
enemy->GetHealthComponent()->OnDamaged.BindUFunction(this, "OnDamaged");
|
||||
enemy->GetHealthComponent()->OnDeath.BindUFunction(this, "OnDeath");
|
||||
|
||||
|
||||
if (auto behaviourTree = enemy->GetBehaviourTree())
|
||||
{
|
||||
Blackboard->InitializeBlackboard(*behaviourTree->BlackboardAsset);
|
||||
|
@ -72,8 +72,8 @@ 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);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ class NAKATOMI_API AEnemyAIController : public AAIController
|
|||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
|
||||
UBlackboardComponent* Blackboard;
|
||||
|
||||
UBehaviorTreeComponent* BehaviorTree;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
AEnemyCharacter::AEnemyCharacter()
|
||||
{
|
||||
PerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));
|
||||
|
||||
|
||||
SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Configuration"));
|
||||
SightConfig->SightRadius = 700.0f;
|
||||
SightConfig->LoseSightRadius = 850.0f;
|
||||
|
@ -22,7 +22,7 @@ AEnemyCharacter::AEnemyCharacter()
|
|||
PerceptionComponent->ConfigureSense(*SightConfig);
|
||||
|
||||
RandomWeaponParameters = CreateDefaultSubobject<URandomWeaponParameters>(TEXT("Random Weapon Parameters"));
|
||||
|
||||
|
||||
GetHealthComponent()->SetMaxHealth(100.0f);
|
||||
|
||||
this->Tags.Add(FName("Enemy"));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ class NAKATOMI_API AEnemyCharacter : public ANakatomiCharacter
|
|||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
||||
UAIPerceptionComponent* PerceptionComponent;
|
||||
|
||||
|
@ -28,7 +27,7 @@ private:
|
|||
|
||||
UPROPERTY(EditDefaultsOnly, Meta = (AllowPrivateAccess = "true"))
|
||||
UBehaviorTree* BehaviourTree;
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
URandomWeaponParameters* RandomWeaponParameters;
|
||||
|
||||
|
@ -45,7 +44,6 @@ protected:
|
|||
virtual void BeginPlay() override;
|
||||
|
||||
private:
|
||||
|
||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||
|
||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||
|
|
|
@ -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()
|
||||
|
@ -33,25 +32,26 @@ void AExplosiveActor::Explode()
|
|||
|
||||
if (ExplosionParticleSystem)
|
||||
{
|
||||
UGameplayStatics::SpawnEmitterAtLocation(this,
|
||||
ExplosionParticleSystem,
|
||||
this->ActorToWorld().GetLocation(),
|
||||
FRotator::ZeroRotator,
|
||||
true);
|
||||
UGameplayStatics::SpawnEmitterAtLocation(this,
|
||||
ExplosionParticleSystem,
|
||||
this->ActorToWorld().GetLocation(),
|
||||
FRotator::ZeroRotator,
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
TArray<FOverlapResult> outOverlaps;
|
||||
GetWorld()->OverlapMultiByObjectType(outOverlaps,
|
||||
ActorToWorld().GetLocation(),
|
||||
FQuat::Identity,
|
||||
FCollisionObjectQueryParams::AllObjects,
|
||||
FCollisionShape::MakeSphere(ExplosionRadius));
|
||||
GetWorld()->OverlapMultiByObjectType(outOverlaps,
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@ UCLASS()
|
|||
class NAKATOMI_API AExplosiveActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
UStaticMeshComponent* StaticMeshComponent;
|
||||
|
||||
|
@ -35,12 +34,10 @@ protected:
|
|||
float MaxDamage = 150.f;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY(VisibleDefaultsOnly)
|
||||
UHealthComponent* HealthComponent = nullptr;
|
||||
|
||||
|
||||
public:
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AExplosiveActor();
|
||||
|
||||
|
@ -48,8 +45,7 @@ protected:
|
|||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
UFUNCTION()
|
||||
void Explode();
|
||||
};
|
||||
|
|
|
@ -22,11 +22,12 @@ EBTNodeResult::Type UGetDistanceToPlayerTask::ExecuteTask(UBehaviorTreeComponent
|
|||
auto blackboardComponent = owner.GetBlackboardComponent();
|
||||
auto playerCharacter = Cast<ANakatomiCharacter>(blackboardComponent->GetValueAsObject(TargetActor.SelectedKeyName));
|
||||
auto distance = FVector::Distance(enemyPawn->GetActorLocation(), playerCharacter->GetActorLocation());
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ struct FDamageInfo
|
|||
|
||||
UPROPERTY()
|
||||
float Damage;
|
||||
|
||||
|
||||
UPROPERTY()
|
||||
const class UDamageType* DamageType;
|
||||
|
||||
|
@ -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:
|
||||
|
||||
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;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,23 +7,22 @@
|
|||
#include "InteractableComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||
class NAKATOMI_API UInteractableComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UInteractableComponent();
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
||||
void Interact();
|
||||
|
||||
void Interact(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy, AActor* damageCauser);
|
||||
|
||||
public:
|
||||
void Interact();
|
||||
|
||||
void Interact(AActor* damagedActor, float damage, const UDamageType* damageType, AController* instigatedBy,
|
||||
AActor* damageCauser);
|
||||
};
|
||||
|
|
|
@ -7,17 +7,21 @@ public class Nakatomi : ModuleRules
|
|||
public Nakatomi(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine", "GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
PublicDependencyModuleNames.AddRange(new[]
|
||||
{
|
||||
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "FieldSystemEngine",
|
||||
"GeometryCollectionEngine", "UMG", "AIModule", "GameplayTasks", "NavigationSystem"
|
||||
});
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
|
|
|
@ -3,4 +3,3 @@
|
|||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
@ -16,7 +16,7 @@ ANakatomiCharacter::ANakatomiCharacter()
|
|||
void ANakatomiCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
|
||||
SetInventoryToDefault();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ void ANakatomiCharacter::BeginPlay()
|
|||
void ANakatomiCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -42,7 +40,7 @@ protected:
|
|||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
|
@ -82,7 +80,6 @@ public:
|
|||
virtual void OnFire();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void CalculateHits(TArray<FHitResult>* hits);
|
||||
|
||||
virtual void ProcessHits(TArray<FHitResult> hits);
|
||||
|
|
|
@ -14,17 +14,18 @@ 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);
|
||||
CullingField = CullingField->SetCullingField(RadialFalloff, RadialVector, Field_Culling_Outside);
|
||||
GetFieldSystemComponent()->ApplyPhysicsField(true, Field_LinearVelocity, nullptr, CullingField);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,8 @@ UCLASS()
|
|||
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;
|
||||
};
|
||||
|
|
|
@ -2,4 +2,3 @@
|
|||
|
||||
|
||||
#include "NakatomiGameModeBase.h"
|
||||
|
||||
|
|
|
@ -13,5 +13,4 @@ UCLASS()
|
|||
class NAKATOMI_API ANakatomiGameModeBase : public AGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
|
|
|
@ -15,5 +15,4 @@ class NAKATOMI_API ANakatomiPlayerController : public APlayerController
|
|||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
|
|
@ -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,12 +275,13 @@ 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)
|
||||
{
|
||||
field->Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Hit.GetActor())
|
||||
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -117,7 +114,7 @@ public:
|
|||
void SetWalkingCallback(const FInputActionInstance& Instance);
|
||||
|
||||
void WeaponSwitchingCallback(const FInputActionInstance& Instance);
|
||||
|
||||
|
||||
virtual void OnFire() override;
|
||||
|
||||
void WeaponCooldownHandler();
|
||||
|
@ -131,7 +128,6 @@ public:
|
|||
float GetCurrentHealthCount();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||
|
||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||
|
|
|
@ -13,8 +13,7 @@ UCLASS()
|
|||
class NAKATOMI_API UPlayerHealthComponent : public UHealthComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
};
|
||||
|
|
|
@ -14,6 +14,6 @@ void ARandomWeapon::BeginPlay()
|
|||
WeaponSkeletalMesh = RandomWeaponParameters->PickRandomMesh();
|
||||
FireSound = RandomWeaponParameters->PickRandomSoundBase();
|
||||
FieldSystemActor = RandomWeaponParameters->PickRandomFieldSystem();
|
||||
|
||||
|
||||
Super::BeginPlay();
|
||||
}
|
||||
|
|
|
@ -14,14 +14,12 @@ UCLASS()
|
|||
class NAKATOMI_API ARandomWeapon : public AWeapon
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, Category = "Random Weapon Parameters")
|
||||
URandomWeaponParameters* RandomWeaponParameters;
|
||||
|
||||
public:
|
||||
|
||||
ARandomWeapon();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -17,14 +17,14 @@ FWeaponProperties URandomWeaponParameters::GenerateRandomWeaponProperties()
|
|||
weaponProperties.ProjectilesPerShot = FMath::RandRange(ProjectilePerShotMin, ProjectilePerShotMax);
|
||||
weaponProperties.ProjectileRange = FMath::FRandRange(ProjectileRangeMin, ProjectileRangeMax);
|
||||
weaponProperties.WeaponSpread = FMath::FRandRange(WeaponSpreadMin, WeaponSpreadMax);
|
||||
|
||||
|
||||
if (IsAutomaticOverride)
|
||||
{
|
||||
weaponProperties.IsAutomatic = IsAutomaticOverride;
|
||||
}
|
||||
else
|
||||
{
|
||||
weaponProperties.IsAutomatic = bool(FMath::Rand() % 2);
|
||||
weaponProperties.IsAutomatic = static_cast<bool>(FMath::Rand() % 2);
|
||||
}
|
||||
|
||||
return weaponProperties;
|
||||
|
|
|
@ -18,54 +18,69 @@ 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")
|
||||
bool IsAutomaticOverride = false;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ EBTNodeResult::Type UTaskGetRandomLocation::ExecuteTask(UBehaviorTreeComponent&
|
|||
{
|
||||
FNavLocation navLocation;
|
||||
navigationSystem->GetRandomReachablePointInRadius(enemyPawn->GetActorLocation(), MaximumDistance, navLocation);
|
||||
|
||||
|
||||
blackboardComponent->SetValueAsVector(PatrolLocationKey.SelectedKeyName, navLocation.Location);
|
||||
return EBTNodeResult::Succeeded;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -24,9 +24,8 @@ UCLASS(Abstract, Blueprintable)
|
|||
class NAKATOMI_API AWeapon : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USkeletalMesh* WeaponSkeletalMesh = nullptr;
|
||||
|
||||
|
@ -48,7 +47,7 @@ protected:
|
|||
UPROPERTY(EditDefaultsOnly)
|
||||
TSubclassOf<class ANakatomiFieldSystemActor> FieldSystemActor;
|
||||
|
||||
public:
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AWeapon();
|
||||
|
||||
|
|
|
@ -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,17 +52,19 @@ 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);
|
||||
|
||||
|
||||
if (player && Weapon)
|
||||
{
|
||||
player->AddWeaponToInventory(Weapon);
|
||||
|
@ -76,7 +78,7 @@ void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AAc
|
|||
void AWeaponPickup::SetWeapon(TSubclassOf<class AWeapon> weapon)
|
||||
{
|
||||
Weapon = weapon;
|
||||
|
||||
|
||||
if (WeaponComponent)
|
||||
{
|
||||
WeaponComponent->Destroy();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ class NAKATOMI_API AWeaponPickup : public AActor
|
|||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<class AWeapon> Weapon;
|
||||
|
||||
|
@ -28,7 +27,7 @@ public:
|
|||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
float MovementSpeed = 1.0f;
|
||||
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
FRotator SpinRotation = FRotator(0.0, 1.0f, 0.0f);
|
||||
|
||||
|
@ -42,7 +41,6 @@ public:
|
|||
FColor LightColor = FColor::White;
|
||||
|
||||
private:
|
||||
|
||||
UPROPERTY()
|
||||
USphereComponent* SphereComponent;
|
||||
|
||||
|
@ -57,7 +55,7 @@ private:
|
|||
UPROPERTY()
|
||||
UPointLightComponent* PointLightComponent;
|
||||
|
||||
public:
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AWeaponPickup();
|
||||
|
||||
|
@ -65,12 +63,13 @@ protected:
|
|||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
public:
|
||||
// Called every frame
|
||||
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();
|
||||
};
|
||||
|
|
|
@ -40,4 +40,4 @@ struct FWeaponProperties
|
|||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties")
|
||||
bool IsAutomatic = true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
// 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;
|
||||
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
|
||||
ExtraModuleNames.Add("Nakatomi");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue