D1/Source/D1/Components/CombatComponent.cpp

56 lines
1.1 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "Components/CombatComponent.h"
#include "Actor/BaseWeapon.h"
#include "Definitions/GameEnums.h"
// Sets default values for this component's properties
UCombatComponent::UCombatComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
void UCombatComponent::SetCombatEnabled(bool bInputCombat)
{
bCombatEnabled = bInputCombat;
OnCombatToggled.Broadcast(bInputCombat);
}
void UCombatComponent::ResetAttack()
{
AttackCount = 0;
bIsAttackSaved = false;
}
void UCombatComponent::SetMainWeapon(ABaseWeapon* NewWeapon)
{
if (IsValid(MainWeapon))
{
MainWeapon->OnUnequipped();
MainWeapon->Destroy();
}
MainWeapon = NewWeapon;
}
ABaseWeapon* UCombatComponent::GetMainWeapon() const
{
return MainWeapon;
}
void UCombatComponent::SetBlockingState(bool enableBlocking)
{
if(enableBlocking != bIsBlocking)
{
bIsBlocking = enableBlocking;
OnBlockingSet.Broadcast(bIsBlocking);
}
}