From a450a7d687f77819cdd9017cad9b5331b406715e Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 24 Jan 2025 15:58:39 +0100 Subject: [PATCH 1/3] Added hit marker --- Content/Legumix/Player/BP_Play.uasset | 4 ++-- Content/Legumix/Player/HUD/WB_MainHud.uasset | 4 ++-- Source/LegumeMix/Private/Player/LMPlayer.cpp | 7 +++++++ Source/LegumeMix/Public/Player/LMPlayer.h | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 7a5efaf..cd9ccf5 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47bb60c6a7da0a0032df813250056b6bd664e72e37a0233430d9bdf80d63f5c9 -size 47896 +oid sha256:fb44ad5503f9723d8d3982501153a258736f914ab8d9b7c90fc5107d91ca8d06 +size 60081 diff --git a/Content/Legumix/Player/HUD/WB_MainHud.uasset b/Content/Legumix/Player/HUD/WB_MainHud.uasset index 629dde6..96c7a0f 100644 --- a/Content/Legumix/Player/HUD/WB_MainHud.uasset +++ b/Content/Legumix/Player/HUD/WB_MainHud.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:306941aa22aaa518489a68736a2c9132e4833e8c7ff87d9a23dc89f7d355980b -size 25869 +oid sha256:2e06fcaef99549326fa8abcb7ba18051b9d2463c4d7217af1cf01bf8de3a8907 +size 53918 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 63d08d4..b00c0bd 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -76,6 +76,7 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) FVector EndLocation; FVector ShotVector; FHitResult OutHit = FHitResult(); + bool HitSomething = false; DrawDebugLine(GetWorld(), Settings.Origin, Settings.Origin + (Settings.Direction * Settings.MaxDistance), FColor::Blue, false, 2.f); @@ -97,9 +98,15 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) if (ULMHitBox* HitBox = Cast(OutHit.Component)) { UE_LOG(LogTemp, Warning, TEXT("Hit Hitbox")); + HitSomething = true; HitBox->OnHit(Settings); } } + + if (HitSomething) + { + OnEnnemyHit(); + } } FVector ALMPlayer::GetWeaponFiringOrigin() const diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 2c66c4a..0093fad 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -67,6 +67,9 @@ public: UFUNCTION(BlueprintCallable) FVector GetAimVector() const; + UFUNCTION(BlueprintImplementableEvent) + void OnEnnemyHit(); + private: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr WeaponManager; From 5e21302abff760de49d1e20ecd187da3f6b6889f Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 24 Jan 2025 16:55:36 +0100 Subject: [PATCH 2/3] Added ammo display --- Content/Legumix/Player/BP_Play.uasset | 4 ++-- Content/Legumix/Player/HUD/WB_MainHud.uasset | 4 ++-- Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset | 4 ++-- Source/LegumeMix/Private/Player/LMPlayer.cpp | 16 ++++------------ Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp | 1 + .../LegumeMix/Private/Weapon/LMWeaponManager.cpp | 6 ++++++ Source/LegumeMix/Public/Player/LMPlayer.h | 16 ++++++++++++++-- Source/LegumeMix/Public/Weapon/LMWeaponManager.h | 11 +++++++++-- 8 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index cd9ccf5..50f85be 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb44ad5503f9723d8d3982501153a258736f914ab8d9b7c90fc5107d91ca8d06 -size 60081 +oid sha256:d33fb3d583b26fe2280e7a18d4d290dff5d8ab81fd61d2c00ce4342f411e51a7 +size 88178 diff --git a/Content/Legumix/Player/HUD/WB_MainHud.uasset b/Content/Legumix/Player/HUD/WB_MainHud.uasset index 96c7a0f..bfd8536 100644 --- a/Content/Legumix/Player/HUD/WB_MainHud.uasset +++ b/Content/Legumix/Player/HUD/WB_MainHud.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e06fcaef99549326fa8abcb7ba18051b9d2463c4d7217af1cf01bf8de3a8907 -size 53918 +oid sha256:85f2aa819dadc172bd145befbaed168ed89a5d7f97be74a0c601f3ca02b737d4 +size 94904 diff --git a/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset b/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset index e33519d..fa3de52 100644 --- a/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset +++ b/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9dd0a8e5040d5424636e6702e52106f5b214a756aa6be25262a44713f92200ac -size 56008 +oid sha256:8ee277b97db6e41a88b1881c97f10352040b92a750b60d39633d1cfe70789b77 +size 56079 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index b00c0bd..38bf943 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -31,7 +31,8 @@ ALMPlayer::ALMPlayer() void ALMPlayer::BeginPlay() { Super::BeginPlay(); - + WeaponManager->WeaponFired.AddUniqueDynamic(this, &ALMPlayer::WeaponFired); + WeaponManager->WeaponSwitched.AddUniqueDynamic(this, &ALMPlayer::WeaponSwitched); } void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) @@ -78,6 +79,8 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) FHitResult OutHit = FHitResult(); bool HitSomething = false; + OnFire(); + DrawDebugLine(GetWorld(), Settings.Origin, Settings.Origin + (Settings.Direction * Settings.MaxDistance), FColor::Blue, false, 2.f); for (int Shots = 0; Shots < Settings.BulletCount; Shots++) @@ -121,14 +124,3 @@ FVector ALMPlayer::GetWeaponFiringOrigin() const FVector ALMPlayer::GetAimVector() const { return Camera->GetForwardVector(); } -void ALMPlayer::Tick(float DeltaTime) -{ - Super::Tick(DeltaTime); -} - -void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - Super::SetupPlayerInputComponent(PlayerInputComponent); - -} - diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp index 9b83164..0fea6c3 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp @@ -94,6 +94,7 @@ bool ALMWeaponBase::DefaultReload() // TODO: Use Animations OnDefaultReload(); GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay); + Player->OnReload(); return true; } diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index 8e9e1b8..b158020 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -120,7 +120,10 @@ void ULMWeaponManager::Fire() ALMWeaponBase* Weapon = GetCurrentWeapon(); if (Weapon->State == EWeaponState::EWS_Idle) + { Weapon->PrimaryFire(); + WeaponFired.Broadcast(); + } } void ULMWeaponManager::Reload() @@ -128,7 +131,9 @@ void ULMWeaponManager::Reload() ALMWeaponBase* Weapon = GetCurrentWeapon(); if (Weapon->State == EWeaponState::EWS_Idle) + { Weapon->Reload(); + } } void ULMWeaponManager::SwitchWeapon(const int Direction) @@ -160,5 +165,6 @@ void ULMWeaponManager::SetWeapon(const int Index) GetCurrentWeapon()->SetActorHiddenInGame(false); GetCurrentWeapon()->OnEquip(); + WeaponSwitched.Broadcast(); } diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 0093fad..f404d6c 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -21,8 +21,6 @@ class LEGUMEMIX_API ALMPlayer : public ACharacter public: // Sets default values for this character's properties ALMPlayer(); - virtual void Tick(float DeltaTime) override; - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; UFUNCTION(BlueprintCallable) void PickUpAmmo(ALMAmmo* Ammo); @@ -67,8 +65,22 @@ public: UFUNCTION(BlueprintCallable) FVector GetAimVector() const; + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void WeaponFired(); + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void WeaponReloaded(); + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void WeaponSwitched(); + UFUNCTION(BlueprintImplementableEvent) void OnEnnemyHit(); + + UFUNCTION(BlueprintImplementableEvent, Category=Legumix) + void OnFire(); + + UFUNCTION(BlueprintImplementableEvent, Category=Legumix) + void OnReload(); + private: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h index b3959a3..0c451c3 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -16,6 +16,9 @@ class LEGUMEMIX_API ULMWeaponManager : public UActorComponent { GENERATED_BODY() + DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWeaponFiredSignature); + DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWeaponSwitchedSignature); + public: ULMWeaponManager(); void SetArmsMesh(USkeletalMeshComponent* Mesh) { ArmsMesh = Mesh; } @@ -50,6 +53,12 @@ public: UFUNCTION(BlueprintCallable, Category="Legumix|Ammo") int RemoveAmmo(EAmmoType Ammo, int Count); +public: + UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix) + FOnWeaponFiredSignature WeaponFired; + UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix) + FOnWeaponFiredSignature WeaponSwitched; + protected: virtual void BeginPlay() override; // virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; @@ -74,6 +83,4 @@ private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Ammo", meta=(AllowPrivateAccess=true)) TMap AmmoData; - - }; From b7a4f1b2059e7df5b23cdda47e42f651cb76314a Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 24 Jan 2025 16:56:00 +0100 Subject: [PATCH 3/3] Fixed revolver reload --- Content/Legumix/Weapon/Revolver/BP_Revolver.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset index d05f3ef..25ecd2e 100644 --- a/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset +++ b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:518819fa1779bbb1b3ec35f67b9ac0967ba613befeda1e45216d5f2593820d9f -size 52339 +oid sha256:0fcdd22901c3e780e6dd405d8f09bc7dffeb15ec2da7f0103adf4a253f4b77c8 +size 57420