Skip to content

Commit

Permalink
#141 Added weapon spawner VFX
Browse files Browse the repository at this point in the history
  • Loading branch information
xthebat committed Jan 29, 2024
1 parent 899e344 commit 42f6c99
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 31 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Content/Maps/warmup.umap
Binary file not shown.
Binary file added Content/Vefects/VFX/Misc/E_RingGlow.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/Cloud9/Weapon/Utils/WeaponInitializerComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

struct FWeaponConfig;

// !DEPRECATED!

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class CLOUD9_API UWeaponInitializerComponent : public UChildActorComponent
{
Expand Down
65 changes: 36 additions & 29 deletions Source/Cloud9/Weapon/Utils/WeaponSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "Cloud9/Character/Cloud9Character.h"
#include "Cloud9/Weapon/Classes/Cloud9WeaponBase.h"
#include "Components/BillboardComponent.h"

FName AWeaponSpawner::RootComponentName = "RootComponent";
FName AWeaponSpawner::TriggerBoxComponentName = "TriggerBox";
Expand All @@ -30,26 +29,15 @@ AWeaponSpawner::AWeaponSpawner()
WeaponSampleComponent->SetupAttachment(RootComponent);
GlowingEffectComponent->SetupAttachment(RootComponent);

bIsDestroyOnActivation = false;
GlowingEffect = nullptr;
SampleScale = 1.0f;
bIsGlowingEffectPreview = true;
SampleScale = 1.5f;
RotationSpeedInDegree = 0.0f;
bIsRandomInitialRotation = false;
ZoneSize = {20.0f, 20.0f, 20.0f};

TriggerBoxComponent->OnComponentBeginOverlap.AddDynamic(this, &AWeaponSpawner::OnBeginOverlap);

#if WITH_EDITORONLY_DATA
// SpriteComponent = CreateEditorOnlyDefaultSubobject<UBillboardComponent>(SpriteComponentName);
// SpriteComponent->SetupAttachment(RootComponent);
//
// static ConstructorHelpers::FObjectFinderOptional<UTexture2D>
// TriggerTextureObject(TEXT("/Engine/EditorResources/S_Trigger"));
//
// SpriteComponent->Sprite = TriggerTextureObject.Get();
// SpriteComponent->SetRelativeScale3D(FVector(0.5f, 0.5f, 0.5f));
// SpriteComponent->bHiddenInGame = true;
// SpriteComponent->bIsScreenSizeScaled = true;
#endif
}

void AWeaponSpawner::OnConstruction(const FTransform& Transform)
Expand All @@ -58,7 +46,10 @@ void AWeaponSpawner::OnConstruction(const FTransform& Transform)

TriggerBoxComponent->SetBoxExtent(ZoneSize);

if (IsValid(GlowingEffect))
// Remove previous set glowing effect (required if preview disabled)
GlowingEffectComponent->SetAsset(nullptr);

if (IsValid(GlowingEffect) and bIsGlowingEffectPreview)
{
GlowingEffectComponent->SetAsset(GlowingEffect);
}
Expand All @@ -77,7 +68,6 @@ void AWeaponSpawner::OnConstruction(const FTransform& Transform)

if (not WeaponConfig.Initialize(WeaponSample))
{
// WeaponSampleComponent->DestroyChildActor();
SetActorTickEnabled(false);
return;
}
Expand All @@ -91,6 +81,27 @@ void AWeaponSpawner::OnConstruction(const FTransform& Transform)
WeaponSample->UpdateComponentTransforms();
WeaponSample->SetActorEnableCollision(false);
WeaponSample->SetActorScale3D({SampleScale, SampleScale, SampleScale});
}
}

void AWeaponSpawner::BeginPlay()
{
Super::BeginPlay();

if (IsValid(WeaponConfig))
{
if (IsValid(GlowingEffect) and not bIsGlowingEffectPreview)
{
GlowingEffectComponent->SetAsset(GlowingEffect);
}

let WeaponSample = WeaponSampleComponent->GetChildActor();

if (not IsValid(WeaponSample))
{
log(Error, "WeaponSampleComponent child actor is invalid");
return;
}

if (bIsRandomInitialRotation)
{
Expand All @@ -101,28 +112,23 @@ void AWeaponSpawner::OnConstruction(const FTransform& Transform)
}
}

void AWeaponSpawner::BeginPlay()
{
Super::BeginPlay();
}

void AWeaponSpawner::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

if (IsValid(WeaponConfig))
{
let Actor = WeaponSampleComponent->GetChildActor();
let WeaponSample = WeaponSampleComponent->GetChildActor();

if (not IsValid(Actor))
if (not IsValid(WeaponSample))
{
log(Error, "WeaponSampleComponent child actor is invalid");
return;
}

var Rotation = Actor->GetActorRotation();
var Rotation = WeaponSample->GetActorRotation();
Rotation.Yaw += DeltaTime * RotationSpeedInDegree;
Actor->SetActorRotation(Rotation);
WeaponSample->SetActorRotation(Rotation);
}
}

Expand All @@ -144,8 +150,9 @@ void AWeaponSpawner::OnBeginOverlap(
return;
}

Inventory->AddWeapon(WeaponConfig, true, true);
if (Inventory->AddWeapon(WeaponConfig, true, true) and bIsDestroyOnActivation)
{
Destroy();
}
}
}

void AWeaponSpawner::Initialize() {}
8 changes: 6 additions & 2 deletions Source/Cloud9/Weapon/Utils/WeaponSpawner.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class CLOUD9_API AWeaponSpawner : public AActor
bool bFromSweep,
const FHitResult& Hit);

void Initialize();

protected:
UPROPERTY(BlueprintReadOnly, Category=Implementation)
UBoxComponent* TriggerBoxComponent;
Expand All @@ -57,9 +55,15 @@ class CLOUD9_API AWeaponSpawner : public AActor
UPROPERTY(EditAnywhere, Category=Config)
FWeaponConfig WeaponConfig;

UPROPERTY(EditAnywhere, Category=Config)
bool bIsDestroyOnActivation;

UPROPERTY(EditAnywhere, Category=Glowing)
UNiagaraSystem* GlowingEffect;

UPROPERTY(EditAnywhere, Category=Glowing)
bool bIsGlowingEffectPreview;

UPROPERTY(EditAnywhere, Category=WeaponSample)
float SampleScale;

Expand Down

0 comments on commit 42f6c99

Please sign in to comment.