diff --git a/Binaries/Win64/LegumeMixEditor.target b/Binaries/Win64/LegumeMixEditor.target index a7ca2f1..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" @@ -4804,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" @@ -30542,10 +30546,6 @@ { "Path": "$(EngineDir)/Plugins/XGEController/XGEController.uplugin", "Type": "UFS" - }, - { - "Path": "$(ProjectDir)/LegumeMix.uproject", - "Type": "UFS" } ], "BuildPlugins": [ diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.exp b/Binaries/Win64/UnrealEditor-LegumeMix.exp index 28b9036..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:41802b8b537a6e0b34f466dd58f0dbb46aedcaaf28e05beacb1d6ca529a0cad3 -size 11548 +oid sha256:539ff602aa1fa5ccacb50b1125dbb86199c549e0b24a8a7da2c9d4cb814b6f48 +size 34050 diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.pdb b/Binaries/Win64/UnrealEditor-LegumeMix.pdb index fa2722f..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:fae58fec73ac589dda932e97a46512579fbd2a0c6d34b3ce1be250f0b29def6c -size 60215296 +oid sha256:bfcad27449bf4813b3c20458b70d67afde0d17f6abcb3d968291708b64a76bd6 +size 60657664 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/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/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset index c47c3e8..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:cc27945649c2736f7fdeebd935e9aabc55e7d7f2d54694b080d12530bf6224e2 -size 34950 +oid sha256:a1b36ac7333d2d6b72f26ce3e384ba1dcee67208a17231d67c021037a7e9f4f0 +size 42647 diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 0621c64..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:405ca21288778bca44cf90e4b0f221cbd80ccad8b3e2d0b5b5828959e0c8f4d8 -size 20808 +oid sha256:7651a3b0a3adbaa6cc2aa4907c29a4a112d232a215f9b9511f30f258f4ed83e8 +size 21387 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/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 6b9f57c..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:51dde808b98d4b04583ab19bf9db04cc2c383974ccb6069672bb8cd2a3465c11 -size 7263 +oid sha256:6c8b22e84568896085079b948cb41a5f2440fa9b67b6130412762911f838490d +size 9304 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/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/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/DT_WeaponData.uasset b/Content/Legumix/Weapon/DT_WeaponData.uasset new file mode 100644 index 0000000..a6daba6 --- /dev/null +++ b/Content/Legumix/Weapon/DT_WeaponData.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4e50014771a56604730976892111daf8f7eceaaf986ef12884bc79b1b54bd5a +size 2838 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 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/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 2bcea73..b3b65f5 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -3,12 +3,22 @@ #include "Player/LMPlayer.h" -// Sets default values +#include "Camera/CameraComponent.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; + Camera = CreateDefaultSubobject(TEXT("Camera")); + Camera->SetupAttachment(RootComponent); + Camera->bUsePawnControlRotation = true; + Camera->SetRelativeLocation(FVector(20, 0, 90)); + + WeaponSkeletalMeshComponent = CreateDefaultSubobject(TEXT("Weapon Mesh")); + WeaponSkeletalMeshComponent->SetupAttachment(Camera); } // Called when the game starts or when spawned @@ -18,11 +28,33 @@ void ALMPlayer::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); + } + WeaponManager->AddAmmoType(Ammo->GetAmmoType(), Ammo->GetAmmoAmount()); +} + +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) { Super::Tick(DeltaTime); - } // Called to bind functionality to input diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 2ec8be3..47a8bba 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -5,22 +5,29 @@ #include "EnhancedInputSubsystems.h" #include "EnhancedInputComponent.h" #include "GameFramework/Character.h" +#include "Player/LMPlayer.h" +#include "Weapon/LMWeaponManager.h" void ALMPlayerController::BeginPlay() { Super::BeginPlay(); EnhancedInputSubsystem = GetLocalPlayer()->GetSubsystem(); EnhancedInputSubsystem->AddMappingContext(DefaultMappingContext, 0); - LegumixPlayer = Cast(GetPawn()); + LegumixPlayer = Cast(GetPawn()); } 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); + 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); + Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); + } } void ALMPlayerController::Move(const FInputActionValue& InputValue) @@ -40,4 +47,20 @@ 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(); +} + +void ALMPlayerController::Scroll(const FInputActionValue& InputValue) +{ + const float ScrollAmount = InputValue.Get(); + LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount); +} 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/Private/Weapon/LMBazoucorn.cpp b/Source/LegumeMix/Private/Weapon/LMBazoucorn.cpp new file mode 100644 index 0000000..89e6651 --- /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 UBazoucorn::Fire() +{ + //Fire like a Bazoucorn +} diff --git a/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp new file mode 100644 index 0000000..ed3587e --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMRadivolver.cpp @@ -0,0 +1,10 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Weapon/LMRadivolver.h" + +void ULMRadivolver::Fire() +{ + //Fire like a Radivolver +} + diff --git a/Source/LegumeMix/Private/Weapon/LMWeapon.cpp b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp new file mode 100644 index 0000000..e18b368 --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMWeapon.cpp @@ -0,0 +1,59 @@ +#include "Weapon/LMWeapon.h" + +#include "Weapon/LMWeaponDataStructure.h" + +void ULMWeapon::Initialize(FVector MeshLocation) +{ + WeaponDataStructure =* WeaponRow.GetRow(TEXT("")); + + //Get FVector de la position de l'arme + +} + +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(); + 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/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/Private/Weapon/LMWeaponManager.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp new file mode 100644 index 0000000..fcea7aa --- /dev/null +++ b/Source/LegumeMix/Private/Weapon/LMWeaponManager.cpp @@ -0,0 +1,103 @@ +// 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(); +} + +void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh) +{ + SetWeaponMeshComponent(Mesh); + + for (auto Weapon : StartingWeapons) + { + if (Weapon) + { + ULMWeapon* Instance = NewObject(this, Weapon); + Weapons.Add(Instance); + + Instance->Initialize(Mesh->GetRelativeLocation()); + } + } + + if (!Weapons.IsEmpty()) + { + SetWeapon(CurrentWeaponIndex); + } +} + +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); + + for (const auto Weapon : Weapons) + { + if (Weapon->WeaponDataStructure.AmmoType != AmmoType) + continue; + + Weapon->AddAmmo(AmmoCount); + } +} + +void ULMWeaponManager::Fire() +{ + ULMWeapon* Weapon = GetCurrentWeapon(); + + GEngine->AddOnScreenDebugMessage(2, 1.f, FColor::Cyan, "Fire"); + Weapon->Fire(); +} + +void ULMWeaponManager::Reload() +{ + GEngine->AddOnScreenDebugMessage(3, 1.f, FColor::Cyan, "Reloading"); + + ULMWeapon* Weapon = GetCurrentWeapon(); + Weapon->Reload(); +} + +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()) + { + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Invalid Weapon Index"); + return; + } + + CurrentWeaponIndex = Index; + + if (WeaponMeshComponent) + { + GEngine->AddOnScreenDebugMessage(INDEX_NONE, 5, FColor::Red, "Has Mesh"); + + WeaponMeshComponent->SetSkeletalMeshAsset(GetCurrentWeapon()->WeaponDataStructure.MeshWeapon); + } +} + 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() + +}; diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index effd765..4027c1b 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -6,6 +6,11 @@ #include "GameFramework/Character.h" #include "LMPlayer.generated.h" +class UCameraComponent; +class ULMWeaponManager; + +class ALMAmmo; + UCLASS() class LEGUMEMIX_API ALMPlayer : public ACharacter { @@ -14,16 +19,30 @@ 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() + void PickUpAmmo(ALMAmmo* Ammo); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: - // Called every frame - virtual void Tick(float DeltaTime) override; + UFUNCTION(BlueprintCallable) + ULMWeaponManager* GetWeaponManager() { return WeaponManager; } - // Called to bind functionality to input - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + UFUNCTION(BlueprintCallable) + void SetWeaponManager(ULMWeaponManager* Manager); +private: + 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 292022c..dcf4e56 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; + /** * */ @@ -34,11 +36,23 @@ 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(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr ScrollAction; + UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) - TObjectPtr LegumixPlayer; + TObjectPtr LegumixPlayer; virtual void SetupInputComponent() override; 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); + void Scroll(const FInputActionValue& InputValue); }; 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); +}; diff --git a/Source/LegumeMix/Public/Weapon/LMBazoucorn.h b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h new file mode 100644 index 0000000..f869717 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMBazoucorn.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "LMWeapon.h" +#include "LMBazoucorn.generated.h" + +/** + * + */ +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 new file mode 100644 index 0000000..b8879f6 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMRadivolver.h @@ -0,0 +1,17 @@ +// 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() + virtual void Fire() override; +}; diff --git a/Source/LegumeMix/Public/Weapon/LMWeapon.h b/Source/LegumeMix/Public/Weapon/LMWeapon.h new file mode 100644 index 0000000..9736dff --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeapon.h @@ -0,0 +1,40 @@ +#pragma once + +#include "CoreMinimal.h" +#include "LMWeaponDataStructure.h" +#include "LMWeapon.generated.h" + +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(FVector MeshLocation); + + virtual void Fire(); + + UFUNCTION(BlueprintCallable) + void Reload(); //Reload current clip to max ammo in clip + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void OnReload(); //To call in blueprint for design utilities + + void AddAmmo(int AmountOfAmmoToGet); //Add ammo in inventory + + 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 new file mode 100644 index 0000000..3225a52 --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeaponDataStructure.h @@ -0,0 +1,25 @@ +#pragma once + +#include "LMAmmo.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) + EAmmoType AmmoType; //Type of ammo, which ammo this weapon is using + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TObjectPtr AnimationBluePrint; //The animation blueprint to animate the mesh +}; diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponManager.h b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h new file mode 100644 index 0000000..7103bfb --- /dev/null +++ b/Source/LegumeMix/Public/Weapon/LMWeaponManager.h @@ -0,0 +1,61 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "LMAmmo.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); + + UFUNCTION(BlueprintCallable, Category="Legumix") + 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; + +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; +};