
native accessor g_pWorldRendererMgr
{
	void ServiceWorldRequests();

	inline uint UpdateObjectsForRendering( StringToken worldGroupId, Vector3 eyePos, float flLODScale, float flMaxVisibleDistance )
	{
		return g_pWorldRendererMgr->UpdateObjectsForRendering( worldGroupId, eyePos, flLODScale, flMaxVisibleDistance );
	}

	inline IWorldReference CreateWorld( string pMapName, ISceneWorld pSceneWorld, bool bAsyncLoad, bool bIgnoreExistingWorlds, bool bLoadVis, bool bPrecacheOnly, StringToken worldGroupId, Transform transform )
	{
		CreateWorldInfo_t info;
		info.m_pWorldName = pMapName;
		info.m_pSceneWorld = pSceneWorld;
		info.m_bAsyncLoad = bAsyncLoad;
		info.m_bLoadVis = bLoadVis;
		info.m_worldGroupId = worldGroupId;
		info.m_bPrecacheOnly = bPrecacheOnly;
		info.m_bIgnoreExistingWorlds = bIgnoreExistingWorlds;
		info.m_mWorldTransform = transform.ToMatrix();

		return g_pWorldRendererMgr->CreateWorld( info );
	}

	bool MountWorldVPK( string pWorldName, string pVpkPath );
	bool UnmountWorldVPK( string pWorldName );
}

native class IWorldReference as NativeEngine.IWorldReference
{
	void Release();
	bool IsWorldLoaded();
	bool IsErrorWorld();
	bool IsMarkedForDeletion();
	bool GetWorldBounds( cref out Vector3 vMin, cref out Vector vMax );
	ISceneWorld GetSceneWorld();

	void PrecacheAllWorldNodes( CastTo[WorldNodeFlags_t] uint flags );

	string GetFolder();

	inline int GetEntityCount( string pEntityLumpName )
	{
		const CUtlVector< const CEntityKeyValues* > *pEnts = g_pWorldRendererMgr->GetEntityList( self, pEntityLumpName );
		return pEnts ? pEnts->Count() : 0;
	}

	inline CEntityKeyValues GetEntityKeyValues( string pEntityLumpName, int index )
	{
		const CUtlVector< const CEntityKeyValues* > *pEnts = g_pWorldRendererMgr->GetEntityList( self, pEntityLumpName );
		return pEnts ? pEnts->Element( index ) : 0;
	}

	inline void SetWorldTransform( Transform transform )
	{
		if ( IWorld *pGeometryWorld = self->GetGeometryWorld() )
		{
			pGeometryWorld->SetWorldTransform( transform.ToMatrix() );
		}
	}
}

native class CEntityKeyValues as NativeEngine.CEntityKeyValues
{
	string GetValueString( StringToken key, string pDefaultValue );
	int GetKeyCount();
	
	inline uint GetKey( int nIdx )
	{
		return self->GetKey( nIdx ).GetHashCode();
	}

	inline string GetValueString( uint key, string pDefaultValue )
	{
		return self->GetValueString( StringTokenFromHashCode( key ), pDefaultValue );
	}
}
