From 59df20c639c3c476140176ed4afb01f3c012d972 Mon Sep 17 00:00:00 2001 From: sSebster Date: Mon, 20 Jan 2025 14:15:06 +0100 Subject: [PATCH 01/15] Created : Weapon class --- Source/LegumeMix/Private/Weapon/LMWeapon.cpp | 1 + Source/LegumeMix/Public/Weapon/LMWeapon.h | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 Source/LegumeMix/Private/Weapon/LMWeapon.cpp create mode 100644 Source/LegumeMix/Public/Weapon/LMWeapon.h diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp new file mode 100644 index 0000000..837977b --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -0,0 +1 @@ +#include "Weapon/LMWeapon.h" diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h new file mode 100644 index 0000000..dd1b279 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -0,0 +1,9 @@ +#pragma once + +#include "CoreMinimal.h" + +UCLASS() +class LEGUMEMIX_API ULMWeapon : public UObject +{ + GENERATED_BODY() +}; From a107f650c80893579214ae22f4ed77458ec3e6ed Mon Sep 17 00:00:00 2001 From: TjgL Date: Mon, 20 Jan 2025 16:27:36 +0100 Subject: [PATCH 02/15] Added weapon manager --- Content/Legumix/Player/BP_Player.uasset | 4 +- .../Weapon/BP_WeaponManagerComponent.uasset | 3 ++ Source/LegumeMix/Private/Player/LMPlayer.cpp | 16 +++--- .../Private/Player/LMPlayerController.cpp | 3 +- .../Private/Weapon/LMWeaponManager.cpp | 50 +++++++++++++++++++ Source/LegumeMix/Public/Player/LMPlayer.h | 12 +++-- .../Public/Player/LMPlayerController.h | 4 +- .../LegumeMix/Public/Weapon/LMWeaponManager.h | 48 ++++++++++++++++++ 8 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset create mode 100644 Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp create mode 100644 Source/LegumeMix/Public/Weapon/LMWeaponManager.h diff --git a/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset index 3803d2f..53b0c53 100644 --- a/Content/Legumix/Player/BP_Player.uasset +++ b/Content/Legumix/Player/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:555cf39cb18991be658039390eecbf091b172614e934e0090227ed060b6e641e -size 34703 +oid sha256:2db256cc9494b901f3f24e4b4d66f8d720b60fba52d250d031e334c0cfd5b5fc +size 35424 diff --git a/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset b/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset new file mode 100644 index 0000000..d90bc05 --- /dev/null +++ b/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:792b2f2ab7e6dc725e9fbb7d949aa7d8ac23483a5ce1508c109ad5973dd1c474 +size 14988 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 2bcea73..ea031d4 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -3,32 +3,32 @@ #include "Player/LMPlayer.h" -// Sets default values +#include "Weapon/LMWeaponManager.h" + ALMPlayer::ALMPlayer() { - // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; + + WeaponManager = CreateDefaultSubobject(TEXT("Weapon Manager")); + + WeaponSkeletalMeshComponent = CreateDefaultSubobject(TEXT("Weapon Mesh")); + WeaponSkeletalMeshComponent->SetupAttachment(GetMesh()); + WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent); } -// Called when the game starts or when spawned void ALMPlayer::BeginPlay() { Super::BeginPlay(); - } -// Called every frame void ALMPlayer::Tick(float DeltaTime) { Super::Tick(DeltaTime); - } -// Called to bind functionality to input void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); - } diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 2ec8be3..2b74fd6 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -5,13 +5,14 @@ #include "EnhancedInputSubsystems.h" #include "EnhancedInputComponent.h" #include "GameFramework/Character.h" +#include "Player/LMPlayer.h" void ALMPlayerController::BeginPlay() { Super::BeginPlay(); EnhancedInputSubsystem = GetLocalPlayer()->GetSubsystem(); EnhancedInputSubsystem->AddMappingContext(DefaultMappingContext, 0); - LegumixPlayer = Cast(GetPawn()); + LegumixPlayer = Cast(GetPawn()); } void ALMPlayerController::SetupInputComponent() diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp new file mode 100644 index 0000000..6c88e97 --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -0,0 +1,50 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon/LMWeaponManager.h" + +#include "Weapon/LMWeapon.h" + + +ULMWeaponManager::ULMWeaponManager() +{ + PrimaryComponentTick.bCanEverTick = false; +} + +void ULMWeaponManager::BeginPlay() +{ + Super::BeginPlay(); + + for (auto Weapon : StartingWeapons) + { + if (Weapon) + { + ULMWeapon* Instance = NewObject(this, Weapon); + Weapons.Add(Instance); + } + } + + if (!Weapons.IsEmpty()) + { + SetWeapon(CurrentWeaponIndex); + } +} + + +void ULMWeaponManager::SetWeapon(int Index) +{ + if (Index < 0 || Index >= Weapons.Num()) + { + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index"); + return; + } + + CurrentWeaponIndex = Index; + + if (WeaponMeshComponent) + { + // TODO + // WeaponMeshComponent->SetSkeletalMesh() + } +} + diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index effd765..71f46c6 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -6,24 +6,28 @@ #include "GameFramework/Character.h" #include "LMPlayer.generated.h" +class ULMWeaponManager; + UCLASS() class LEGUMEMIX_API ALMPlayer : public ACharacter { GENERATED_BODY() public: - // Sets default values for this character's properties ALMPlayer(); protected: - // Called when the game starts or when spawned virtual void BeginPlay() override; public: - // Called every frame virtual void Tick(float DeltaTime) override; - // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; +private: + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + TObjectPtr WeaponManager; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + TObjectPtr WeaponSkeletalMeshComponent; }; diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index 292022c..01dc307 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -7,6 +7,8 @@ #include "EnhancedInputSubsystems.h" #include "LMPlayerController.generated.h" +class ALMPlayer; + /** * */ @@ -35,7 +37,7 @@ private: TObjectPtr JumpAction; UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) - TObjectPtr LegumixPlayer; + TObjectPtr LegumixPlayer; virtual void SetupInputComponent() override; void Move(const FInputActionValue& InputValue); diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h new file mode 100644 index 0000000..977fa19 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -0,0 +1,48 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "LMWeaponManager.generated.h" + + +class ULMWeapon; + +UCLASS(Blueprintable, BlueprintType, ClassGroup="Legumix", meta=(BlueprintSpawnableComponent)) +class LEGUMEMIX_API ULMWeaponManager : public UActorComponent +{ + GENERATED_BODY() + +public: + ULMWeaponManager(); + void SetWeaponMeshComponent(USkeletalMeshComponent* Mesh) { WeaponMeshComponent = Mesh; } + +public: + /** + * Get the Weapon currently equipped. + * @return The Current Weapon. + */ + UFUNCTION(BlueprintCallable, Category="Legumix") + ULMWeapon* GetCurrentWeapon() { return Weapons[CurrentWeaponIndex]; } + + UFUNCTION(BlueprintCallable, Category="Legumix") + void SetWeapon(int Index); + +protected: + virtual void BeginPlay() override; + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta = (AllowPrivateAccess = "true")) + TObjectPtr WeaponMeshComponent; + + /** The weapons the player starts with. */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta=(AllowPrivateAccess=true)) + TArray> StartingWeapons; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta=(AllowPrivateAccess=true)) + TArray> Weapons; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix", meta=(AllowPrivateAccess=true)) + int CurrentWeaponIndex = 0; +}; From f39f90b41140efa98979cc94c9cabe8a69d4e8e4 Mon Sep 17 00:00:00 2001 From: TjgL Date: Mon, 20 Jan 2025 16:55:37 +0100 Subject: [PATCH 03/15] Added Binding for firing and reloading --- .../Legumix/Player/BP_PlayerController.uasset | 4 +-- Content/Legumix/Player/Input/IA_Reload.uasset | 3 ++ .../Legumix/Player/Input/IMC_Default.uasset | 4 +-- .../Private/Player/LMPlayerController.cpp | 15 +++++++- .../Private/Weapon/LMWeaponManager.cpp | 36 +++++++++++++++++++ Source/LegumeMix/Public/Player/LMPlayer.h | 7 ++-- .../Public/Player/LMPlayerController.h | 8 +++++ .../LegumeMix/Public/Weapon/LMWeaponManager.h | 9 +++++ 8 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 Content/Legumix/Player/Input/IA_Reload.uasset diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 0621c64..70cbdfd 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:405ca21288778bca44cf90e4b0f221cbd80ccad8b3e2d0b5b5828959e0c8f4d8 -size 20808 +oid sha256:6a919743f7fbc6ec885b5d01157fdf18ce01885039406dbb482584129be4a0a0 +size 21190 diff --git a/Content/Legumix/Player/Input/IA_Reload.uasset b/Content/Legumix/Player/Input/IA_Reload.uasset new file mode 100644 index 0000000..a627744 --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Reload.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a76e00972c3d8c538e13db6eba112f616c5b35e3730a50950f495aade376d8b +size 1696 diff --git a/Content/Legumix/Player/Input/IMC_Default.uasset b/Content/Legumix/Player/Input/IMC_Default.uasset index 6b9f57c..064fac7 100644 --- a/Content/Legumix/Player/Input/IMC_Default.uasset +++ b/Content/Legumix/Player/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51dde808b98d4b04583ab19bf9db04cc2c383974ccb6069672bb8cd2a3465c11 -size 7263 +oid sha256:d49fb1f06fa5933d889da18c924c6bcbb92e213c6d7b54a29ef88406943d9396 +size 8619 diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 2b74fd6..06aff27 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -6,6 +6,7 @@ #include "EnhancedInputComponent.h" #include "GameFramework/Character.h" #include "Player/LMPlayer.h" +#include "Weapon/LMWeaponManager.h" void ALMPlayerController::BeginPlay() { @@ -22,6 +23,8 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move); Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump); Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look); + Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); + Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); } void ALMPlayerController::Move(const FInputActionValue& InputValue) @@ -41,4 +44,14 @@ void ALMPlayerController::Look(const FInputActionValue& InputValue) const FVector2d VectorDirection = InputValue.Get(); AddYawInput(VectorDirection.X); AddPitchInput(VectorDirection.Y); -} \ No newline at end of file +} + +void ALMPlayerController::Fire(const FInputActionValue& InputValue) +{ + LegumixPlayer->GetWeaponManager()->Fire(); +} + +void ALMPlayerController::Reload(const FInputActionValue& InputValue) +{ + LegumixPlayer->GetWeaponManager()->Reload(); +} diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index 6c88e97..f54eb11 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -21,6 +21,9 @@ void ULMWeaponManager::BeginPlay() { ULMWeapon* Instance = NewObject(this, Weapon); Weapons.Add(Instance); + + // TODO + // Instance->Initialize(); } } @@ -30,6 +33,39 @@ void ULMWeaponManager::BeginPlay() } } +void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount) +{ + FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType); + GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug); + + for (const auto Weapon : Weapons) + { + // TODO : match weapon ammo type + if (!Weapon) + continue; + + // TODO + // Weapon.AddAmmo(AmmoCount); + } +} + +void ULMWeaponManager::Fire() +{ + // ULMWeapon* Weapon = GetCurrentWeapon(); + + GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire"); + // TODO +} + +void ULMWeaponManager::Reload() +{ + GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading"); + + + // ULMWeapon* Weapon = GetCurrentWeapon(); + // TODO + // Weapon->Reload(); +} void ULMWeaponManager::SetWeapon(int Index) { diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 71f46c6..49ddd12 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -15,14 +15,15 @@ class LEGUMEMIX_API ALMPlayer : public ACharacter public: ALMPlayer(); + virtual void Tick(float DeltaTime) override; + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; protected: virtual void BeginPlay() override; public: - virtual void Tick(float DeltaTime) override; - - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + UFUNCTION(BlueprintCallable) + ULMWeaponManager* GetWeaponManager() { return WeaponManager; } private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index 01dc307..cd05666 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -36,6 +36,12 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr JumpAction; + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr FireAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr ReloadAction; + UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; @@ -43,4 +49,6 @@ private: void Move(const FInputActionValue& InputValue); void Jump(const FInputActionValue& InputValue); void Look(const FInputActionValue& InputValue); + void Fire(const FInputActionValue& InputValue); + void Reload(const FInputActionValue& InputValue); }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h index 977fa19..7a5caaf 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -29,6 +29,15 @@ public: UFUNCTION(BlueprintCallable, Category="Legumix") void SetWeapon(int Index); + UFUNCTION(BlueprintCallable, Category="Legumix") + void AddAmmoType(uint8 AmmoType, int AmmoCount); + + UFUNCTION(BlueprintCallable, Category="Legumix") + void Fire(); + + UFUNCTION(BlueprintCallable, Category="Legumix") + void Reload(); + protected: virtual void BeginPlay() override; From 6da5f750890c2f24d91bbf4cbd182a65e6808c7f Mon Sep 17 00:00:00 2001 From: sSebster Date: Mon, 20 Jan 2025 18:42:26 +0100 Subject: [PATCH 04/15] Added weapons radivolver and bazoucorn added bp radivolver and bazoucorn added dt weapon data --- Binaries/Win64/UnrealEditor-LegumeMix.exp | 4 +-- Binaries/Win64/UnrealEditor-LegumeMix.pdb | 4 +-- Content/Legumix/Weapon/BP_Bazoucorn.uasset | 3 ++ Content/Legumix/Weapon/BP_Radivolver.uasset | 3 ++ Content/Legumix/Weapon/DT_WeaponData.uasset | 3 ++ Source/LegumeMix/Private/Weapon/Bazoucorn.cpp | 4 +++ .../LegumeMix/Private/Weapon/LMRadivolver.cpp | 4 +++ Source/LegumeMix/Private/Weapon/LMWeapon.cpp | 32 +++++++++++++++++++ .../Private/Weapon/LMWeaponDataStructure.cpp | 1 + Source/LegumeMix/Public/Weapon/Bazoucorn.h | 16 ++++++++++ Source/LegumeMix/Public/Weapon/LMRadivolver.h | 16 ++++++++++ Source/LegumeMix/Public/Weapon/LMWeapon.h | 31 +++++++++++++++++- .../Public/Weapon/LMWeaponDataStructure.h | 24 ++++++++++++++ 13 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 Content/Legumix/Weapon/BP_Bazoucorn.uasset create mode 100644 Content/Legumix/Weapon/BP_Radivolver.uasset create mode 100644 Content/Legumix/Weapon/DT_WeaponData.uasset create mode 100644 Source/LegumeMix/Private/Weapon/Bazoucorn.cpp create mode 100644 Source/LegumeMix/Private/Weapon/LMRadivolver.cpp create mode 100644 Source/LegumeMix/Private/Weapon/LMWeaponDataStructure.cpp create mode 100644 Source/LegumeMix/Public/Weapon/Bazoucorn.h create mode 100644 Source/LegumeMix/Public/Weapon/LMRadivolver.h create mode 100644 Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.exp b/Binaries/Win64/UnrealEditor-LegumeMix.exp index 3fed5c4..a6c8e31 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.exp +++ b/Binaries/Win64/UnrealEditor-LegumeMix.exp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ed528cbcb22fab1d12ed581a7c24a30e0e61e49413780f3299c63208ab77ccc -size 11558 +oid sha256:2c7dbeab63810375b3130700a96467f2ff19c4a5ce65ef643464f197fbd48968 +size 21132 diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.pdb b/Binaries/Win64/UnrealEditor-LegumeMix.pdb index 7d674df..0e11f92 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.pdb +++ b/Binaries/Win64/UnrealEditor-LegumeMix.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:857367d1cbd5cf6e376a48fdc7e5322bcb5ac0fb89152955790a09ce2bae9bb9 -size 60223488 +oid sha256:c9a69dc83569b529cbab9a41a0b4a673d1954c0706a7d4fa86941384f9f7ec04 +size 60411904 diff --git a/Content/Legumix/Weapon/BP_Bazoucorn.uasset b/Content/Legumix/Weapon/BP_Bazoucorn.uasset new file mode 100644 index 0000000..c6b7034 --- /dev/null +++ b/Content/Legumix/Weapon/BP_Bazoucorn.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:444084ec12a0a30ee30f4edb07c0277d94408ac55ae151ec9d0899e90935cdac +size 6095 diff --git a/Content/Legumix/Weapon/BP_Radivolver.uasset b/Content/Legumix/Weapon/BP_Radivolver.uasset new file mode 100644 index 0000000..b7332c1 --- /dev/null +++ b/Content/Legumix/Weapon/BP_Radivolver.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f69c9db90342e0aebf72a4fb844725eb3f0c3d4586902cacfed87339b2c90182 +size 11857 diff --git a/Content/Legumix/Weapon/DT_WeaponData.uasset b/Content/Legumix/Weapon/DT_WeaponData.uasset new file mode 100644 index 0000000..b51c224 --- /dev/null +++ b/Content/Legumix/Weapon/DT_WeaponData.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cfe70137cb69fab53bd2763dd2e3dd1545953a6fa9d88e84cebbcccf6562962 +size 2501 diff --git a/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp b/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp new file mode 100644 index 0000000..49fe2af --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon/Bazoucorn.h" diff --git a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp new file mode 100644 index 0000000..f401218 --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon/LMRadivolver.h" diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp index 837977b..21931da 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -1 +1,33 @@ #include "Weapon/LMWeapon.h" + +#include "Weapon/LMWeaponDataStructure.h" + +void ULMWeapon::Initialize() +{ + WeaponDataStructure =* WeaponRow.GetRow(TEXT("")); +} + +bool ULMWeapon::HasAmmoInClip() +{ + if(CurrentClipAmmo > 0) + { + return true; + } + return false; +} + +bool ULMWeapon::HasAmmoInInventory() +{ + if (CurrentAmmoInInventory > 0) + { + return true; + } + return false; +} + +void ULMWeapon::Reload() +{ + //Do design reload logic + OnReload(); +} + diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponDataStructure.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponDataStructure.cpp new file mode 100644 index 0000000..1a3991c --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMWeaponDataStructure.cpp @@ -0,0 +1 @@ +#include "Weapon/LMWeaponDataStructure.h" diff --git a/Source/LegumeMix/Public/Weapon/Bazoucorn.h b/Source/LegumeMix/Public/Weapon/Bazoucorn.h new file mode 100644 index 0000000..b644cb3 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/Bazoucorn.h @@ -0,0 +1,16 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "LMWeapon.h" +#include "Bazoucorn.generated.h" + +/** + * + */ +UCLASS(BlueprintType, Blueprintable) +class LEGUMEMIX_API UBazoucorn : public ULMWeapon +{ + GENERATED_BODY() +}; diff --git a/Source/LegumeMix/Public/Weapon/LMRadivolver.h b/Source/LegumeMix/Public/Weapon/LMRadivolver.h new file mode 100644 index 0000000..3261c68 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMRadivolver.h @@ -0,0 +1,16 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "LMWeapon.h" +#include "LMRadivolver.generated.h" + +/** + * + */ +UCLASS(BlueprintType, Blueprintable) +class LEGUMEMIX_API ULMRadivolver : public ULMWeapon +{ + GENERATED_BODY() +}; diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h index dd1b279..4dda398 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeapon.h +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -1,9 +1,38 @@ #pragma once #include "CoreMinimal.h" +#include "LMWeaponDataStructure.h" +#include "LMWeapon.generated.h" -UCLASS() +struct FLMWeaponDataStructure; + +UCLASS(BlueprintType, Blueprintable) class LEGUMEMIX_API ULMWeapon : public UObject { GENERATED_BODY() + +public: + + UPROPERTY() + FLMWeaponDataStructure WeaponDataStructure; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Legumix") + FDataTableRowHandle WeaponRow; + + UPROPERTY() + int CurrentClipAmmo; + + UPROPERTY() + int CurrentAmmoInInventory; + + void Initialize(); + + void Fire(); + UFUNCTION(BlueprintCallable) + void Reload(); + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void OnReload(); //To call in blueprint for design utilities + void AddAmmo(); + + bool HasAmmoInClip(); + bool HasAmmoInInventory(); }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h new file mode 100644 index 0000000..1fe5db6 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -0,0 +1,24 @@ +#pragma once +#include "AnimationBlueprintEditorSettings.h" +#include "LMWeaponDataStructure.generated.h" + +USTRUCT(BlueprintType) +struct FLMWeaponDataStructure : public FTableRowBase +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int MaxAmmo; // Max ammo in "inventory" + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + int MaxClipAmmo; // Max ammo in clip + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene + + //UPROPERTY(EditAnywhere, BlueprintReadWrite) + //enum AmmoType; //Type of ammo, which ammo this weapon is using + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TObjectPtr AnimationBluePrint; //The animation blueprint to animate the mesh +}; From dde9f349583404421730e0f6e022cb49581d3103 Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Tue, 21 Jan 2025 16:03:24 +0100 Subject: [PATCH 05/15] Added : Ammo files --- Binaries/Win64/LegumeMixEditor.target | 168 +++++++++--------- Content/Legumix/Player/BP_Player.uasset | 4 +- Content/Legumix/Weapon/BP_Ammo.uasset | 3 + Source/LegumeMix/Private/Player/LMPlayer.cpp | 18 +- .../Private/Player/LMPlayerController.cpp | 14 +- Source/LegumeMix/Private/Weapon/LMAmmo.cpp | 43 +++++ Source/LegumeMix/Public/Player/LMPlayer.h | 7 + Source/LegumeMix/Public/Weapon/LMAmmo.h | 50 ++++++ 8 files changed, 217 insertions(+), 90 deletions(-) create mode 100644 Content/Legumix/Weapon/BP_Ammo.uasset create mode 100644 Source/LegumeMix/Private/Weapon/LMAmmo.cpp create mode 100644 Source/LegumeMix/Public/Weapon/LMAmmo.h diff --git a/Binaries/Win64/LegumeMixEditor.target b/Binaries/Win64/LegumeMixEditor.target index 7b8d3b5..314c033 100644 --- a/Binaries/Win64/LegumeMixEditor.target +++ b/Binaries/Win64/LegumeMixEditor.target @@ -21,6 +21,18 @@ "BuildId": "37670630" }, "BuildProducts": [ + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb", + "Type": "SymbolFile" + }, + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules", + "Type": "RequiredResource" + }, { "Path": "$(EngineDir)/Binaries/ThirdParty/USD/UsdResources/Win64/plugins/ar/resources/plugInfo.json", "Type": "RequiredResource" @@ -2833,6 +2845,50 @@ "Path": "$(EngineDir)/Plugins/Animation/LiveLink/Binaries/Win64/UnrealEditor.modules", "Type": "RequiredResource" }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor-RigLogicDeveloper.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor-RigLogicEditor.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor-RigLogicLib.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor-RigLogicLibTest.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor-RigLogicModule.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/Binaries/Win64/UnrealEditor.modules", + "Type": "RequiredResource" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Binaries/Win64/UnrealEditor-Bridge.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Binaries/Win64/UnrealEditor-Bridge.pdb", + "Type": "SymbolFile" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Binaries/Win64/UnrealEditor-MegascansPlugin.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Binaries/Win64/UnrealEditor-MegascansPlugin.pdb", + "Type": "SymbolFile" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Binaries/Win64/UnrealEditor.modules", + "Type": "RequiredResource" + }, { "Path": "$(EngineDir)/Plugins/Cameras/CameraShakePreviewer/Binaries/Win64/UnrealEditor-CameraShakePreviewer.dll", "Type": "DynamicLibrary" @@ -3665,6 +3721,18 @@ "Path": "$(EngineDir)/Plugins/Experimental/MeshModelingToolsetExp/Binaries/Win64/UnrealEditor.modules", "Type": "RequiredResource" }, + { + "Path": "$(EngineDir)/Plugins/Experimental/MetaHuman/MetaHumanSDK/Binaries/Win64/UnrealEditor-MetaHumanSDKEditor.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Experimental/MetaHuman/MetaHumanSDK/Binaries/Win64/UnrealEditor-MetaHumanSDKRuntime.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(EngineDir)/Plugins/Experimental/MetaHuman/MetaHumanSDK/Binaries/Win64/UnrealEditor.modules", + "Type": "RequiredResource" + }, { "Path": "$(EngineDir)/Plugins/Experimental/NFORDenoise/Binaries/Win64/UnrealEditor-NFORDenoise.dll", "Type": "DynamicLibrary" @@ -3889,66 +3957,6 @@ "Path": "$(EngineDir)/Plugins/Interchange/Runtime/Binaries/Win64/UnrealEditor.modules", "Type": "RequiredResource" }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RD.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RD.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderBlueprint.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderBlueprint.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderGameControl.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderGameControl.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLC.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLC.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLink.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLink.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLogging.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderLogging.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderShaderInfo.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor-RiderShaderInfo.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/Binaries/Win64/UnrealEditor.modules", - "Type": "RequiredResource" - }, { "Path": "$(EngineDir)/Plugins/Media/AndroidMedia/Binaries/Win64/UnrealEditor-AndroidMediaEditor.dll", "Type": "DynamicLibrary" @@ -4808,21 +4816,13 @@ { "Path": "$(EngineDir)/Plugins/XGEController/Binaries/Win64/UnrealEditor.modules", "Type": "RequiredResource" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules", - "Type": "RequiredResource" } ], "RuntimeDependencies": [ + { + "Path": "$(ProjectDir)/LegumeMix.uproject", + "Type": "UFS" + }, { "Path": "$(EngineDir)/Binaries/ThirdParty/DbgHelp/dbghelp.dll", "Type": "NonUFS" @@ -29839,6 +29839,14 @@ "Path": "$(EngineDir)/Plugins/Animation/LiveLink/LiveLink.uplugin", "Type": "UFS" }, + { + "Path": "$(EngineDir)/Plugins/Animation/RigLogic/RigLogic.uplugin", + "Type": "UFS" + }, + { + "Path": "$(EngineDir)/Plugins/Bridge/Bridge.uplugin", + "Type": "UFS" + }, { "Path": "$(EngineDir)/Plugins/Cameras/CameraShakePreviewer/CameraShakePreviewer.uplugin", "Type": "UFS" @@ -30179,6 +30187,10 @@ "Path": "$(EngineDir)/Plugins/Experimental/MeshModelingToolsetExp/MeshModelingToolsetExp.uplugin", "Type": "UFS" }, + { + "Path": "$(EngineDir)/Plugins/Experimental/MetaHuman/MetaHumanSDK/MetaHumanSDK.uplugin", + "Type": "UFS" + }, { "Path": "$(EngineDir)/Plugins/Experimental/NFORDenoise/NFORDenoise.uplugin", "Type": "UFS" @@ -30239,10 +30251,6 @@ "Path": "$(EngineDir)/Plugins/Interchange/Runtime/Interchange.uplugin", "Type": "UFS" }, - { - "Path": "$(EngineDir)/Plugins/Marketplace/Developer/RiderLink/RiderLink.uplugin", - "Type": "UFS" - }, { "Path": "$(EngineDir)/Plugins/Media/AndroidMedia/AndroidMedia.uplugin", "Type": "UFS" @@ -30538,10 +30546,6 @@ { "Path": "$(EngineDir)/Plugins/XGEController/XGEController.uplugin", "Type": "UFS" - }, - { - "Path": "$(ProjectDir)/LegumeMix.uproject", - "Type": "UFS" } ], "BuildPlugins": [ @@ -30573,6 +30577,7 @@ "BaseCharacterFXEditor", "BlendSpaceMotionAnalysis", "BlueprintHeaderView", + "Bridge", "CLionSourceCodeAccess", "CableComponent", "CameraShakePreviewer", @@ -30661,6 +30666,7 @@ "MeshModelingToolset", "MeshModelingToolsetExp", "MeshPainting", + "MetaHumanSDK", "Metasound", "MobileLauncherProfileWizard", "MobilePatchingUtils", @@ -30699,8 +30705,8 @@ "RenderDocPlugin", "RenderGraphInsights", "ResonanceAudio", - "RiderLink", "RiderSourceCodeAccess", + "RigLogic", "RigVM", "SQLiteCore", "SequencerAnimTools", diff --git a/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset index 53b0c53..0f797c6 100644 --- a/Content/Legumix/Player/BP_Player.uasset +++ b/Content/Legumix/Player/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2db256cc9494b901f3f24e4b4d66f8d720b60fba52d250d031e334c0cfd5b5fc -size 35424 +oid sha256:d13142befdccaf0a6e255f0ba55b1fbbfe764f1846950d8b6088aa3d00eca516 +size 34593 diff --git a/Content/Legumix/Weapon/BP_Ammo.uasset b/Content/Legumix/Weapon/BP_Ammo.uasset new file mode 100644 index 0000000..67df7d4 --- /dev/null +++ b/Content/Legumix/Weapon/BP_Ammo.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c05e55130308441515ad0dd36070015a59d36d0cd874aea6f533082a4603e29 +size 33124 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index ea031d4..135d138 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -2,11 +2,12 @@ #include "Player/LMPlayer.h" - +#include "Weapon/LMAmmo.h" #include "Weapon/LMWeaponManager.h" ALMPlayer::ALMPlayer() { + // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; WeaponManager = CreateDefaultSubobject(TEXT("Weapon Manager")); @@ -17,18 +18,33 @@ ALMPlayer::ALMPlayer() WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent); } +// Called when the game starts or when spawned void ALMPlayer::BeginPlay() { Super::BeginPlay(); + } +void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) +{ + if (GEngine) + { + FString AmmoAmount = FString::Printf(TEXT("Quantité de munition : %i"), Ammo->GetAmmoAmount()); + GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Red, AmmoAmount); + } +} + +// Called every frame void ALMPlayer::Tick(float DeltaTime) { Super::Tick(DeltaTime); + } +// Called to bind functionality to input void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); + } diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 06aff27..27bed09 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -19,12 +19,14 @@ void ALMPlayerController::BeginPlay() void ALMPlayerController::SetupInputComponent() { Super::SetupInputComponent(); - UEnhancedInputComponent* Input = Cast(InputComponent); - Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move); - Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump); - Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look); - Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); - Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); + if(UEnhancedInputComponent* Input = Cast(InputComponent)) + { + Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move); + Input->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Jump); + Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look); + Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); + Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); + } } void ALMPlayerController::Move(const FInputActionValue& InputValue) diff --git a/Source/LegumeMix/Private/Weapon/LMAmmo.cpp b/Source/LegumeMix/Private/Weapon/LMAmmo.cpp new file mode 100644 index 0000000..2fee821 --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMAmmo.cpp @@ -0,0 +1,43 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon/LMAmmo.h" + +#include "Components/BoxComponent.h" +#include "Components/SphereComponent.h" +#include "Player/LMPlayer.h" + +// Sets default values +ALMAmmo::ALMAmmo() +{ + PrimaryActorTick.bCanEverTick = true; + AmmoMeshComponent = CreateDefaultSubobject(TEXT("AmmoMeshComponent")); + RootComponent = AmmoMeshComponent; + CollisionSphere = CreateDefaultSubobject(TEXT("CollisionSphere")); + CollisionSphere->SetupAttachment(RootComponent); + CollisionSphere->OnComponentBeginOverlap.AddDynamic(this, &ALMAmmo::OnSphereOverlap); + AmmoType = EAmmoType::EAT_RadishAmmo; + AmmoAmount = 1; + +} + +void ALMAmmo::BeginPlay() +{ + Super::BeginPlay(); +} + +void ALMAmmo::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) +{ + if (ALMPlayer* Player = Cast(OtherActor)) + { + Player->PickUpAmmo(this); + Destroy(); + } +} + +void ALMAmmo::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 49ddd12..55bf134 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -8,17 +8,24 @@ class ULMWeaponManager; +class ALMAmmo; + UCLASS() class LEGUMEMIX_API ALMPlayer : public ACharacter { GENERATED_BODY() public: + // Sets default values for this character's properties ALMPlayer(); virtual void Tick(float DeltaTime) override; virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + + UFUNCTION() + void PickUpAmmo(ALMAmmo* Ammo); protected: + // Called when the game starts or when spawned virtual void BeginPlay() override; public: diff --git a/Source/LegumeMix/Public/Weapon/LMAmmo.h b/Source/LegumeMix/Public/Weapon/LMAmmo.h new file mode 100644 index 0000000..d397a72 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMAmmo.h @@ -0,0 +1,50 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "LMAmmo.generated.h" + +class USphereComponent; + +UENUM(BlueprintType) +enum class EAmmoType : uint8 +{ + EAT_RadishAmmo UMETA(DisplayName = "Radish Ammo"), + EAT_CornAmmo UMETA(DisplayName = "Corn Ammo") +}; + +UCLASS() +class LEGUMEMIX_API ALMAmmo : public AActor +{ + GENERATED_BODY() + +public: + ALMAmmo(); + virtual void Tick(float DeltaTime) override; + + UFUNCTION(BlueprintCallable) + inline int GetAmmoAmount() { return AmmoAmount; } + + UFUNCTION(BlueprintCallable) + inline EAmmoType GetAmmoType() { return AmmoType; } + +protected: + virtual void BeginPlay() override; + + UPROPERTY(EditAnywhere) + TObjectPtr AmmoMeshComponent; + + UPROPERTY(EditAnywhere) + TObjectPtr CollisionSphere; + + UPROPERTY(EditAnywhere) + EAmmoType AmmoType; + + UPROPERTY(EditAnywhere) + int AmmoAmount; + + UFUNCTION(BlueprintCallable) + void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); +}; From 075533474d18896ba2e8d572afd60917c0046477 Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Tue, 21 Jan 2025 16:14:32 +0100 Subject: [PATCH 06/15] Added : GameMode C++ file --- Content/Legumix/BP_GameMode.uasset | 4 ++-- Source/LegumeMix/Private/LMGameMode.cpp | 5 +++++ Source/LegumeMix/Public/LMGameMode.h | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Source/LegumeMix/Private/LMGameMode.cpp create mode 100644 Source/LegumeMix/Public/LMGameMode.h diff --git a/Content/Legumix/BP_GameMode.uasset b/Content/Legumix/BP_GameMode.uasset index 5f71003..ae68f7c 100644 --- a/Content/Legumix/BP_GameMode.uasset +++ b/Content/Legumix/BP_GameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffcd01b1a1fbc3def3c8451957cb4dc49d6529b1ea90ba3303bc53d2bd2f22ef -size 20699 +oid sha256:6ef764f0d6d17fb2309efb34815b5a2714079966472e420a0d6181a5021a0b5e +size 21071 diff --git a/Source/LegumeMix/Private/LMGameMode.cpp b/Source/LegumeMix/Private/LMGameMode.cpp new file mode 100644 index 0000000..401236f --- /dev/null +++ b/Source/LegumeMix/Private/LMGameMode.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "LMGameMode.h" + diff --git a/Source/LegumeMix/Public/LMGameMode.h b/Source/LegumeMix/Public/LMGameMode.h new file mode 100644 index 0000000..d9f147b --- /dev/null +++ b/Source/LegumeMix/Public/LMGameMode.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameModeBase.h" +#include "LMGameMode.generated.h" + +/** + * + */ +UCLASS() +class LEGUMEMIX_API ALMGameMode : public AGameModeBase +{ + GENERATED_BODY() + +}; From 3c68d50ed1417612da84676c765dabd4b5270450 Mon Sep 17 00:00:00 2001 From: sSebster Date: Tue, 21 Jan 2025 16:28:43 +0100 Subject: [PATCH 07/15] Added for parent weapon class : Reload and AddAmmo --- Binaries/Win64/UnrealEditor-LegumeMix.exp | 4 ++-- Binaries/Win64/UnrealEditor-LegumeMix.pdb | 4 ++-- Source/LegumeMix/Private/Weapon/Bazoucorn.cpp | 4 ---- .../LegumeMix/Private/Weapon/LMBazoucorn.cpp | 9 ++++++++ .../LegumeMix/Private/Weapon/LMRadivolver.cpp | 6 +++++ Source/LegumeMix/Private/Weapon/LMWeapon.cpp | 23 +++++++++++++++++++ .../Weapon/{Bazoucorn.h => LMBazoucorn.h} | 2 +- Source/LegumeMix/Public/Weapon/LMWeapon.h | 10 ++++---- .../Public/Weapon/LMWeaponDataStructure.h | 5 ++-- 9 files changed, 52 insertions(+), 15 deletions(-) delete mode 100644 Source/LegumeMix/Private/Weapon/Bazoucorn.cpp create mode 100644 Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp rename Source/LegumeMix/Public/Weapon/{Bazoucorn.h => LMBazoucorn.h} (88%) diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.exp b/Binaries/Win64/UnrealEditor-LegumeMix.exp index a6c8e31..81cee73 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.exp +++ b/Binaries/Win64/UnrealEditor-LegumeMix.exp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2c7dbeab63810375b3130700a96467f2ff19c4a5ce65ef643464f197fbd48968 -size 21132 +oid sha256:539ff602aa1fa5ccacb50b1125dbb86199c549e0b24a8a7da2c9d4cb814b6f48 +size 34050 diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.pdb b/Binaries/Win64/UnrealEditor-LegumeMix.pdb index 0e11f92..6e57268 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.pdb +++ b/Binaries/Win64/UnrealEditor-LegumeMix.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9a69dc83569b529cbab9a41a0b4a673d1954c0706a7d4fa86941384f9f7ec04 -size 60411904 +oid sha256:bfcad27449bf4813b3c20458b70d67afde0d17f6abcb3d968291708b64a76bd6 +size 60657664 diff --git a/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp b/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp deleted file mode 100644 index 49fe2af..0000000 --- a/Source/LegumeMix/Private/Weapon/Bazoucorn.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "Weapon/Bazoucorn.h" diff --git a/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp b/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp new file mode 100644 index 0000000..9cc48fa --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp @@ -0,0 +1,9 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon\LMBazoucorn.h" + +void ULMWeapon::Fire() +{ + //Fire like a Bazoucorn +} diff --git a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp index f401218..21d995a 100644 --- a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp +++ b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp @@ -2,3 +2,9 @@ #include "Weapon/LMRadivolver.h" + +void ULMWeapon::Fire() +{ + //Fire like a Radivolver +} + diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp index 21931da..16d8a30 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -29,5 +29,28 @@ void ULMWeapon::Reload() { //Do design reload logic OnReload(); + if(HasAmmoInClip()) + { + if(CurrentAmmoInInventory >= WeaponDataStructure.MaxClipAmmo) + { + CurrentClipAmmo = WeaponDataStructure.MaxClipAmmo; + CurrentAmmoInInventory -= WeaponDataStructure.MaxClipAmmo; + } + else + { + CurrentClipAmmo = CurrentAmmoInInventory; + CurrentAmmoInInventory = 0; + } + } +} + +void ULMWeapon::AddAmmo(int AmountOfAmmoToGet) +{ + CurrentAmmoInInventory += AmountOfAmmoToGet; +} + +void ULMWeapon::Fire() +{ + //Fire } diff --git a/Source/LegumeMix/Public/Weapon/Bazoucorn.h b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h similarity index 88% rename from Source/LegumeMix/Public/Weapon/Bazoucorn.h rename to Source/LegumeMix/Public/Weapon/LMBazoucorn.h index b644cb3..6d413c1 100644 --- a/Source/LegumeMix/Public/Weapon/Bazoucorn.h +++ b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h @@ -4,7 +4,7 @@ #include "CoreMinimal.h" #include "LMWeapon.h" -#include "Bazoucorn.generated.h" +#include "LMBazoucorn.generated.h" /** * diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h index 4dda398..d9c2e60 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeapon.h +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -27,12 +27,14 @@ public: void Initialize(); void Fire(); + UFUNCTION(BlueprintCallable) - void Reload(); + void Reload(); //Reload current clip to max ammo in clip UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) void OnReload(); //To call in blueprint for design utilities - void AddAmmo(); + + void AddAmmo(int AmountOfAmmoToGet); //Add ammo in inventory - bool HasAmmoInClip(); - bool HasAmmoInInventory(); + bool HasAmmoInClip(); //Check if there is ammo in clip (return a bool) + bool HasAmmoInInventory(); //Check if there is ammo in "inventory" (return a bool) }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h index 1fe5db6..df020c7 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -1,5 +1,6 @@ #pragma once #include "AnimationBlueprintEditorSettings.h" +#include "LMAmmo.h" #include "LMWeaponDataStructure.generated.h" USTRUCT(BlueprintType) @@ -16,8 +17,8 @@ struct FLMWeaponDataStructure : public FTableRowBase UPROPERTY(EditAnywhere, BlueprintReadWrite) TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene - //UPROPERTY(EditAnywhere, BlueprintReadWrite) - //enum AmmoType; //Type of ammo, which ammo this weapon is using + UPROPERTY(EditAnywhere, BlueprintReadWrite) + EAmmoType AmmoType; //Type of ammo, which ammo this weapon is using UPROPERTY(EditAnywhere, BlueprintReadWrite) TObjectPtr AnimationBluePrint; //The animation blueprint to animate the mesh From 99707d1b73c6b9165e3e7ade1a4c99eb4e0448bc Mon Sep 17 00:00:00 2001 From: TjgL Date: Tue, 21 Jan 2025 16:32:31 +0100 Subject: [PATCH 08/15] Added player weapon display --- Content/Legumix/Player/BP_Player.uasset | 4 +-- .../Legumix/Weapon/BP_WeaponManager.uasset | 3 +++ .../Weapon/BP_WeaponManagerComponent.uasset | 3 --- Content/Legumix/Weapon/DT_WeaponData.uasset | 4 +-- Source/LegumeMix/Private/Player/LMPlayer.cpp | 25 +++++++++++++++---- .../Private/Weapon/LMWeaponManager.cpp | 17 +++++++++---- Source/LegumeMix/Public/Player/LMPlayer.h | 9 ++++++- .../Public/Weapon/LMWeaponDataStructure.h | 2 +- .../LegumeMix/Public/Weapon/LMWeaponManager.h | 2 ++ 9 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 Content/Legumix/Weapon/BP_WeaponManager.uasset delete mode 100644 Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset diff --git a/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset index 53b0c53..a92705a 100644 --- a/Content/Legumix/Player/BP_Player.uasset +++ b/Content/Legumix/Player/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2db256cc9494b901f3f24e4b4d66f8d720b60fba52d250d031e334c0cfd5b5fc -size 35424 +oid sha256:a1b36ac7333d2d6b72f26ce3e384ba1dcee67208a17231d67c021037a7e9f4f0 +size 42647 diff --git a/Content/Legumix/Weapon/BP_WeaponManager.uasset b/Content/Legumix/Weapon/BP_WeaponManager.uasset new file mode 100644 index 0000000..0d3685c --- /dev/null +++ b/Content/Legumix/Weapon/BP_WeaponManager.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76dde9bd31fe7b9c92b2537215bc3a2b4fc67a3ea9fd83ccf9faa93d1af0d962 +size 15175 diff --git a/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset b/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset deleted file mode 100644 index d90bc05..0000000 --- a/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:792b2f2ab7e6dc725e9fbb7d949aa7d8ac23483a5ce1508c109ad5973dd1c474 -size 14988 diff --git a/Content/Legumix/Weapon/DT_WeaponData.uasset b/Content/Legumix/Weapon/DT_WeaponData.uasset index b51c224..a6daba6 100644 --- a/Content/Legumix/Weapon/DT_WeaponData.uasset +++ b/Content/Legumix/Weapon/DT_WeaponData.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5cfe70137cb69fab53bd2763dd2e3dd1545953a6fa9d88e84cebbcccf6562962 -size 2501 +oid sha256:a4e50014771a56604730976892111daf8f7eceaaf986ef12884bc79b1b54bd5a +size 2838 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index ea031d4..6d3e825 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -3,18 +3,20 @@ #include "Player/LMPlayer.h" +#include "Camera/CameraComponent.h" #include "Weapon/LMWeaponManager.h" ALMPlayer::ALMPlayer() { PrimaryActorTick.bCanEverTick = true; - - WeaponManager = CreateDefaultSubobject(TEXT("Weapon Manager")); + + Camera = CreateDefaultSubobject(TEXT("Camera")); + Camera->SetupAttachment(RootComponent); + Camera->bUsePawnControlRotation = true; + Camera->SetRelativeLocation(FVector(20, 0, 90)); WeaponSkeletalMeshComponent = CreateDefaultSubobject(TEXT("Weapon Mesh")); - WeaponSkeletalMeshComponent->SetupAttachment(GetMesh()); - - WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent); + WeaponSkeletalMeshComponent->SetupAttachment(Camera); } void ALMPlayer::BeginPlay() @@ -22,6 +24,19 @@ void ALMPlayer::BeginPlay() Super::BeginPlay(); } +void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) +{ + UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) + if (!Manager) + { + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Red, TEXT("No Weapon Manager was given to the player !")); + return; + } + + WeaponManager = Manager; + WeaponManager->Initialize(WeaponSkeletalMeshComponent); +} + void ALMPlayer::Tick(float DeltaTime) { Super::Tick(DeltaTime); diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index f54eb11..f026708 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -21,12 +21,16 @@ void ULMWeaponManager::BeginPlay() { ULMWeapon* Instance = NewObject(this, Weapon); Weapons.Add(Instance); - - // TODO - // Instance->Initialize(); + + Instance->Initialize(); } } +} +void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) +{ + SetWeaponMeshComponent(Mesh); + if (!Weapons.IsEmpty()) { SetWeapon(CurrentWeaponIndex); @@ -69,6 +73,8 @@ void ULMWeaponManager::Reload() void ULMWeaponManager::SetWeapon(int Index) { + UE_LOG(LogTemp, Warning, TEXT("Test")) + if (Index < 0 || Index >= Weapons.Num()) { GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index"); @@ -79,8 +85,9 @@ void ULMWeaponManager::SetWeapon(int Index) if (WeaponMeshComponent) { - // TODO - // WeaponMeshComponent->SetSkeletalMesh() + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh"); + + WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon); } } diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 49ddd12..6bd8424 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -6,6 +6,7 @@ #include "GameFramework/Character.h" #include "LMPlayer.generated.h" +class UCameraComponent; class ULMWeaponManager; UCLASS() @@ -25,10 +26,16 @@ public: UFUNCTION(BlueprintCallable) ULMWeaponManager* GetWeaponManager() { return WeaponManager; } + UFUNCTION(BlueprintCallable) + void SetWeaponManager(ULMWeaponManager* Manager); + private: - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) TObjectPtr WeaponManager; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) TObjectPtr WeaponSkeletalMeshComponent; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + TObjectPtr Camera; }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h index 1fe5db6..053242a 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -14,7 +14,7 @@ struct FLMWeaponDataStructure : public FTableRowBase int MaxClipAmmo; // Max ammo in clip UPROPERTY(EditAnywhere, BlueprintReadWrite) - TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene + TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene //UPROPERTY(EditAnywhere, BlueprintReadWrite) //enum AmmoType; //Type of ammo, which ammo this weapon is using diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h index 7a5caaf..821a8e3 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -37,6 +37,8 @@ public: UFUNCTION(BlueprintCallable, Category="Legumix") void Reload(); + + void Initialize(USkeletalMeshComponent* Mesh); protected: virtual void BeginPlay() override; From f380b6c358ef82f76a3bfa6ac9718a3e0e89dd1c Mon Sep 17 00:00:00 2001 From: TjgL Date: Tue, 21 Jan 2025 16:52:55 +0100 Subject: [PATCH 09/15] Implemented weapon switching --- .../Legumix/Player/BP_PlayerController.uasset | 4 +- Content/Legumix/Player/Input/IA_Scroll.uasset | 3 ++ .../Legumix/Player/Input/IMC_Default.uasset | 4 +- .../Private/Player/LMPlayerController.cpp | 7 ++++ .../Private/Weapon/LMWeaponManager.cpp | 37 ++++++++++++------- .../Public/Player/LMPlayerController.h | 4 ++ .../LegumeMix/Public/Weapon/LMWeaponManager.h | 6 ++- 7 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 Content/Legumix/Player/Input/IA_Scroll.uasset diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 70cbdfd..fac88f9 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a919743f7fbc6ec885b5d01157fdf18ce01885039406dbb482584129be4a0a0 -size 21190 +oid sha256:7651a3b0a3adbaa6cc2aa4907c29a4a112d232a215f9b9511f30f258f4ed83e8 +size 21387 diff --git a/Content/Legumix/Player/Input/IA_Scroll.uasset b/Content/Legumix/Player/Input/IA_Scroll.uasset new file mode 100644 index 0000000..b0f1bee --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Scroll.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a644a26da4bb581689db8d5718d28cce453de39fb11ff18e5ddc428d7efbd221 +size 1588 diff --git a/Content/Legumix/Player/Input/IMC_Default.uasset b/Content/Legumix/Player/Input/IMC_Default.uasset index 064fac7..ee7bc6a 100644 --- a/Content/Legumix/Player/Input/IMC_Default.uasset +++ b/Content/Legumix/Player/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d49fb1f06fa5933d889da18c924c6bcbb92e213c6d7b54a29ef88406943d9396 -size 8619 +oid sha256:6c8b22e84568896085079b948cb41a5f2440fa9b67b6130412762911f838490d +size 9304 diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 27bed09..47a8bba 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -26,6 +26,7 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look); Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); + Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); } } @@ -57,3 +58,9 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue) { LegumixPlayer->GetWeaponManager()->Reload(); } + +void ALMPlayerController::Scroll(const FInputActionValue& InputValue) +{ + const float ScrollAmount = InputValue.Get(); + LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount); +} diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index f026708..2717c4b 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -37,7 +37,7 @@ void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) } } -void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount) +void ULMWeaponManager::AddAmmoType(EAmmoType AmmoType, int AmmoCount) { FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType); GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug); @@ -45,36 +45,47 @@ void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount) for (const auto Weapon : Weapons) { // TODO : match weapon ammo type - if (!Weapon) + if (Weapon->WeaponDataStructure.AmmoType == AmmoType) continue; - // TODO - // Weapon.AddAmmo(AmmoCount); + Weapon->AddAmmo(AmmoCount); } } void ULMWeaponManager::Fire() { - // ULMWeapon* Weapon = GetCurrentWeapon(); + ULMWeapon* Weapon = GetCurrentWeapon(); GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire"); - // TODO + Weapon->Fire(); } void ULMWeaponManager::Reload() { GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading"); - - // ULMWeapon* Weapon = GetCurrentWeapon(); - // TODO - // Weapon->Reload(); + ULMWeapon* Weapon = GetCurrentWeapon(); + Weapon->Reload(); } -void ULMWeaponManager::SetWeapon(int Index) +void ULMWeaponManager::SwitchWeapon(const int Direction) +{ + const int NewIndex = Direction + CurrentWeaponIndex; + if (NewIndex >= 0 && NewIndex < Weapons.Num()) + { + SetWeapon(NewIndex); + } + else + { + if (NewIndex < 0) + SetWeapon(Weapons.Num() - 1); + else + SetWeapon(0); + } +} + +void ULMWeaponManager::SetWeapon(const int Index) { - UE_LOG(LogTemp, Warning, TEXT("Test")) - if (Index < 0 || Index >= Weapons.Num()) { GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index"); diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index cd05666..dcf4e56 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -41,6 +41,9 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr ReloadAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr ScrollAction; UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; @@ -51,4 +54,5 @@ private: void Look(const FInputActionValue& InputValue); void Fire(const FInputActionValue& InputValue); void Reload(const FInputActionValue& InputValue); + void Scroll(const FInputActionValue& InputValue); }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h index 821a8e3..7103bfb 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "LMAmmo.h" #include "Components/ActorComponent.h" #include "LMWeaponManager.generated.h" @@ -30,14 +31,15 @@ public: void SetWeapon(int Index); UFUNCTION(BlueprintCallable, Category="Legumix") - void AddAmmoType(uint8 AmmoType, int AmmoCount); + void AddAmmoType(EAmmoType AmmoType, int AmmoCount); UFUNCTION(BlueprintCallable, Category="Legumix") void Fire(); UFUNCTION(BlueprintCallable, Category="Legumix") void Reload(); - + void SwitchWeapon(int Direction); + void Initialize(USkeletalMeshComponent* Mesh); protected: From 43b88bdae92e139fd24576d330b431cfeb39d72e Mon Sep 17 00:00:00 2001 From: TjgL Date: Tue, 21 Jan 2025 17:05:20 +0100 Subject: [PATCH 10/15] Added Mesh relative location to the weapon --- Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index 2717c4b..e955737 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -14,6 +14,11 @@ ULMWeaponManager::ULMWeaponManager() void ULMWeaponManager::BeginPlay() { Super::BeginPlay(); +} + +void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) +{ + SetWeaponMeshComponent(Mesh); for (auto Weapon : StartingWeapons) { @@ -22,14 +27,9 @@ void ULMWeaponManager::BeginPlay() ULMWeapon* Instance = NewObject(this, Weapon); Weapons.Add(Instance); - Instance->Initialize(); + // Instance->Initialize(Mesh->GetRelativeLocation()); } } -} - -void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) -{ - SetWeaponMeshComponent(Mesh); if (!Weapons.IsEmpty()) { From e9e8ce49a2167a8fe423568908d1f0b1789a7b8e Mon Sep 17 00:00:00 2001 From: sSebster Date: Tue, 21 Jan 2025 17:14:10 +0100 Subject: [PATCH 11/15] Added : virtual and override fire for weapons --- Content/Legumix/Player/BP_Player.uasset | 4 +- .../Legumix/Player/BP_PlayerController.uasset | 4 +- Content/Legumix/Player/Input/IA_Scroll.uasset | 3 ++ .../Legumix/Player/Input/IMC_Default.uasset | 4 +- .../Legumix/Weapon/BP_WeaponManager.uasset | 3 ++ .../Weapon/BP_WeaponManagerComponent.uasset | 3 -- Source/LegumeMix/Private/Player/LMPlayer.cpp | 26 ++++++++-- .../Private/Player/LMPlayerController.cpp | 7 +++ .../LegumeMix/Private/Weapon/LMBazoucorn.cpp | 2 +- .../LegumeMix/Private/Weapon/LMRadivolver.cpp | 2 +- Source/LegumeMix/Private/Weapon/LMWeapon.cpp | 2 + .../Private/Weapon/LMWeaponManager.cpp | 52 +++++++++++++------ Source/LegumeMix/Public/Player/LMPlayer.h | 9 +++- .../Public/Player/LMPlayerController.h | 4 ++ Source/LegumeMix/Public/Weapon/LMBazoucorn.h | 1 + Source/LegumeMix/Public/Weapon/LMRadivolver.h | 1 + Source/LegumeMix/Public/Weapon/LMWeapon.h | 2 +- .../Public/Weapon/LMWeaponDataStructure.h | 2 +- .../LegumeMix/Public/Weapon/LMWeaponManager.h | 6 ++- 19 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 Content/Legumix/Player/Input/IA_Scroll.uasset create mode 100644 Content/Legumix/Weapon/BP_WeaponManager.uasset delete mode 100644 Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset diff --git a/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset index 0f797c6..a92705a 100644 --- a/Content/Legumix/Player/BP_Player.uasset +++ b/Content/Legumix/Player/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d13142befdccaf0a6e255f0ba55b1fbbfe764f1846950d8b6088aa3d00eca516 -size 34593 +oid sha256:a1b36ac7333d2d6b72f26ce3e384ba1dcee67208a17231d67c021037a7e9f4f0 +size 42647 diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 70cbdfd..fac88f9 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a919743f7fbc6ec885b5d01157fdf18ce01885039406dbb482584129be4a0a0 -size 21190 +oid sha256:7651a3b0a3adbaa6cc2aa4907c29a4a112d232a215f9b9511f30f258f4ed83e8 +size 21387 diff --git a/Content/Legumix/Player/Input/IA_Scroll.uasset b/Content/Legumix/Player/Input/IA_Scroll.uasset new file mode 100644 index 0000000..b0f1bee --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Scroll.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a644a26da4bb581689db8d5718d28cce453de39fb11ff18e5ddc428d7efbd221 +size 1588 diff --git a/Content/Legumix/Player/Input/IMC_Default.uasset b/Content/Legumix/Player/Input/IMC_Default.uasset index 064fac7..ee7bc6a 100644 --- a/Content/Legumix/Player/Input/IMC_Default.uasset +++ b/Content/Legumix/Player/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d49fb1f06fa5933d889da18c924c6bcbb92e213c6d7b54a29ef88406943d9396 -size 8619 +oid sha256:6c8b22e84568896085079b948cb41a5f2440fa9b67b6130412762911f838490d +size 9304 diff --git a/Content/Legumix/Weapon/BP_WeaponManager.uasset b/Content/Legumix/Weapon/BP_WeaponManager.uasset new file mode 100644 index 0000000..0d3685c --- /dev/null +++ b/Content/Legumix/Weapon/BP_WeaponManager.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76dde9bd31fe7b9c92b2537215bc3a2b4fc67a3ea9fd83ccf9faa93d1af0d962 +size 15175 diff --git a/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset b/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset deleted file mode 100644 index d90bc05..0000000 --- a/Content/Legumix/Weapon/BP_WeaponManagerComponent.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:792b2f2ab7e6dc725e9fbb7d949aa7d8ac23483a5ce1508c109ad5973dd1c474 -size 14988 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 135d138..517a912 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -2,6 +2,8 @@ #include "Player/LMPlayer.h" + +#include "Camera/CameraComponent.h" #include "Weapon/LMAmmo.h" #include "Weapon/LMWeaponManager.h" @@ -9,13 +11,14 @@ ALMPlayer::ALMPlayer() { // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; - - WeaponManager = CreateDefaultSubobject(TEXT("Weapon Manager")); + + Camera = CreateDefaultSubobject(TEXT("Camera")); + Camera->SetupAttachment(RootComponent); + Camera->bUsePawnControlRotation = true; + Camera->SetRelativeLocation(FVector(20, 0, 90)); WeaponSkeletalMeshComponent = CreateDefaultSubobject(TEXT("Weapon Mesh")); - WeaponSkeletalMeshComponent->SetupAttachment(GetMesh()); - - WeaponManager->SetWeaponMeshComponent(WeaponSkeletalMeshComponent); + WeaponSkeletalMeshComponent->SetupAttachment(Camera); } // Called when the game starts or when spawned @@ -34,6 +37,19 @@ void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) } } +void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) +{ + UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) + if (!Manager) + { + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Red, TEXT("No Weapon Manager was given to the player !")); + return; + } + + WeaponManager = Manager; + WeaponManager->Initialize(WeaponSkeletalMeshComponent); +} + // Called every frame void ALMPlayer::Tick(float DeltaTime) { diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 27bed09..47a8bba 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -26,6 +26,7 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(LookAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Look); Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); + Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); } } @@ -57,3 +58,9 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue) { LegumixPlayer->GetWeaponManager()->Reload(); } + +void ALMPlayerController::Scroll(const FInputActionValue& InputValue) +{ + const float ScrollAmount = InputValue.Get(); + LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount); +} diff --git a/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp b/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp index 9cc48fa..89e6651 100644 --- a/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp +++ b/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp @@ -3,7 +3,7 @@ #include "Weapon\LMBazoucorn.h" -void ULMWeapon::Fire() +void UBazoucorn::Fire() { //Fire like a Bazoucorn } diff --git a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp index 21d995a..ed3587e 100644 --- a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp +++ b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp @@ -3,7 +3,7 @@ #include "Weapon/LMRadivolver.h" -void ULMWeapon::Fire() +void ULMRadivolver::Fire() { //Fire like a Radivolver } diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp index 16d8a30..375c413 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -5,6 +5,8 @@ void ULMWeapon::Initialize() { WeaponDataStructure =* WeaponRow.GetRow(TEXT("")); + + //Get FVector de la position de l'arme } bool ULMWeapon::HasAmmoInClip() diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index f54eb11..e955737 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -14,6 +14,11 @@ ULMWeaponManager::ULMWeaponManager() void ULMWeaponManager::BeginPlay() { Super::BeginPlay(); +} + +void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) +{ + SetWeaponMeshComponent(Mesh); for (auto Weapon : StartingWeapons) { @@ -21,19 +26,18 @@ void ULMWeaponManager::BeginPlay() { ULMWeapon* Instance = NewObject(this, Weapon); Weapons.Add(Instance); - - // TODO - // Instance->Initialize(); + + // Instance->Initialize(Mesh->GetRelativeLocation()); } } - + if (!Weapons.IsEmpty()) { SetWeapon(CurrentWeaponIndex); } } -void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount) +void ULMWeaponManager::AddAmmoType(EAmmoType AmmoType, int AmmoCount) { FString Debug = FString::Printf(TEXT("Adding %i ammo of type %i"), AmmoCount, AmmoType); GEngine->AddOnScreenDebugMessage(1, 1.f, FColor::Cyan, Debug); @@ -41,33 +45,46 @@ void ULMWeaponManager::AddAmmoType(uint8 AmmoType, int AmmoCount) for (const auto Weapon : Weapons) { // TODO : match weapon ammo type - if (!Weapon) + if (Weapon->WeaponDataStructure.AmmoType == AmmoType) continue; - // TODO - // Weapon.AddAmmo(AmmoCount); + Weapon->AddAmmo(AmmoCount); } } void ULMWeaponManager::Fire() { - // ULMWeapon* Weapon = GetCurrentWeapon(); + ULMWeapon* Weapon = GetCurrentWeapon(); GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire"); - // TODO + Weapon->Fire(); } void ULMWeaponManager::Reload() { GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading"); - - // ULMWeapon* Weapon = GetCurrentWeapon(); - // TODO - // Weapon->Reload(); + ULMWeapon* Weapon = GetCurrentWeapon(); + Weapon->Reload(); } -void ULMWeaponManager::SetWeapon(int Index) +void ULMWeaponManager::SwitchWeapon(const int Direction) +{ + const int NewIndex = Direction + CurrentWeaponIndex; + if (NewIndex >= 0 && NewIndex < Weapons.Num()) + { + SetWeapon(NewIndex); + } + else + { + if (NewIndex < 0) + SetWeapon(Weapons.Num() - 1); + else + SetWeapon(0); + } +} + +void ULMWeaponManager::SetWeapon(const int Index) { if (Index < 0 || Index >= Weapons.Num()) { @@ -79,8 +96,9 @@ void ULMWeaponManager::SetWeapon(int Index) if (WeaponMeshComponent) { - // TODO - // WeaponMeshComponent->SetSkeletalMesh() + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh"); + + WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon); } } diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 55bf134..4027c1b 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -6,6 +6,7 @@ #include "GameFramework/Character.h" #include "LMPlayer.generated.h" +class UCameraComponent; class ULMWeaponManager; class ALMAmmo; @@ -32,10 +33,16 @@ public: UFUNCTION(BlueprintCallable) ULMWeaponManager* GetWeaponManager() { return WeaponManager; } + UFUNCTION(BlueprintCallable) + void SetWeaponManager(ULMWeaponManager* Manager); + private: - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) TObjectPtr WeaponManager; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) TObjectPtr WeaponSkeletalMeshComponent; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Legumix", meta = (AllowPrivateAccess = true)) + TObjectPtr Camera; }; diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index cd05666..dcf4e56 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -41,6 +41,9 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr ReloadAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr ScrollAction; UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; @@ -51,4 +54,5 @@ private: void Look(const FInputActionValue& InputValue); void Fire(const FInputActionValue& InputValue); void Reload(const FInputActionValue& InputValue); + void Scroll(const FInputActionValue& InputValue); }; diff --git a/Source/LegumeMix/Public/Weapon/LMBazoucorn.h b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h index 6d413c1..f869717 100644 --- a/Source/LegumeMix/Public/Weapon/LMBazoucorn.h +++ b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h @@ -13,4 +13,5 @@ UCLASS(BlueprintType, Blueprintable) class LEGUMEMIX_API UBazoucorn : public ULMWeapon { GENERATED_BODY() + virtual void Fire() override; }; diff --git a/Source/LegumeMix/Public/Weapon/LMRadivolver.h b/Source/LegumeMix/Public/Weapon/LMRadivolver.h index 3261c68..b8879f6 100644 --- a/Source/LegumeMix/Public/Weapon/LMRadivolver.h +++ b/Source/LegumeMix/Public/Weapon/LMRadivolver.h @@ -13,4 +13,5 @@ UCLASS(BlueprintType, Blueprintable) class LEGUMEMIX_API ULMRadivolver : public ULMWeapon { GENERATED_BODY() + virtual void Fire() override; }; diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h index d9c2e60..6e473b0 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeapon.h +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -26,7 +26,7 @@ public: void Initialize(); - void Fire(); + virtual void Fire(); UFUNCTION(BlueprintCallable) void Reload(); //Reload current clip to max ammo in clip diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h index df020c7..033939a 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -15,7 +15,7 @@ struct FLMWeaponDataStructure : public FTableRowBase int MaxClipAmmo; // Max ammo in clip UPROPERTY(EditAnywhere, BlueprintReadWrite) - TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene + TObjectPtr MeshWeapon; //Mesh of the weapon display in the scene UPROPERTY(EditAnywhere, BlueprintReadWrite) EAmmoType AmmoType; //Type of ammo, which ammo this weapon is using diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h index 7a5caaf..7103bfb 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -3,6 +3,7 @@ #pragma once #include "CoreMinimal.h" +#include "LMAmmo.h" #include "Components/ActorComponent.h" #include "LMWeaponManager.generated.h" @@ -30,13 +31,16 @@ public: void SetWeapon(int Index); UFUNCTION(BlueprintCallable, Category="Legumix") - void AddAmmoType(uint8 AmmoType, int AmmoCount); + void AddAmmoType(EAmmoType AmmoType, int AmmoCount); UFUNCTION(BlueprintCallable, Category="Legumix") void Fire(); UFUNCTION(BlueprintCallable, Category="Legumix") void Reload(); + void SwitchWeapon(int Direction); + + void Initialize(USkeletalMeshComponent* Mesh); protected: virtual void BeginPlay() override; From 7bcaa4c17a1966f9460b75aa8499afba122c46ce Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Tue, 21 Jan 2025 18:21:26 +0100 Subject: [PATCH 12/15] Updated ammo in weapon stock adding --- Source/LegumeMix/Private/Player/LMPlayer.cpp | 2 +- Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 517a912..b3b65f5 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -35,6 +35,7 @@ void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) FString AmmoAmount = FString::Printf(TEXT("Quantité de munition : %i"), Ammo->GetAmmoAmount()); GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Red, AmmoAmount); } + WeaponManager->AddAmmoType(Ammo->GetAmmoType(), Ammo->GetAmmoAmount()); } void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) @@ -54,7 +55,6 @@ void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) void ALMPlayer::Tick(float DeltaTime) { Super::Tick(DeltaTime); - } // Called to bind functionality to input diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index e955737..98613b2 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -44,8 +44,7 @@ void ULMWeaponManager::AddAmmoType(EAmmoType AmmoType, int AmmoCount) for (const auto Weapon : Weapons) { - // TODO : match weapon ammo type - if (Weapon->WeaponDataStructure.AmmoType == AmmoType) + if (Weapon->WeaponDataStructure.AmmoType != AmmoType) continue; Weapon->AddAmmo(AmmoCount); From de089e1f2fa24237824add7c6fcc986d8f231d7c Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Tue, 21 Jan 2025 19:19:18 +0100 Subject: [PATCH 13/15] Update initialize weapon mesh --- Source/LegumeMix/Private/Weapon/LMWeapon.cpp | 3 ++- Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp | 2 +- Source/LegumeMix/Public/Weapon/LMWeapon.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp index 375c413..e18b368 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -2,11 +2,12 @@ #include "Weapon/LMWeaponDataStructure.h" -void ULMWeapon::Initialize() +void ULMWeapon::Initialize(FVector MeshLocation) { WeaponDataStructure =* WeaponRow.GetRow(TEXT("")); //Get FVector de la position de l'arme + } bool ULMWeapon::HasAmmoInClip() diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp index 98613b2..fcea7aa 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -27,7 +27,7 @@ void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) ULMWeapon* Instance = NewObject(this, Weapon); Weapons.Add(Instance); - // Instance->Initialize(Mesh->GetRelativeLocation()); + Instance->Initialize(Mesh->GetRelativeLocation()); } } diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h index 6e473b0..9736dff 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeapon.h +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -24,7 +24,7 @@ public: UPROPERTY() int CurrentAmmoInInventory; - void Initialize(); + void Initialize(FVector MeshLocation); virtual void Fire(); From 156becc36c651587d2ab8cd9e3b94fbb548b5417 Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Tue, 21 Jan 2025 19:19:43 +0100 Subject: [PATCH 14/15] Change project config to build game --- Config/DefaultEngine.ini | 2 +- LegumeMix.uproject | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 8418e17..666bf2f 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,7 +1,7 @@ [/Script/EngineSettings.GameMapsSettings] -GameDefaultMap=/Engine/Maps/Templates/OpenWorld +GameDefaultMap=/Engine/Maps/Templates/OpenWorld.OpenWorld GlobalDefaultGameMode=/Game/Legumix/BP_GameMode.BP_GameMode_C [/Script/Engine.RendererSettings] diff --git a/LegumeMix.uproject b/LegumeMix.uproject index 2356227..c71aa05 100644 --- a/LegumeMix.uproject +++ b/LegumeMix.uproject @@ -21,5 +21,8 @@ "Editor" ] } + ], + "TargetPlatforms": [ + "Windows" ] } \ No newline at end of file From 9d6b10b106342f6d988e9d34c5a76fb3c64527d4 Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Wed, 22 Jan 2025 12:04:38 +0100 Subject: [PATCH 15/15] fix : Retrieve an inused include --- Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h index 033939a..3225a52 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -1,5 +1,5 @@ #pragma once -#include "AnimationBlueprintEditorSettings.h" + #include "LMAmmo.h" #include "LMWeaponDataStructure.generated.h"