diff --git a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset index 379559b..aa2df4f 100644 Binary files a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset and b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset differ diff --git a/Content/Blueprints/Items/RevolverGun.uasset b/Content/Blueprints/Items/RevolverGun.uasset index 9ce83b1..0230aa1 100644 Binary files a/Content/Blueprints/Items/RevolverGun.uasset and b/Content/Blueprints/Items/RevolverGun.uasset differ diff --git a/Content/Blueprints/Items/ShotGun.uasset b/Content/Blueprints/Items/ShotGun.uasset new file mode 100644 index 0000000..a33f65d Binary files /dev/null and b/Content/Blueprints/Items/ShotGun.uasset differ diff --git a/Content/Levels/TestMap.umap b/Content/Levels/TestMap.umap index fb68d38..7c6bb0e 100644 Binary files a/Content/Levels/TestMap.umap and b/Content/Levels/TestMap.umap differ diff --git a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp index 28d4447..1166109 100644 --- a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp +++ b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp @@ -25,7 +25,7 @@ void UShootingComponent::BeginPlay() void UShootingComponent::Shoot() { - if (CurrentAmmo == 0 || bIsReloading || !bCanShoot) return; + if (!bIsHoldingGun || CurrentAmmo == 0 || bIsReloading || !bCanShoot) return; APawn* PawnOwner = Cast(PlayerCharacter); if (!PawnOwner || !PawnOwner->GetController()) return; @@ -71,7 +71,7 @@ void UShootingComponent::Shoot() void UShootingComponent::Reload() { - if (bIsReloading) return; + if (!bIsHoldingGun || bIsReloading) return; bIsReloading = true; @@ -81,6 +81,31 @@ void UShootingComponent::Reload() UE_LOG(LogTemp, Display, TEXT("Reloaded. Ammo: %d/%d"), CurrentAmmo, MaxAmmo); // Docelowo tutaj wywo�anie UI aktualizuj�ce stan ammo } +void UShootingComponent::PickUpGun(AGunBase* gunItem) +{ + if (bIsHoldingGun) + DropGun(); + + bIsHoldingGun = true; + + MaxRange = gunItem->MaxRange; + DamageValue = gunItem->DamageValue; + FireRateCooldown = gunItem->FireRateCooldown; + RecoilForceMultiplier = gunItem->RecoilForceMultiplier; + ReloadTime = gunItem->ReloadTime; + CurrentAmmo = gunItem->CurrentAmmo; + MaxAmmo = gunItem->MaxAmmo; +} + +void UShootingComponent::DropGun() +{ + if (!bIsHoldingGun) return; + + // TODO: Spawn gun actor + + bIsHoldingGun = false; +} + void UShootingComponent::ResetFireCooldown() { bCanShoot = true; diff --git a/Source/Exo/Private/Player/ExoPlayerController.cpp b/Source/Exo/Private/Player/ExoPlayerController.cpp index 143fc80..3f2c651 100644 --- a/Source/Exo/Private/Player/ExoPlayerController.cpp +++ b/Source/Exo/Private/Player/ExoPlayerController.cpp @@ -90,7 +90,7 @@ void AExoPlayerController::Look(const FInputActionValue& InputActionValue) void AExoPlayerController::Interact() { if (InteractionComponent->InteractedActor) - IInteractable::Execute_Interact(InteractionComponent->InteractedActor); + IInteractable::Execute_Interact(InteractionComponent->InteractedActor, PlayerCharacter); } void AExoPlayerController::PlayerJump() diff --git a/Source/Exo/Public/Characters/Components/ShootingComponent.h b/Source/Exo/Public/Characters/Components/ShootingComponent.h index 6f66409..7239898 100644 --- a/Source/Exo/Public/Characters/Components/ShootingComponent.h +++ b/Source/Exo/Public/Characters/Components/ShootingComponent.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include +#include #include "Interfaces/Damageable.h" #include "ShootingComponent.generated.h" @@ -18,27 +19,6 @@ public: // Sets default values for this component's properties UShootingComponent(); - UPROPERTY(EditAnywhere, Category = "Shooting") - float MaxRange = 2000.0f; - - UPROPERTY(EditAnywhere, Category = "Shooting") - float DamageValue = 100.0f; - - UPROPERTY(EditAnywhere, Category = "Shooting") - float FireRateCooldown = 1.0f; - - UPROPERTY(EditAnywhere, Category = "Shooting") - float RecoilForceMultiplier = 1.0f; - - UPROPERTY(EditAnywhere, Category = "Shooting") - float ReloadTime = 3.0f; - - UPROPERTY(EditAnywhere, Category = "Ammo") - int32 CurrentAmmo = 10; - - UPROPERTY(EditAnywhere, Category = "Ammo") - int32 MaxAmmo = 10; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug") bool bShowDebugLine = true; @@ -59,6 +39,12 @@ public: UFUNCTION(Category = "Shooting") void Reload(); + UFUNCTION(BlueprintCallable, Category = "Shooting") + void PickUpGun(AGunBase* gunItem); + + UFUNCTION(Category = "Shooting") + void DropGun(); + private: void ResetFireCooldown(); @@ -68,9 +54,16 @@ private: FTimerHandle ReloadTimer; - UPROPERTY(EditAnywhere, Category = "Shooting") + bool bIsHoldingGun = false; + bool bCanShoot = true; - - UPROPERTY(EditAnywhere, Category = "Reloading") bool bIsReloading = false; + + float MaxRange = 2000.0f; + float DamageValue = 100.0f; + float FireRateCooldown = 1.0f; + float RecoilForceMultiplier = 1.0f; + float ReloadTime = 3.0f; + int32 CurrentAmmo = 10; + int32 MaxAmmo = 10; }; diff --git a/Source/Exo/Public/Interfaces/Interactable.h b/Source/Exo/Public/Interfaces/Interactable.h index e16f178..e5fd2af 100644 --- a/Source/Exo/Public/Interfaces/Interactable.h +++ b/Source/Exo/Public/Interfaces/Interactable.h @@ -1,6 +1,7 @@ #pragma once #include "CoreMinimal.h" +#include "Characters/ExoPlayerCharacter.h" #include "UObject/Interface.h" #include "Interactable.generated.h" @@ -16,5 +17,5 @@ class EXO_API IInteractable public: UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction") - void Interact(); + void Interact(AExoPlayerCharacter* playerCharacter); }; \ No newline at end of file diff --git a/Source/Exo/Public/Items/GunBase.h b/Source/Exo/Public/Items/GunBase.h index b5c1f97..493318c 100644 --- a/Source/Exo/Public/Items/GunBase.h +++ b/Source/Exo/Public/Items/GunBase.h @@ -15,6 +15,27 @@ public: // Sets default values for this actor's properties AGunBase(); + UPROPERTY(EditAnywhere, Category = "Shooting") + float MaxRange = 2000.0f; + + UPROPERTY(EditAnywhere, Category = "Shooting") + float DamageValue = 100.0f; + + UPROPERTY(EditAnywhere, Category = "Shooting") + float FireRateCooldown = 1.0f; + + UPROPERTY(EditAnywhere, Category = "Shooting") + float RecoilForceMultiplier = 1.0f; + + UPROPERTY(EditAnywhere, Category = "Shooting") + float ReloadTime = 3.0f; + + UPROPERTY(EditAnywhere, Category = "Ammo") + int32 CurrentAmmo = 10; + + UPROPERTY(EditAnywhere, Category = "Ammo") + int32 MaxAmmo = 10; + protected: // Called when the game starts or when spawned virtual void BeginPlay() override;