@echo off
setlocal

set "PROJECT_DIR=%~dp0.."
set "PROJECT_FILE=%PROJECT_DIR%\AgrarianGame.uproject"

echo Checking project file for stale VisualStudioTools plugin reference...
findstr /I /C:"VisualStudioTools" "%PROJECT_FILE%" >nul
if "%ERRORLEVEL%"=="0" (
  echo.
  echo ERROR: AgrarianGame.uproject still contains VisualStudioTools.
  echo Run git pull again, or discard local changes to AgrarianGame.uproject.
  echo.
  pause
  exit /b 1
)

echo Cleaning generated Unreal project folders...
if exist "%PROJECT_DIR%\.vs" rmdir /s /q "%PROJECT_DIR%\.vs"
if exist "%PROJECT_DIR%\Binaries" rmdir /s /q "%PROJECT_DIR%\Binaries"
if exist "%PROJECT_DIR%\Intermediate" rmdir /s /q "%PROJECT_DIR%\Intermediate"
if exist "%PROJECT_DIR%\DerivedDataCache" rmdir /s /q "%PROJECT_DIR%\DerivedDataCache"

echo.
echo Clean complete. Regenerate Visual Studio project files if needed, then run:
echo %PROJECT_DIR%\Scripts\BuildEditor-Windows.bat
echo.
pause
exit /b 0
