Merge remote-tracking branch 'origin/master'

This commit is contained in:
Emilie Schott 2025-01-24 17:01:45 +01:00
commit 8265363b28
9 changed files with 52 additions and 24 deletions

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -31,7 +31,8 @@ ALMPlayer::ALMPlayer()
void ALMPlayer::BeginPlay()
{
Super::BeginPlay();
WeaponManager->WeaponFired.AddUniqueDynamic(this, &ALMPlayer::WeaponFired);
WeaponManager->WeaponSwitched.AddUniqueDynamic(this, &ALMPlayer::WeaponSwitched);
}
void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo)
@ -76,6 +77,9 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
FVector EndLocation;
FVector ShotVector;
FHitResult OutHit = FHitResult();
bool HitSomething = false;
OnFire();
DrawDebugLine(GetWorld(), Settings.Origin, Settings.Origin + (Settings.Direction * Settings.MaxDistance), FColor::Blue, false, 2.f);
@ -97,9 +101,15 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
if (ULMHitBox* HitBox = Cast<ULMHitBox>(OutHit.Component))
{
UE_LOG(LogTemp, Warning, TEXT("Hit Hitbox"));
HitSomething = true;
HitBox->OnHit(Settings);
}
}
if (HitSomething)
{
OnEnnemyHit();
}
}
FVector ALMPlayer::GetWeaponFiringOrigin() const
@ -114,14 +124,3 @@ FVector ALMPlayer::GetWeaponFiringOrigin() const
FVector ALMPlayer::GetAimVector() const { return Camera->GetForwardVector(); }
void ALMPlayer::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}

View File

@ -94,6 +94,7 @@ bool ALMWeaponBase::DefaultReload()
// TODO: Use Animations
OnDefaultReload();
GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay);
Player->OnReload();
return true;
}

View File

@ -120,7 +120,10 @@ void ULMWeaponManager::Fire()
ALMWeaponBase* Weapon = GetCurrentWeapon();
if (Weapon->State == EWeaponState::EWS_Idle)
{
Weapon->PrimaryFire();
WeaponFired.Broadcast();
}
}
void ULMWeaponManager::Reload()
@ -128,7 +131,9 @@ void ULMWeaponManager::Reload()
ALMWeaponBase* Weapon = GetCurrentWeapon();
if (Weapon->State == EWeaponState::EWS_Idle)
{
Weapon->Reload();
}
}
void ULMWeaponManager::SwitchWeapon(const int Direction)
@ -160,5 +165,6 @@ void ULMWeaponManager::SetWeapon(const int Index)
GetCurrentWeapon()->SetActorHiddenInGame(false);
GetCurrentWeapon()->OnEquip();
WeaponSwitched.Broadcast();
}

View File

@ -21,8 +21,6 @@ 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(BlueprintCallable)
void PickUpAmmo(ALMAmmo* Ammo);
@ -67,6 +65,23 @@ public:
UFUNCTION(BlueprintCallable)
FVector GetAimVector() const;
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void WeaponFired();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void WeaponReloaded();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void WeaponSwitched();
UFUNCTION(BlueprintImplementableEvent)
void OnEnnemyHit();
UFUNCTION(BlueprintImplementableEvent, Category=Legumix)
void OnFire();
UFUNCTION(BlueprintImplementableEvent, Category=Legumix)
void OnReload();
private:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
TObjectPtr<ULMWeaponManager> WeaponManager;

View File

@ -16,6 +16,9 @@ class LEGUMEMIX_API ULMWeaponManager : public UActorComponent
{
GENERATED_BODY()
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWeaponFiredSignature);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWeaponSwitchedSignature);
public:
ULMWeaponManager();
void SetArmsMesh(USkeletalMeshComponent* Mesh) { ArmsMesh = Mesh; }
@ -50,6 +53,12 @@ public:
UFUNCTION(BlueprintCallable, Category="Legumix|Ammo")
int RemoveAmmo(EAmmoType Ammo, int Count);
public:
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix)
FOnWeaponFiredSignature WeaponFired;
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix)
FOnWeaponFiredSignature WeaponSwitched;
protected:
virtual void BeginPlay() override;
// virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
@ -74,6 +83,4 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Ammo", meta=(AllowPrivateAccess=true))
TMap<EAmmoType, FLMAmmoData> AmmoData;
};