Apply Rider cleanup
This commit is contained in:
parent
9bd298bd6e
commit
b5088f3bae
|
@ -1,11 +1,10 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
using UnrealBuildTool;
|
using UnrealBuildTool;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public class NakatomiTarget : TargetRules
|
public class NakatomiTarget : TargetRules
|
||||||
{
|
{
|
||||||
public NakatomiTarget( TargetInfo Target) : base(Target)
|
public NakatomiTarget(TargetInfo Target) : base(Target)
|
||||||
{
|
{
|
||||||
Type = TargetType.Game;
|
Type = TargetType.Game;
|
||||||
DefaultBuildSettings = BuildSettingsVersion.V2;
|
DefaultBuildSettings = BuildSettingsVersion.V2;
|
||||||
|
|
|
@ -31,7 +31,8 @@ void ADemolitionCharacter::Explode()
|
||||||
{
|
{
|
||||||
if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>())
|
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);
|
float scale = 1.f - (distance / ExplosionRadius);
|
||||||
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
|
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@ protected:
|
||||||
float MaxDamage = 150.f;
|
float MaxDamage = 150.f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void Explode();
|
void Explode();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,5 @@ protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Destruct();
|
void Destruct();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,7 +72,7 @@ void AEnemyAIController::OnDeath(FDamageInfo info)
|
||||||
|
|
||||||
enemy->DetachFromControllerPendingDestroy();
|
enemy->DetachFromControllerPendingDestroy();
|
||||||
enemy->GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
enemy->GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||||
enemy->GetCapsuleComponent()->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
|
enemy->GetCapsuleComponent()->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||||
|
|
||||||
enemy->GetMesh()->SetCollisionProfileName("Ragdoll");
|
enemy->GetMesh()->SetCollisionProfileName("Ragdoll");
|
||||||
enemy->SetActorEnableCollision(true);
|
enemy->SetActorEnableCollision(true);
|
||||||
|
|
|
@ -21,7 +21,6 @@ class NAKATOMI_API AEnemyAIController : public AAIController
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UBlackboardComponent* Blackboard;
|
UBlackboardComponent* Blackboard;
|
||||||
|
|
||||||
UBehaviorTreeComponent* BehaviorTree;
|
UBehaviorTreeComponent* BehaviorTree;
|
||||||
|
|
|
@ -40,7 +40,7 @@ UAIPerceptionComponent* AEnemyCharacter::GetPerceptionComponent()
|
||||||
|
|
||||||
void AEnemyCharacter::OnFire()
|
void AEnemyCharacter::OnFire()
|
||||||
{
|
{
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Firing);
|
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
||||||
|
|
||||||
TArray<FHitResult> Hits = TArray<FHitResult>();
|
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||||
CalculateHits(&Hits);
|
CalculateHits(&Hits);
|
||||||
|
@ -50,7 +50,7 @@ void AEnemyCharacter::OnFire()
|
||||||
|
|
||||||
// TODO: Play some animation here
|
// TODO: Play some animation here
|
||||||
|
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
|
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEnemyCharacter::BeginPlay()
|
void AEnemyCharacter::BeginPlay()
|
||||||
|
@ -84,7 +84,8 @@ void AEnemyCharacter::CalculateHits(TArray<FHitResult>* hits)
|
||||||
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
|
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
|
||||||
{
|
{
|
||||||
// Calculate the maximum distance the weapon can fire
|
// 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);
|
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
|
||||||
|
|
||||||
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
|
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
|
||||||
|
@ -108,7 +109,8 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
// Spawn field actor
|
// Spawn field actor
|
||||||
FTransform transform;
|
FTransform transform;
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
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())
|
if (Hit.GetActor())
|
||||||
{
|
{
|
||||||
|
@ -119,7 +121,8 @@ void AEnemyCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
|
|
||||||
if (auto healthComponent = Hit.GetActor()->GetComponentByClass<UHealthComponent>())
|
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()
|
GENERATED_BODY()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
||||||
UAIPerceptionComponent* PerceptionComponent;
|
UAIPerceptionComponent* PerceptionComponent;
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||||
|
|
|
@ -22,7 +22,6 @@ AExplosiveActor::AExplosiveActor()
|
||||||
void AExplosiveActor::BeginPlay()
|
void AExplosiveActor::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExplosiveActor::Explode()
|
void AExplosiveActor::Explode()
|
||||||
|
@ -51,7 +50,8 @@ void AExplosiveActor::Explode()
|
||||||
{
|
{
|
||||||
if (auto healthComponent = Overlaps.GetActor()->GetComponentByClass<UHealthComponent>())
|
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);
|
float scale = 1.f - (distance / ExplosionRadius);
|
||||||
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
|
healthComponent->TakeDamage(Overlaps.GetActor(), scale * MaxDamage, nullptr, nullptr, this);
|
||||||
}
|
}
|
||||||
|
@ -71,4 +71,3 @@ void AExplosiveActor::Explode()
|
||||||
|
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ class NAKATOMI_API AExplosiveActor : public AActor
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
UStaticMeshComponent* StaticMeshComponent;
|
UStaticMeshComponent* StaticMeshComponent;
|
||||||
|
|
||||||
|
@ -35,11 +34,9 @@ protected:
|
||||||
float MaxDamage = 150.f;
|
float MaxDamage = 150.f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(VisibleDefaultsOnly)
|
UPROPERTY(VisibleDefaultsOnly)
|
||||||
UHealthComponent* HealthComponent = nullptr;
|
UHealthComponent* HealthComponent = nullptr;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets default values for this actor's properties
|
// Sets default values for this actor's properties
|
||||||
AExplosiveActor();
|
AExplosiveActor();
|
||||||
|
@ -49,7 +46,6 @@ protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void Explode();
|
void Explode();
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,8 @@ EBTNodeResult::Type UGetDistanceToPlayerTask::ExecuteTask(UBehaviorTreeComponent
|
||||||
if (distance < DistanceThreshold)
|
if (distance < DistanceThreshold)
|
||||||
{
|
{
|
||||||
enemyPawn->Explode();
|
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;
|
return EBTNodeResult::Succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ UCLASS()
|
||||||
class NAKATOMI_API UGetDistanceToPlayerTask : public UBTTaskNode
|
class NAKATOMI_API UGetDistanceToPlayerTask : public UBTTaskNode
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
UBehaviorTreeComponent* behaviourTreeOwner = nullptr;
|
UBehaviorTreeComponent* behaviourTreeOwner = nullptr;
|
||||||
|
|
||||||
|
@ -25,12 +25,9 @@ private:
|
||||||
float DistanceThreshold = 5.0f;
|
float DistanceThreshold = 5.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UGetDistanceToPlayerTask();
|
UGetDistanceToPlayerTask();
|
||||||
|
|
||||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||||
|
|
||||||
virtual EBTNodeResult::Type AbortTask(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)
|
if (damagedActor == nullptr || IsDead || !CanDamage)
|
||||||
{
|
{
|
||||||
|
@ -22,12 +23,12 @@ void UHealthComponent::TakeDamage(AActor* damagedActor, float damage, const UDam
|
||||||
|
|
||||||
CurrentHealth -= damage;
|
CurrentHealth -= damage;
|
||||||
|
|
||||||
OnDamaged.ExecuteIfBound({ damagedActor, damage, damageType, instigatedBy, damageCauser });
|
OnDamaged.ExecuteIfBound({damagedActor, damage, damageType, instigatedBy, damageCauser});
|
||||||
|
|
||||||
if (CurrentHealth <= 0.0f)
|
if (CurrentHealth <= 0.0f)
|
||||||
{
|
{
|
||||||
IsDead = true;
|
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();
|
Super::BeginPlay();
|
||||||
|
|
||||||
ResetHealth();
|
ResetHealth();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,18 +30,16 @@ struct FDamageInfo
|
||||||
DECLARE_DELEGATE_OneParam(FOnDamageDelegate, FDamageInfo)
|
DECLARE_DELEGATE_OneParam(FOnDamageDelegate, FDamageInfo)
|
||||||
DECLARE_DELEGATE_OneParam(FOnDeathDelegate, FDamageInfo)
|
DECLARE_DELEGATE_OneParam(FOnDeathDelegate, FDamageInfo)
|
||||||
|
|
||||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class NAKATOMI_API UHealthComponent : public UActorComponent
|
class NAKATOMI_API UHealthComponent : public UActorComponent
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FOnDamageDelegate OnDamaged;
|
FOnDamageDelegate OnDamaged;
|
||||||
FOnDeathDelegate OnDeath;
|
FOnDeathDelegate OnDeath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float MaxHealth = 100.f;
|
float MaxHealth = 100.f;
|
||||||
|
|
||||||
|
@ -53,12 +51,12 @@ private:
|
||||||
bool CanDamage = true;
|
bool CanDamage = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Sets default values for this component's properties
|
// Sets default values for this component's properties
|
||||||
UHealthComponent();
|
UHealthComponent();
|
||||||
|
|
||||||
UFUNCTION()
|
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()
|
UFUNCTION()
|
||||||
void IncrementHealth(float value);
|
void IncrementHealth(float value);
|
||||||
|
@ -96,6 +94,4 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
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,7 +7,7 @@
|
||||||
#include "InteractableComponent.generated.h"
|
#include "InteractableComponent.generated.h"
|
||||||
|
|
||||||
|
|
||||||
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class NAKATOMI_API UInteractableComponent : public UActorComponent
|
class NAKATOMI_API UInteractableComponent : public UActorComponent
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
@ -21,9 +21,8 @@ protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Interact();
|
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);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,11 @@ public class Nakatomi : ModuleRules
|
||||||
{
|
{
|
||||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
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[] { });
|
||||||
|
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
#include "Nakatomi.h"
|
#include "Nakatomi.h"
|
||||||
#include "Modules/ModuleManager.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
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ void ANakatomiCharacter::BeginPlay()
|
||||||
void ANakatomiCharacter::Tick(float DeltaTime)
|
void ANakatomiCharacter::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to bind functionality to input
|
// Called to bind functionality to input
|
||||||
|
|
|
@ -17,7 +17,6 @@ class NAKATOMI_API ANakatomiCharacter : public ACharacter
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TArray<TSubclassOf<class AWeapon>> DefaultWeaponInventory;
|
TArray<TSubclassOf<class AWeapon>> DefaultWeaponInventory;
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ public:
|
||||||
AWeapon* CurrentWeapon = nullptr;
|
AWeapon* CurrentWeapon = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(VisibleDefaultsOnly)
|
UPROPERTY(VisibleDefaultsOnly)
|
||||||
UHealthComponent* HealthComponent = nullptr;
|
UHealthComponent* HealthComponent = nullptr;
|
||||||
|
|
||||||
|
@ -82,7 +80,6 @@ public:
|
||||||
virtual void OnFire();
|
virtual void OnFire();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits);
|
virtual void CalculateHits(TArray<FHitResult>* hits);
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits);
|
virtual void ProcessHits(TArray<FHitResult> hits);
|
||||||
|
|
|
@ -14,14 +14,15 @@ ANakatomiFieldSystemActor::ANakatomiFieldSystemActor()
|
||||||
RadialVector = CreateDefaultSubobject<URadialVector>(TEXT("Radial Vector"));
|
RadialVector = CreateDefaultSubobject<URadialVector>(TEXT("Radial Vector"));
|
||||||
CullingField = CreateDefaultSubobject<UCullingField>(TEXT("Culling Field"));
|
CullingField = CreateDefaultSubobject<UCullingField>(TEXT("Culling Field"));
|
||||||
|
|
||||||
SphereComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
|
SphereComponent->SetCollisionResponseToAllChannels(ECR_Overlap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ANakatomiFieldSystemActor::BeginPlay()
|
void ANakatomiFieldSystemActor::BeginPlay()
|
||||||
{
|
{
|
||||||
Radius = SphereComponent->GetScaledSphereRadius();
|
Radius = SphereComponent->GetScaledSphereRadius();
|
||||||
Position = GetActorLocation();
|
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);
|
GetFieldSystemComponent()->ApplyPhysicsField(true, Field_ExternalClusterStrain, nullptr, RadialFalloff);
|
||||||
|
|
||||||
RadialVector = RadialVector->SetRadialVector(ForceMagnitude, Position);
|
RadialVector = RadialVector->SetRadialVector(ForceMagnitude, Position);
|
||||||
|
|
|
@ -16,9 +16,7 @@ class NAKATOMI_API ANakatomiFieldSystemActor : public AFieldSystemActor
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
USphereComponent* SphereComponent;
|
USphereComponent* SphereComponent;
|
||||||
|
|
||||||
|
@ -50,11 +48,9 @@ private:
|
||||||
FVector Position = FVector::ZeroVector;
|
FVector Position = FVector::ZeroVector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ANakatomiFieldSystemActor();
|
ANakatomiFieldSystemActor();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,4 +2,3 @@
|
||||||
|
|
||||||
|
|
||||||
#include "NakatomiGameModeBase.h"
|
#include "NakatomiGameModeBase.h"
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,4 @@ UCLASS()
|
||||||
class NAKATOMI_API ANakatomiGameModeBase : public AGameModeBase
|
class NAKATOMI_API ANakatomiGameModeBase : public AGameModeBase
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,5 +15,4 @@ class NAKATOMI_API ANakatomiPlayerController : public APlayerController
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,13 +33,13 @@ APlayerCharacter::APlayerCharacter()
|
||||||
CameraBoom->TargetArmLength = 350.0f;
|
CameraBoom->TargetArmLength = 350.0f;
|
||||||
CameraBoom->bEnableCameraLag = true;
|
CameraBoom->bEnableCameraLag = true;
|
||||||
CameraBoom->CameraLagSpeed = 10.0f;
|
CameraBoom->CameraLagSpeed = 10.0f;
|
||||||
CameraBoom->SocketOffset = { 0.0f, 75.0f, 110.0f };
|
CameraBoom->SocketOffset = {0.0f, 75.0f, 110.0f};
|
||||||
|
|
||||||
// Setup the camera component
|
// Setup the camera component
|
||||||
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
|
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
|
||||||
CameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
|
CameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
|
||||||
CameraComponent->bUsePawnControlRotation = false;
|
CameraComponent->bUsePawnControlRotation = false;
|
||||||
CameraComponent->SetRelativeRotation({ -5.0f,0.0f,0.0f });
|
CameraComponent->SetRelativeRotation({-5.0f, 0.0f, 0.0f});
|
||||||
|
|
||||||
// Setup the character movement
|
// Setup the character movement
|
||||||
UCharacterMovementComponent* CharacterMovementComponent = GetCharacterMovement();
|
UCharacterMovementComponent* CharacterMovementComponent = GetCharacterMovement();
|
||||||
|
@ -89,7 +89,8 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||||
|
|
||||||
if (APlayerController* PC = Cast<APlayerController>(GetController()))
|
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())
|
if (!InputMappingContext.IsNull())
|
||||||
{
|
{
|
||||||
|
@ -134,7 +135,8 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||||
|
|
||||||
if (WeaponSwitchingAction)
|
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)
|
void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
|
||||||
{
|
{
|
||||||
if (CurrentWeapon == nullptr || CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != WeaponState::Idle)
|
if (CurrentWeapon == nullptr || CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != Idle)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -184,12 +186,15 @@ void APlayerCharacter::BeginFireCallback(const FInputActionInstance& Instance)
|
||||||
|
|
||||||
if (CurrentWeapon->GetWeaponProperties()->IsAutomatic)
|
if (CurrentWeapon->GetWeaponProperties()->IsAutomatic)
|
||||||
{
|
{
|
||||||
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler, CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
|
GetWorldTimerManager().SetTimer(CooldownTimerHandle, this, &APlayerCharacter::WeaponCooldownHandler,
|
||||||
GetWorldTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire, CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
|
CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
|
||||||
|
GetWorldTimerManager().SetTimer(FireTimerHandle, this, &APlayerCharacter::OnFire,
|
||||||
|
CurrentWeapon->GetWeaponProperties()->WeaponCooldown, true);
|
||||||
}
|
}
|
||||||
else
|
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++)
|
for (size_t i = 0; i < CurrentWeapon->GetWeaponProperties()->ProjectilesPerShot; i++)
|
||||||
{
|
{
|
||||||
// Calculate the maximum distance the weapon can fire
|
// 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);
|
FVector MaxHitLoc = TraceStart + (ShootDir * Range);
|
||||||
|
|
||||||
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
|
GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, MaxHitLoc, COLLISION_WEAPON, TraceParams);
|
||||||
|
@ -269,7 +275,8 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
{
|
{
|
||||||
FTransform transform;
|
FTransform transform;
|
||||||
transform.SetLocation(Hit.ImpactPoint);
|
transform.SetLocation(Hit.ImpactPoint);
|
||||||
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform, SpawnParameters);
|
auto field = GetWorld()->SpawnActor<AFieldSystemActor>(CurrentWeapon->GetFieldSystemActor(), transform,
|
||||||
|
SpawnParameters);
|
||||||
|
|
||||||
if (field)
|
if (field)
|
||||||
{
|
{
|
||||||
|
@ -286,7 +293,8 @@ void APlayerCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||||
|
|
||||||
if (auto healthComponent = Hit.GetActor()->GetComponentByClass<UHealthComponent>())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Firing);
|
CurrentWeapon->SetCurrentWeaponStatus(Firing);
|
||||||
|
|
||||||
TArray<FHitResult> Hits = TArray<FHitResult>();
|
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||||
CalculateHits(&Hits);
|
CalculateHits(&Hits);
|
||||||
|
@ -325,7 +333,7 @@ void APlayerCharacter::OnFire()
|
||||||
|
|
||||||
// TODO: Play some animation here
|
// TODO: Play some animation here
|
||||||
|
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Cooldown);
|
CurrentWeapon->SetCurrentWeaponStatus(Cooldown);
|
||||||
|
|
||||||
if (CurrentWeapon->GetAmmoCount() == 0)
|
if (CurrentWeapon->GetAmmoCount() == 0)
|
||||||
{
|
{
|
||||||
|
@ -335,9 +343,9 @@ void APlayerCharacter::OnFire()
|
||||||
|
|
||||||
void APlayerCharacter::WeaponCooldownHandler()
|
void APlayerCharacter::WeaponCooldownHandler()
|
||||||
{
|
{
|
||||||
if (CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != WeaponState::Idle)
|
if (CurrentWeapon->GetCurrentWeaponStatus()->GetValue() != Idle)
|
||||||
{
|
{
|
||||||
CurrentWeapon->SetCurrentWeaponStatus(WeaponState::Idle);
|
CurrentWeapon->SetCurrentWeaponStatus(Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsFiring)
|
if (!IsFiring)
|
||||||
|
|
|
@ -28,7 +28,6 @@ class NAKATOMI_API APlayerCharacter : public ANakatomiCharacter
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
UInputAction* MovementAction;
|
UInputAction* MovementAction;
|
||||||
|
|
||||||
|
@ -60,12 +59,10 @@ public:
|
||||||
TSubclassOf<class UUserWidget> PlayerHUD;
|
TSubclassOf<class UUserWidget> PlayerHUD;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
float SprintSpeedMultiplier = 2.0f;
|
float SprintSpeedMultiplier = 2.0f;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
|
||||||
USpringArmComponent* CameraBoom = nullptr;
|
USpringArmComponent* CameraBoom = nullptr;
|
||||||
|
|
||||||
|
@ -131,7 +128,6 @@ public:
|
||||||
float GetCurrentHealthCount();
|
float GetCurrentHealthCount();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||||
|
|
||||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||||
|
|
|
@ -16,5 +16,4 @@ class NAKATOMI_API UPlayerHealthComponent : public UHealthComponent
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,12 +16,10 @@ class NAKATOMI_API ARandomWeapon : public AWeapon
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, Category = "Random Weapon Parameters")
|
UPROPERTY(VisibleAnywhere, Category = "Random Weapon Parameters")
|
||||||
URandomWeaponParameters* RandomWeaponParameters;
|
URandomWeaponParameters* RandomWeaponParameters;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ARandomWeapon();
|
ARandomWeapon();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -24,7 +24,7 @@ FWeaponProperties URandomWeaponParameters::GenerateRandomWeaponProperties()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
weaponProperties.IsAutomatic = bool(FMath::Rand() % 2);
|
weaponProperties.IsAutomatic = static_cast<bool>(FMath::Rand() % 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return weaponProperties;
|
return weaponProperties;
|
||||||
|
|
|
@ -18,52 +18,67 @@ class NAKATOMI_API URandomWeaponParameters : public UActorComponent
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
int DefaultAmmoMin = 4;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Default Ammo", DisplayName = "Max")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Default Ammo", DisplayName = "Max")
|
||||||
int DefaultAmmoMax = 200;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
float WeaponSpreadMax = 15.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Is Automatic")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Weapon Parameters|Is Automatic")
|
||||||
|
|
|
@ -15,9 +15,9 @@ class NAKATOMI_API UTaskFireWeapon : public UBTTaskNode
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
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;
|
FBlackboardKeySelector TargetActor;
|
||||||
|
|
||||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,15 +13,16 @@ UCLASS()
|
||||||
class NAKATOMI_API UTaskGetRandomLocation : public UBTTaskNode
|
class NAKATOMI_API UTaskGetRandomLocation : public UBTTaskNode
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
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;
|
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;
|
float MaximumDistance = 500.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// Sets default values
|
// Sets default values
|
||||||
AWeapon::AWeapon()
|
AWeapon::AWeapon()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
|
@ -16,7 +15,6 @@ void AWeapon::BeginPlay()
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
SetAmmoCountToDefault();
|
SetAmmoCountToDefault();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
USkeletalMesh* AWeapon::GetSkeletalMesh()
|
USkeletalMesh* AWeapon::GetSkeletalMesh()
|
||||||
|
|
|
@ -26,7 +26,6 @@ class NAKATOMI_API AWeapon : public AActor
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
USkeletalMesh* WeaponSkeletalMesh = nullptr;
|
USkeletalMesh* WeaponSkeletalMesh = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,15 @@ void AWeaponPickup::Tick(float DeltaTime)
|
||||||
WeaponComponent->SetActorLocation(WeaponStartingLocation + ((MovementDirection * Sine) * MovementDistance));
|
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)));
|
float sin = FMath::Abs(FMath::Sin(GetWorld()->GetRealTimeSeconds() * (MovementSpeed / 2)));
|
||||||
PointLightComponent->SetLightBrightness(sin * MaxLightBrightness);
|
PointLightComponent->SetLightBrightness(sin * MaxLightBrightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AWeaponPickup::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
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
|
// TODO: Add extra checking here
|
||||||
auto player = Cast<APlayerCharacter>(OtherActor);
|
auto player = Cast<APlayerCharacter>(OtherActor);
|
||||||
|
@ -100,7 +102,8 @@ void AWeaponPickup::SpawnWeapon()
|
||||||
FActorSpawnParameters SpawnParameters;
|
FActorSpawnParameters SpawnParameters;
|
||||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
WeaponComponent = GetWorld()->SpawnActor<AWeapon>(Weapon, SpawnParameters);
|
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->AttachToComponent(RootComponent, TransformRules);
|
||||||
WeaponComponent->SetActorRelativeLocation(FVector(0.0f, 0.0f, 5.0f));
|
WeaponComponent->SetActorRelativeLocation(FVector(0.0f, 0.0f, 5.0f));
|
||||||
WeaponComponent->SetActorEnableCollision(false);
|
WeaponComponent->SetActorEnableCollision(false);
|
||||||
|
@ -108,4 +111,3 @@ void AWeaponPickup::SpawnWeapon()
|
||||||
WeaponStartingLocation = WeaponComponent->GetActorLocation();
|
WeaponStartingLocation = WeaponComponent->GetActorLocation();
|
||||||
WeaponStartingLocation += ((MovementDirection * MovementDistance) / 2);
|
WeaponStartingLocation += ((MovementDirection * MovementDistance) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ class NAKATOMI_API AWeaponPickup : public AActor
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||||
TSubclassOf<class AWeapon> Weapon;
|
TSubclassOf<class AWeapon> Weapon;
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ public:
|
||||||
FColor LightColor = FColor::White;
|
FColor LightColor = FColor::White;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
USphereComponent* SphereComponent;
|
USphereComponent* SphereComponent;
|
||||||
|
|
||||||
|
@ -70,7 +68,8 @@ public:
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
UFUNCTION()
|
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);
|
void SetWeapon(TSubclassOf<class AWeapon> weapon);
|
||||||
|
|
||||||
|
@ -79,6 +78,5 @@ public:
|
||||||
void SetWeaponProperties(FWeaponProperties FWeaponProperties);
|
void SetWeaponProperties(FWeaponProperties FWeaponProperties);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void SpawnWeapon();
|
void SpawnWeapon();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
using UnrealBuildTool;
|
using UnrealBuildTool;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public class NakatomiEditorTarget : TargetRules
|
public class NakatomiEditorTarget : TargetRules
|
||||||
{
|
{
|
||||||
public NakatomiEditorTarget( TargetInfo Target) : base(Target)
|
public NakatomiEditorTarget(TargetInfo Target) : base(Target)
|
||||||
{
|
{
|
||||||
Type = TargetType.Editor;
|
Type = TargetType.Editor;
|
||||||
DefaultBuildSettings = BuildSettingsVersion.V2;
|
DefaultBuildSettings = BuildSettingsVersion.V2;
|
||||||
|
|
Loading…
Reference in New Issue