Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed practice range and added spawner on dust #242

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Content/Environment/BP_Cloud9PracticeRangeBase.uasset
Binary file not shown.
Binary file modified Content/Environment/BP_ShootingRangeStats.uasset
Binary file not shown.
Binary file modified Content/Environment/Ball/BP_Cloud9PracticeRangeBalls.uasset
Binary file not shown.
Binary file modified Content/Environment/Bots/BP_Cloud9PracticeRangeBots.uasset
Binary file not shown.
Binary file modified Content/Maps/de_shortdust.umap
Binary file not shown.
Binary file modified Content/Maps/warmup.umap
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/Emitters/E_RingGlow.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow_Armor.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow_GrenadeWeapon.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow_OneTimePrimaryWeapon.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow_PrimaryWeapon.uasset
Binary file not shown.
Binary file modified Content/Vefects/VFX/Misc/NS_RingGlow_SecondaryWeapon.uasset
Binary file not shown.
11 changes: 11 additions & 0 deletions Source/Cloud9/Character/Cloud9Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
#include "Cloud9/Tools/Extensions/AActor.h"
#include "Components/Cloud9HealthComponent.h"
#include "Components/Cloud9AnimationComponent.h"
#include "Components/WidgetInteractionComponent.h"

const FName ACloud9Character::SpringArmComponentName = TEXT("CameraBoom");
const FName ACloud9Character::CameraComponentName = TEXT("TopDownCamera");
const FName ACloud9Character::DecalComponentName = TEXT("CursorToWorld");
const FName ACloud9Character::InventoryComponentName = TEXT("InventoryComponent");
const FName ACloud9Character::HealthComponentName = TEXT("HealthComponent");
const FName ACloud9Character::AnimationComponentName = TEXT("AnimationComponent");
const FName ACloud9Character::WidgetInteractionComponentName = TEXT("WidgetInteractionComponent");

ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer) : Super(
ObjectInitializer.SetDefaultSubobjectClass<UCloud9CharacterMovement>(CharacterMovementComponentName))
Expand Down Expand Up @@ -108,6 +110,10 @@ ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer)
InventoryComponent = CreateDefaultSubobject<UCloud9InventoryComponent>(InventoryComponentName);
HealthComponent = CreateDefaultSubobject<UCloud9HealthComponent>(HealthComponentName);
AnimationComponent = CreateDefaultSubobject<UCloud9AnimationComponent>(AnimationComponentName);
WidgetInteractionComponent = CreateDefaultSubobject<UWidgetInteractionComponent>(WidgetInteractionComponentName);
WidgetInteractionComponent->SetupAttachment(RootComponent);
WidgetInteractionComponent->InteractionSource = EWidgetInteractionSource::Custom;
WidgetInteractionComponent->bShowDebug = false;

HealthComponent->OnCharacterDie.AddDynamic(this, &ACloud9Character::OnCharacterDie);

Expand Down Expand Up @@ -225,6 +231,11 @@ void ACloud9Character::SetDestroyAfter(float NewTime)
DestroyAfterTime = NewTime;
}

UWidgetInteractionComponent* ACloud9Character::GetWidgetInteractionComponent() const
{
return WidgetInteractionComponent;
}

void ACloud9Character::SetCameraRotationYaw(float Angle) const
{
var Rotation = CameraBoom->GetRelativeRotation();
Expand Down
8 changes: 8 additions & 0 deletions Source/Cloud9/Character/Cloud9Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "Cloud9Character.generated.h"

class UWidgetInteractionComponent;
class ACloud9PlayerController;
class UCloud9InventoryComponent;
class UCloud9AnimationComponent;
Expand All @@ -50,6 +51,7 @@ class ACloud9Character : public ACharacter
static const FName InventoryComponentName;
static const FName HealthComponentName;
static const FName AnimationComponentName;
static const FName WidgetInteractionComponentName;

ACloud9Character(const FObjectInitializer& ObjectInitializer);

Expand Down Expand Up @@ -80,6 +82,8 @@ class ACloud9Character : public ACharacter
UFUNCTION(BlueprintCallable)
float GetViewVerticalRotation() const { return ViewVerticalRotation; }

UWidgetInteractionComponent* GetWidgetInteractionComponent() const;

void SetCameraRotationYaw(float Angle) const;
void AddCameraRotationYaw(float Angle) const;
float GetCameraRotationRoll() const;
Expand Down Expand Up @@ -177,6 +181,10 @@ class ACloud9Character : public ACharacter
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Utility, meta=(AllowPrivateAccess))
UCloud9AnimationComponent* AnimationComponent;

