#include "BuyMenu"

namespace ITEM_CASH_LARGE
{

const string MODEL	= "models/briefcase_money.mdl";
const string SOUND	= "kingpin/cash.wav";

class item_cash_large : ScriptBasePlayerAmmoEntity
{

	void Spawn()
	{
		g_EntityFuncs.SetSize( self.pev, Vector( -20, -15, 0 ), Vector( 20, 15, 15 ) );
		g_EntityFuncs.SetModel( self, MODEL );
		self.pev.body = 1;
		BaseClass.Spawn();
		self.pev.spawnflags = 7424;

		g_EntityFuncs.DispatchKeyValue(self.edict(), "rendermode", 0);
		g_EntityFuncs.DispatchKeyValue(self.edict(), "renderfx", 19);
		g_EntityFuncs.DispatchKeyValue(self.edict(), "rendercolor", "0 100 50");

		//SetThink( ThinkFunction( CashOnTheFloor ) );
		//pev.nextthink = g_Engine.time + 0.1f;
	}

	void CashOnTheFloor()
	{
		SetThink( ThinkFunction( DestroyThink ) );
		pev.nextthink = g_Engine.time + 60.0;
		return;
	}

	void DestroyThink()
	{
		g_EntityFuncs.Remove( self );
	}

	bool AddAmmo( CBaseEntity@ pOther )
	{
		CBasePlayer@ pPlayer = cast<CBasePlayer@>( pOther );

		int iR = 255;
		int iG = 215;
		int iB = 0;
		float fFade = 0.2f;
		float fHold = 0.2f;
		int iA = 40;
		int iFlags = 0;

		if( pPlayer !is null && pPlayer.HasSuit() && (pPlayer.pev.flags & FL_FAKECLIENT) == 0 )
		{
			pPlayer.pev.frags += 1600;

			g_SoundSystem.EmitSound( pPlayer.edict(), CHAN_ITEM, SOUND, 1, ATTN_NORM );
			g_EngineFuncs.ClientPrintf( pPlayer, print_center, "You picked up 16000$\n" );
			g_PlayerFuncs.ScreenFade(pPlayer, Vector(iR, iG, iB), fFade, fHold, iA, iFlags);
			return true;
		}
		return false;
	}
}

string GetName()
{
	return "item_cash_large";
}

void Register()
{
	if( g_CustomEntityFuncs.IsCustomEntity( GetName() ) )
		return;

	g_CustomEntityFuncs.RegisterCustomEntity( "ITEM_CASH_LARGE::item_cash_large", GetName() );
	g_Game.PrecacheOther( GetName() );
}
}