#pragma once

// -----------------------------------------------------------------------------
// localplayer.h
// -----------------------------------------------------------------------------
// LocalPlayer: reads and writes the local player's pawn and global view
// state. Wraps every per-player field the features need: crosshair target,
// team, world position, view offset (eye height) and the global view
// angles (written by the aim features).
// -----------------------------------------------------------------------------

#include <cstdint>

#include "../core/memory.h"
#include "../core/offsets.h"
#include "vector.h"

namespace sdk {

// Provides access to the local player pawn and view state.
class LocalPlayer
{
public:
	// Binds the memory reader, offset table and client.dll base address.
	void Initialize(const core::ProcessMemory* memory, const core::GameOffsets* offsets, uintptr_t clientBase);

	// Returns the local player's C_CSPlayerPawn pointer.
	uintptr_t GetLocalPawn() const;

	// Returns the client.dll module base address.
	uintptr_t GetClientBase() const;

	// Returns the crosshair entity id (m_iIDEntIndex), or -1 when empty.
	int GetCrosshairId() const;

	// Returns the local player's team number, or -1 when unavailable.
	int GetTeam() const;

	// Writes the local player's world position into `outPosition`.
	bool GetPosition(Vec3& outPosition) const;

	// Returns the eye height above the origin (m_vecViewOffset.z).
	float GetViewOrigin() const;

	// Writes the view angles (used by every aim feature).
	void SetAngles(const Vec3& angles) const;

	// Writes the current view angles into `outAngles`. Returns false when
	// the view state is unavailable.
	bool GetAngles(Vec3& outAngles) const;

	// Returns the number of shots fired (m_iShotsFired), or 0 when
	// unavailable. Used by the aimbot to detect an ongoing spray.
	int GetShotsFired() const;

private:
	const core::ProcessMemory* m_memory = nullptr;
	const core::GameOffsets* m_offsets = nullptr;
	uintptr_t m_clientBase = 0;
};

} // namespace sdk