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;