// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MagazineActor.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FAMMO_REPACK);
UCLASS()
class OPENCONFLICT_API AMagazineActor : public AActor
{
	GENERATED_BODY()
	
	/*UPROPERTY and UFUNCTION declarations*/
private:
	/*Properties*/
	UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
	int MAX_COUNT;
	UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
	int CurrentCount;
	UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
	bool ActiveMag = false;
	UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
	float RepackDelay = 0.5f;


	/*Functions*/

protected:
	/*Properties*/

	/*Functions*/

public:
	/*Properties*/
	UPROPERTY(BlueprintAssignable)
	FAMMO_REPACK AMMO_REPACK;

	/*Functions*/
	UFUNCTION(BlueprintImplementableEvent)
	void EmptyMagEvent();

	/*C++ only declarations*/
private:
	/*Properties*/

	/*Functions*/
	void PackMag();

protected:
	/*Properties*/
	FTimerHandle RepackTimer;

	/*Functions*/
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	

public:
	/*Properties*/
	bool hasReserveAmmo = true;
	

	/*Functions*/
	// Sets default values for this actor's properties
	AMagazineActor();
	AMagazineActor(int MaxCount);

	// Called every frame
	virtual void Tick(float DeltaTime) override;

	void StripRound();
	void SetAmmoValues(int MaxCount);
};
