97 lines
3.0 KiB
C++
97 lines
3.0 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Ammo/LMAmmoData.h"
|
|
#include "Components/ActorComponent.h"
|
|
#include "LMWeaponManager.generated.h"
|
|
|
|
|
|
class ALMWeaponBase;
|
|
class ULMWeapon;
|
|
|
|
UCLASS(Blueprintable, BlueprintType, ClassGroup=Legumix, meta=(BlueprintSpawnableComponent))
|
|
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; }
|
|
|
|
public:
|
|
/**
|
|
* Get the Weapon currently equipped.
|
|
* @return The Current Weapon.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
ALMWeaponBase* GetCurrentWeapon() { return Weapons[CurrentWeaponIndex]; }
|
|
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
void SetWeapon(int Index);
|
|
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
bool AddAmmoType(EAmmoType AmmoType, int AmmoCount);
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
int GetAmmoCount(EAmmoType AmmoType);
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
FLMAmmoData& GetAmmoData(EAmmoType AmmoType);
|
|
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
void Fire();
|
|
|
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
|
void Reload();
|
|
void SwitchWeapon(int Direction);
|
|
|
|
void Initialize(USkeletalMeshComponent* Mesh);
|
|
|
|
UFUNCTION(BlueprintCallable, Category="Legumix|Ammo")
|
|
void SetupAmmoData();
|
|
UFUNCTION(BlueprintCallable, Category="Legumix|Ammo")
|
|
int RemoveAmmo(EAmmoType Ammo, int Count);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void CreateTracer(EAmmoType Ammo, FVector EndLocation, FRotator Direction);
|
|
|
|
TMap<EAmmoType, FLMAmmoData> GetAmmoDataMap() { return AmmoData; }
|
|
|
|
public:
|
|
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix)
|
|
FOnWeaponFiredSignature WeaponFired;
|
|
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category=Legumix)
|
|
FOnWeaponFiredSignature WeaponSwitched;
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
|
|
#if WITH_EDITOR
|
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
#endif
|
|
|
|
private:
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = "true"))
|
|
TObjectPtr<USkeletalMeshComponent> ArmsMesh;
|
|
|
|
private:
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Ammo", meta=(AllowPrivateAccess=true))
|
|
TObjectPtr<UDataTable> AmmoDataTable;
|
|
|
|
/** The weapons the player starts with. */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
|
TArray<TSubclassOf<ALMWeaponBase>> StartingWeapons;
|
|
|
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true))
|
|
TArray<TObjectPtr<ALMWeaponBase>> Weapons;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
|
int CurrentWeaponIndex = 0;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Ammo", meta=(AllowPrivateAccess=true))
|
|
TMap<EAmmoType, FLMAmmoData> AmmoData;
|
|
};
|