63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "MagazineActor.h"
|
|
|
|
#include "OpenConflict/PlayerCharacter/Components/DDIHealth.h"
|
|
|
|
// Sets default values
|
|
AMagazineActor::AMagazineActor()
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
bReplicates = true;
|
|
|
|
|
|
}
|
|
// Called when the game starts or when spawned
|
|
void AMagazineActor::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
}
|
|
|
|
// Called every frame
|
|
void AMagazineActor::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
if (!ActiveMag && CurrentCount < MAX_COUNT )
|
|
{
|
|
GetWorld()->GetTimerManager().SetTimer(RepackTimer, this, &AMagazineActor::PackMag, RepackDelay, true, RepackDelay);
|
|
}
|
|
|
|
}
|
|
|
|
void AMagazineActor::PackMag()
|
|
{
|
|
if (hasReserveAmmo)
|
|
{
|
|
CurrentCount += 1;
|
|
AMMO_REPACK.Broadcast();
|
|
}
|
|
|
|
if (CurrentCount >= MAX_COUNT)
|
|
{
|
|
CurrentCount = MAX_COUNT;
|
|
GetWorld()->GetTimerManager().ClearTimer(RepackTimer);
|
|
}
|
|
}
|
|
|
|
void AMagazineActor::StripRound()
|
|
{
|
|
CurrentCount -= 1;
|
|
if (CurrentCount <= 0)
|
|
{
|
|
CurrentCount = 0;
|
|
}
|
|
}
|
|
|
|
void AMagazineActor::SetAmmoValues(int MaxCount)
|
|
{
|
|
MAX_COUNT = MaxCount;
|
|
CurrentCount = MAX_COUNT;
|
|
} |