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

#pragma once

#include "CoreMinimal.h"
#include "Camera/CameraComponent.h"
#include "Components/DDIHealth.h"
#include "GameFramework/Character.h"
#include "Net/UnrealNetwork.h"
#include "DDICharacter.generated.h"


UCLASS()
class OPENCONFLICT_API ADDICharacter : public ACharacter
{
	GENERATED_BODY()
	/*UPROPERTY and UFUNCTION declarations*/
private:
	/*Properties*/

	/*Functions*/

protected:
	/*Properties*/

	/*Functions*/
	UFUNCTION(BlueprintImplementableEvent, Category = "Events")
	void OnDamageTaken();

public:
	/*Properties*/
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera")
	UCameraComponent* CameraComponent;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health", ReplicatedUsing=OnRep_Health)
	UDDIHealth* HealthComponent;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Projectile")
	TSubclassOf<AActor> ProjectileClass;

	/*Functions*/
	UFUNCTION()
	void OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
	
	UFUNCTION()
	void TakeDamage(int Damage);
	
	UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
	void Server_SpawnProjectile();

	UFUNCTION(Client, Reliable, WithValidation, BlueprintCallable)
	void Client_CharacterHit();

	UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable)
	void Server_CharacterHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

	UFUNCTION()
	void OnRep_Health();
	
	/*C++ only declarations*/
private:
	/*Properties*/

	/*Functions*/

protected:
	/*Properties*/

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

public:
	/*Properties*/

	/*Functions*/
	// Sets default values for this character's properties
	ADDICharacter();
	// Called every frame
	virtual void Tick(float DeltaTime) override;


};
