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() void ALMPlayer::BeginPlay()
{ {
Super::BeginPlay(); Super::BeginPlay();
WeaponManager->WeaponFired.AddUniqueDynamic(this, &ALMPlayer::WeaponFired);
WeaponManager->WeaponSwitched.AddUniqueDynamic(this, &ALMPlayer::WeaponSwitched);
} }
void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo) void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo)
@ -76,6 +77,9 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
FVector EndLocation; FVector EndLocation;
FVector ShotVector; FVector ShotVector;
FHitResult OutHit = FHitResult(); FHitResult OutHit = FHitResult();
bool HitSomething = false;
OnFire();
DrawDebugLine(GetWorld(), Settings.Origin, Settings.Origin + (Settings.Direction * Settings.MaxDistance), FColor::Blue, false, 2.f); 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)) if (ULMHitBox* HitBox = Cast<ULMHitBox>(OutHit.Component))
{ {
UE_LOG(LogTemp, Warning, TEXT("Hit Hitbox")); UE_LOG(LogTemp, Warning, TEXT("Hit Hitbox"));
HitSomething = true;
HitBox->OnHit(Settings); HitBox->OnHit(Settings);
} }
} }
if (HitSomething)
{
OnEnnemyHit();
}
} }
FVector ALMPlayer::GetWeaponFiringOrigin() const FVector ALMPlayer::GetWeaponFiringOrigin() const
@ -114,14 +124,3 @@ FVector ALMPlayer::GetWeaponFiringOrigin() const
FVector ALMPlayer::GetAimVector() const { return Camera->GetForwardVector(); } 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 // TODO: Use Animations
OnDefaultReload(); OnDefaultReload();
GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay); GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay);
Player->OnReload();
return true; return true;
} }

View File

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

View File

@ -21,8 +21,6 @@ class LEGUMEMIX_API ALMPlayer : public ACharacter
public: public:
// Sets default values for this character's properties // Sets default values for this character's properties
ALMPlayer(); ALMPlayer();
virtual void Tick(float DeltaTime) override;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void PickUpAmmo(ALMAmmo* Ammo); void PickUpAmmo(ALMAmmo* Ammo);
@ -67,6 +65,23 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
FVector GetAimVector() const; 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: private:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
TObjectPtr<ULMWeaponManager> WeaponManager; TObjectPtr<ULMWeaponManager> WeaponManager;

View File

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