/** Helper to play animation montages for character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Utility, meta=(AllowPrivateAccess))
UWidgetInteractionComponent* WidgetInteractionComponent;

/** Current number of frags made by character */
UPROPERTY(BlueprintReadOnly, Category=State, meta=(AllowPrivateAccess))
int Score;
Expand Down
28 changes: 20 additions & 8 deletions Source/Cloud9/Environment/Cloud9PracticeSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ FName ACloud9PracticeSpawner::ZoneComponentName = "ZoneComponentName";
ACloud9PracticeSpawner::ACloud9PracticeSpawner()
{
// Disable collision to remove firearms hit screen
SetActorEnableCollision(false);
// SetActorEnableCollision(false);
PrimaryActorTick.bCanEverTick = true;
ZoneComponent = CreateDefaultSubobject<UBoxComponent>(ZoneComponentName);
RootComponent = ZoneComponent;
ZoneSize = {100.0f, 100.0f, 100.0f};
ZoneComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
MaxTargetsCount = 10;
GridSize = FVector::OneVector;
bIsEnabled = true;
Expand All @@ -37,11 +38,16 @@ float ACloud9PracticeSpawner::GetKillPerMinute() const

void ACloud9PracticeSpawner::RestartShooting()
{
for (let Actor : Actors)
{
Actor->OnDestroyed.RemoveAll(this);
Actor->Destroy();
}
Actors.Reset();
AddPracticeTargets();
bIsStarted = false;
Killed = 0;
TimeElapsed = 0.0f;
Actors.Empty();
AddPracticeTargets();
OnRestartShooting.Broadcast();
}

Expand Down Expand Up @@ -84,10 +90,13 @@ void ACloud9PracticeSpawner::Tick(float DeltaTime)

void ACloud9PracticeSpawner::OnChildActorDestroyed(AActor* DestroyedActor)
{
bIsStarted = true;
OnTargetDestroyed.Broadcast(++Killed);
Actors.Remove(DestroyedActor);
AddPracticeTargets();
if (bIsEnabled)
{
bIsStarted = true;
OnTargetDestroyed.Broadcast(++Killed);
Actors.Remove(DestroyedActor);
AddPracticeTargets();
}
}

AActor* ACloud9PracticeSpawner::SpawnTarget_Implementation(FVector Location)
Expand All @@ -100,7 +109,10 @@ AActor* ACloud9PracticeSpawner::SpawnTarget_Implementation(FVector Location)
return nullptr;
}

return GetWorld()->SpawnActor(Template, &Location, nullptr);
FActorSpawnParameters ActorSpawnParameters;
ActorSpawnParameters.Owner = this;

return GetWorld()->SpawnActor(Template, &Location, nullptr, ActorSpawnParameters);
}

bool ACloud9PracticeSpawner::AddPracticeTargets()
Expand Down
12 changes: 11 additions & 1 deletion Source/Cloud9/Weapon/Classes/Cloud9WeaponFirearm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "Cloud9WeaponFirearm.h"
#include "Engine/StaticMeshActor.h"
#include "NiagaraFunctionLibrary.h"
#include "Components/WidgetInteractionComponent.h"

#include "Cloud9/Tools/Macro/Common.h"
#include "Cloud9/Tools/Macro/Logging.h"
Expand All @@ -41,8 +42,8 @@
#include "Cloud9/Weapon/Sounds/Cloud9SoundPlayer.h"
#include "Cloud9/Weapon/Structures/WeaponConfig.h"
#include "Cloud9/Weapon/Tables/WeaponTableFirearm.h"
#include "Components/WidgetComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Kismet/KismetMathLibrary.h"

const FName ACloud9WeaponFirearm::TracerProbabilityParameterName = TEXT("Probability");
const FName ACloud9WeaponFirearm::TracerDirectionParameterName = TEXT("Direction");
Expand Down Expand Up @@ -415,6 +416,15 @@ EFirearmFireStatus ACloud9WeaponFirearm::Fire(

if (IsHit)
{
if (Cast<UWidgetComponent>(LineHit.Component))
{
let Component = Character->GetWidgetInteractionComponent();
Component->SetCustomHitResult(LineHit);
Component->PressPointerKey(EKeys::LeftMouseButton);
Component->ReleasePointerKey(EKeys::LeftMouseButton);
return EFirearmFireStatus::Success;
}

let Direction = LineHit.Location - StartLocation | EFVector::Normalize{};

if (IsValid(FirearmCommonData.Tracer))
Expand Down
2 changes: 2 additions & 0 deletions Source/Cloud9/Weapon/Utils/EquipmentSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bool AEquipmentSpawner::CanBeDestroyed() const
not(bHelmetActivated xor bHelmet);
}

#if WITH_EDITOR
void AEquipmentSpawner::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
Expand All @@ -74,5 +75,6 @@ void AEquipmentSpawner::PostEditChangeProperty(FPropertyChangedEvent& PropertyCh
bHelmet = false;
}
}
#endif

AActor* AEquipmentSpawner::CreateChildActor() { return InitializeStaticMeshSample(SampleMesh); }