#pragma once

// -----------------------------------------------------------------------------
// triggerbot.h
// -----------------------------------------------------------------------------
// TriggerbotFeature: holding the trigger key (middle mouse button) with an
// enemy in the crosshair snaps the view to the selected aim bone, waits for
// the game to process the angle and then fires.
// -----------------------------------------------------------------------------

#include "../core/memory.h"
#include "../core/offsets.h"
#include "../sdk/entitylist.h"
#include "../sdk/localplayer.h"

namespace features {

// Crosshair-triggered auto fire running on its own thread.
class Triggerbot
{
public:
	// Binds the memory reader, offsets, entity list and local player.
	void Initialize(const core::ProcessMemory* memory, const core::GameOffsets* offsets,
		const sdk::EntityList* entities, const sdk::LocalPlayer* player);

	// Starts the triggerbot thread.
	void Start();

	// Thread entry point.
	static unsigned long __stdcall ThreadProc(void* param);

private:
	// Aims the view at the selected bone of the crosshair target.
	bool AimAtSelectedBone(int slot);

	// Performs a short left mouse click.
	static void Click();

	const core::ProcessMemory* m_memory = nullptr;
	const core::GameOffsets* m_offsets = nullptr;
	const sdk::EntityList* m_entities = nullptr;
	const sdk::LocalPlayer* m_player = nullptr;
};

} // namespace features