102 lines
2.0 KiB
C++
102 lines
2.0 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "CombatGadget.h"
|
|
#include "ReconGadget.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "GadgetManager.generated.h"
|
|
|
|
UCLASS()
|
|
class ENDLESSVENDETTA_API AGadgetManager : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
AReconGadget* ReconGadget;
|
|
ACombatGadget* CombatGadget;
|
|
|
|
protected:
|
|
UPROPERTY(EditDefaultsOnly, Category = "Gadget")
|
|
TSubclassOf<AReconGadget> ReconClass;
|
|
UPROPERTY(EditDefaultsOnly, Category = "Gadget")
|
|
TSubclassOf<ACombatGadget> CombatClass;
|
|
|
|
// Called when the game starts or when spawned
|
|
virtual void BeginPlay() override;
|
|
|
|
public:
|
|
void SpawnGadgetsOnBeginPlay(USceneComponent* PlayersCameraComponent);
|
|
|
|
void SpawnGadget(TSubclassOf<AGadgetBase> GadgetClass, USceneComponent* PlayersCameraComponent);
|
|
|
|
// Sets default values for this actor's properties
|
|
AGadgetManager();
|
|
|
|
// Called every frame
|
|
virtual void Tick(float DeltaTime) override;
|
|
|
|
bool IsValidReconGadget()
|
|
{
|
|
return IsValid(ReconGadget);
|
|
}
|
|
|
|
bool IsValidCombatGadget()
|
|
{
|
|
return IsValid(CombatGadget);
|
|
}
|
|
|
|
void EquipRecon()
|
|
{
|
|
ReconGadget->Equip();
|
|
}
|
|
|
|
void EquipCombat()
|
|
{
|
|
CombatGadget->Equip();
|
|
}
|
|
|
|
bool IsReconEquipped()
|
|
{
|
|
return ReconGadget->Equipped;
|
|
}
|
|
|
|
bool IsCombatEquipped()
|
|
{
|
|
return CombatGadget->Equipped;
|
|
}
|
|
|
|
bool TryToUnequipRecon()
|
|
{
|
|
if (ReconGadget->Equipped) return ReconGadget->Unequip();
|
|
return false;
|
|
}
|
|
|
|
bool TryToUnequipCombat()
|
|
{
|
|
if (CombatGadget->Equipped) return CombatGadget->Unequip();
|
|
return false;
|
|
}
|
|
|
|
bool ReconInUse()
|
|
{
|
|
return IsValidReconGadget() && ReconGadget->IsInUse();
|
|
}
|
|
|
|
bool CombatInUse()
|
|
{
|
|
return IsValidCombatGadget() && CombatGadget->IsInUse();
|
|
}
|
|
|
|
bool ReconCantBeSwitchedOut()
|
|
{
|
|
return IsValidReconGadget() && (ReconGadget->IsInUse() || (ReconGadget->Equipped && !TryToUnequipRecon()));
|
|
}
|
|
|
|
bool CombatCantBeSwitchedOut()
|
|
{
|
|
return IsValidCombatGadget() && (CombatGadget->IsInUse() || (CombatGadget->Equipped && !TryToUnequipCombat()));
|
|
}
|
|
|
|
};
|