#!/bin/bash

# Get the user's home directory
USER_HOME="$HOME"

# Set up Unreal Engine paths
UE_ROOT="/Users/Shared/Epic Games/UE_5.5"
UE_EDITOR="$UE_ROOT/Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor"
UE_UAT="$UE_ROOT/Engine/Build/BatchFiles/RunUAT.command"

# Set up project paths
PROJECT_ROOT="$(pwd)"
PROJECT_FILE="$PROJECT_ROOT/Luckyrobots.uproject"
ARCHIVE_DIR="$PROJECT_ROOT/Builds"

# Run the build command
"$UE_UAT" -ScriptsForProject="$PROJECT_FILE" Turnkey \
  -command=VerifySdk \
  -platform=Mac \
  -UpdateIfNeeded \
  -EditorIO \
  -EditorIOPort=59484 \
  -project="$PROJECT_FILE" \
  BuildCookRun \
  -nop4 \
  -utf8output \
  -cook \
  -project="$PROJECT_FILE" \
  -target=Luckyrobots \
  -unrealexe="$UE_EDITOR" \
  -platform=Mac \
  -installed \
  -stage \
  -archive \
  -package \
  -build \
  -iterativecooking \
  -pak \
  -iostore \
  -compressed \
  -prereqs \
  -archivedirectory="$ARCHIVE_DIR" \
  -CrashReporter \
  -clientconfig=Shipping \
  # -nocompile \
  # -nocompileuat \
  # -nocompileeditor \
  # -skipbuildeditor \

  # enable these if you want to test build without pak and iostore (you're just testing the build)
  # -skipiostore \
  # -skippak \ (disable -pak and -iostore)