#include "point_checkpoint"

#include "anti_rush"

#include "cubemath/player_respawn_zone_as"

#include "rc/map_save"

#include "opfor/nvision"
#include "opfor/weapon_knife"

void MapInit()
{
	// Enable SC PointCheckPoint Support
	RegisterPointCheckPointEntity();
	// Enable custom trigger zone scripts for Anti-Rush
	RegisterAntiRushEntity();
	RegisterPlayerRespawnZoneASEntity();
	// Register original Opposing Force knife weapon
	RegisterKnife();
	// Enable Nightvision Support
	g_nv.MapInit();
	g_nv.SetNVColor( Vector(225, 0, 0) ); // Red Nightvision
	// Save file cleanup routine for "map_save"
	MapSaveReset();
	// Global CVars
	g_EngineFuncs.CVarSetFloat( "mp_hevsuit_voice", 0 );
	g_EngineFuncs.CVarSetFloat( "mp_no_akimbo_uzis", 1 );
}
// Remove save files when these maps are NOT running
void MapSaveReset()
{
	const array<string> SAVE_MAPS = { "ss1a2","ss1a3","ss4a2","ss4a3" };

	g_CustomEntityFuncs.RegisterCustomEntity( "map_save", "map_save" );
	g_CustomEntityFuncs.RegisterCustomEntity( "map_load", "map_load" );
	
	if( SAVE_MAPS.find( g_Engine.mapname ) < 0 )
	   for( uint i = 0; i < SAVE_MAPS.length(); i++ )
		   g_FileSystem.RemoveFile( "scripts/maps/store/" + SAVE_MAPS[i] + ".dat" );
}
