// Project Sword & Gun Copyright © 2021 Kevin Poretti

#pragma once

#include "CoreMinimal.h"
#include "Weapons/SNGRangedWeaponBase.h"
#include "SNGInstantRangedWeapon.generated.h"

/**
 *	Base class for instant type ranged weapons.
 *
 *	An instant weapon is one where a line trace is performed in the same tick when the weapon is fired. If the line
 *	trace hits something damage is also applied immediately. 
 */
UCLASS()
class SWORDNGUN_API ASNGInstantRangedWeapon : public ASNGRangedWeaponBase
{
	GENERATED_BODY()

public:
	/** Sets default values for this actor's properties. */
	ASNGInstantRangedWeapon();
	
protected:
	/** The length/distance of the line trace */
	UPROPERTY(EditDefaultsOnly, Category="Properties")
	float Range;

	/**
	 *	Spawns and plays the tracer/smoke trailer effect.
	 *
	 *	The tracer will be spawned from this weapon's muzzle socket location and will stretch to the location provided
	 *	by the TraceEnd parameter.
	 *
	 *	@param TraceEnd where the tracer effect should end
	 */
	void PlayTracerEffect(FVector TraceEnd);

	/**
	 *	C++ implementation of the DoFire function, which is called in Fire if this weapon is actually able to be fired.
	 *
	 *	This function is overriden to do a single line trace.
	 */
	virtual void DoFire_Implementation() override;

	/**
	 *	Performs the actual line trace from the weapon owner's "eyes." For example, if the weapon owner is a player it
	 *	will perform a line trace from the center of the camera.
	 *
	 *	If something is hit this will apply damage if applicable and play appropriate effects.
	 *
	 *	@param SpreadOffset modifies the direction of the line trace by this rotation
	 */
	UFUNCTION(BlueprintCallable)
	void DoLineTrace(FRotator SpreadOffset = FRotator::ZeroRotator);
};

