#pragma once

#include <Common/Common.hpp>

class CMaterial2;
class C_CSPlayerPawn;

// 
// Material-based player chams.
//
// Requires a hook on scenesystem.dll "OnDrawObject" (CAnimatableSceneObjectDesc)
// that feeds meshes to OnDrawObject(). The feature builds two flat materials
// (visible + through-walls variant) via the game's own material system and
// swaps them onto player meshes at draw time.
//
// NOTE: the mesh-field offsets, the scene-object owner offset and the KV3ID
// hashes are build-specific. They are isolated as constants below so they can
// be updated against a current dump without touching the surrounding logic.
//

class CChams final
{
public:
	enum EMaterialStyle_t : int32_t
	{
		MATERIAL_STYLE_PLAIN = 0,
		MATERIAL_STYLE_MAX,
	};

public:
	auto CreateMaterials() -> void;

public:
	// Returns true when the mesh data was consumed (material applied + base drawn).
	auto OnDrawObject( void* pAnimatableSceneObjectDesc , void* pDx11 , void* pMeshData , int nDataCount , void* pSceneView , void* pSceneLayer , void* pUnk , void* pUnk2 ) -> bool;

public:
	auto IsReady() const -> bool { return m_pMaterialVisible && m_pMaterialInvisible; }

private:
	auto CreateMaterial( const char* szName , const char* szVmatBuffer ) -> CMaterial2*;

private:
	CMaterial2* m_pMaterialVisible = nullptr;
	CMaterial2* m_pMaterialInvisible = nullptr;
};

auto GetChams() -> CChams*;