Merge remote-tracking branch 'origin/master'

This commit is contained in:
Emilie Schott 2025-03-12 12:50:00 +01:00
commit 0d8d83e0cf
10 changed files with 56 additions and 12 deletions

BIN
Content/Legumix/Player/BP_Play.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/Legumix/Player/Input/IA_Slide.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -116,11 +116,9 @@ bool ULMMovementComponent::CanCrouchInCurrentState() const
void ULMMovementComponent::UpdateCharacterStateBeforeMovement(float DeltaSeconds)
{
UE_LOG(LogTemp, Log, TEXT("Velocity %f vs %f"), Velocity.SizeSquared(), pow(SlideMinSpeed, 2))
if (MovementMode == EMovementMode::MOVE_Walking && Safe_bPrevWantsToCrouch)
{
FHitResult PotentialSlideSurface;
UE_LOG(LogTemp, Display, TEXT("PotentialSlideSurface"));
if (Velocity.SizeSquared() > pow(SlideMinSpeed, 2) && GetSlideSurface(PotentialSlideSurface))
{
EnterSlide();
@ -260,5 +258,16 @@ void ULMMovementComponent::CrouchPressed()
bWantsToCrouch = !bWantsToCrouch;
}
void ULMMovementComponent::CrouchToggle(bool Toggle)
{
bWantsToCrouch = Toggle;
}
#pragma endregion
bool ULMMovementComponent::CanAttemptJump() const
{
return IsJumpAllowed() &&
(IsMovingOnGround() || IsFalling()); // Falling included for double-jump and non-zero jump hold time, but validated by character.
}

View File

@ -105,6 +105,11 @@ int ALMPlayer::RemoveAmmo(const EAmmoType AmmoType, const int Count) const
return WeaponManager->RemoveAmmo(AmmoType, Count);
}
bool ALMPlayer::CanJumpInternal_Implementation() const
{
return JumpIsAllowedInternal();
}
void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager)
{
UE_LOG(LogTemp, Warning, TEXT("Set weapon manager"))

View File

@ -7,6 +7,7 @@
#include "LMUserSettings.h"
#include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h"
#include "Player/LMMovementComponent.h"
#include "Player/LMPlayer.h"
#include "Weapon/LMWeaponManager.h"
@ -35,6 +36,8 @@ void ALMPlayerController::SetupInputComponent()
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause);
Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput);
Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel);
}
}
@ -79,6 +82,19 @@ void ALMPlayerController::PauseInput(const FInputActionValue& InputValue)
TogglePause();
}
void ALMPlayerController::SlideInput(const FInputActionValue& InputValue)
{
LegumixPlayer->GetLegumixMovementComponent()->CrouchToggle(true);
}
void ALMPlayerController::SlideCancel(const FInputActionValue& InputValue)
{
if (LegumixPlayer->GetLegumixMovementComponent()->bWantsToCrouch)
{
LegumixPlayer->GetLegumixMovementComponent()->CrouchToggle(false);
}
}
void ALMPlayerController::TogglePause()
{
const bool bIsPaused = UGameplayStatics::IsGamePaused(GetWorld());

View File

@ -66,6 +66,11 @@ public:
UFUNCTION(BlueprintPure)
bool IsCustomMovementMode(ECustomMovementModes InCustomMovementMode) const;
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchPressed();
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchToggle(bool Toggle);
public:
UPROPERTY(Transient)
TObjectPtr<ALMPlayer> PlayerCharacterOwner;
@ -87,8 +92,6 @@ private:
void EnterSlide();
void ExitSlide();
void PhysSlide(float DeltaTime, int32 Iterations);
bool GetSlideSurface(FHitResult& Hit) const;
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchPressed();
bool GetSlideSurface(FHitResult& Hit) const;
virtual bool CanAttemptJump() const override;
};

View File

@ -53,6 +53,8 @@ public:
UFUNCTION(BlueprintCallable)
int RemoveAmmo(EAmmoType AmmoType, int Count) const;
virtual bool CanJumpInternal_Implementation() const override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;

View File

@ -47,9 +47,13 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<UInputAction> PauseAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<UInputAction> SlideAction;
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<ALMPlayer> LegumixPlayer;
virtual void SetupInputComponent() override;
void Move(const FInputActionValue& InputValue);
@ -59,6 +63,8 @@ private:
void Reload(const FInputActionValue& InputValue);
void Scroll(const FInputActionValue& InputValue);
void PauseInput(const FInputActionValue& InputValue);
void SlideInput(const FInputActionValue& InputValue);
void SlideCancel(const FInputActionValue& InputValue);
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0))
float Sensitivity = 1.0f;