#pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Interfaces/IHttpRequest.h" #include "PlanetDataTypes.h" #include "PlanetDataManager.generated.h" class AComputePointActor; // Fired once all compute points have been spawned into the world DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnComputePointsLoaded, int32, Count); /** * APlanetDataManager * * Place one of these in your level. On BeginPlay it fetches data from the * Planet backend and spawns AComputePointActor instances at the correct * Cesium globe positions. * * Phase A (local): Set bUseLocalMockData = true and point MockDataPath to * Content/Data/mock_compute_points.json. * Phase B (live): Set bUseLocalMockData = false and fill BackendBaseUrl. */ UCLASS(BlueprintType, Blueprintable) class PLANETCLIENT_API APlanetDataManager : public AActor { GENERATED_BODY() public: APlanetDataManager(); // ----------------------------------------------------------------------- // Inspector-editable properties // ----------------------------------------------------------------------- // Base URL of the Planet backend, e.g. "http://localhost:8000" UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Config") FString BackendBaseUrl = TEXT("http://localhost:8000"); // When true, loads mock_compute_points.json from disk instead of the API. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Config") bool bUseLocalMockData = true; // Absolute path to the mock JSON file (Phase A). // Default points to /Content/Data/mock_compute_points.json UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Config", meta=(EditCondition="bUseLocalMockData")) FString MockDataPath; // The Blueprint subclass of AComputePointActor to spawn. // Set this in the Details Panel to your BP_ComputePointActor. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Config") TSubclassOf ComputePointClass; // Height above sea level (metres) at which to place data points. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Planet|Config") double PointAltitudeMeters = 50000.0; // ----------------------------------------------------------------------- // Events // ----------------------------------------------------------------------- UPROPERTY(BlueprintAssignable, Category="Planet|Events") FOnComputePointsLoaded OnComputePointsLoaded; // ----------------------------------------------------------------------- // Public API // ----------------------------------------------------------------------- // Call this to re-fetch and rebuild all points. UFUNCTION(BlueprintCallable, Category="Planet") void FetchAllData(); UFUNCTION(BlueprintCallable, Category="Planet") TArray GetAllComputePoints() const { return SpawnedPoints; } protected: virtual void BeginPlay() override; private: TArray SpawnedPoints; // HTTP handlers void FetchComputePoints(); void OnComputePointsResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bSuccess); // Local mock data loader (Phase A) void LoadMockComputePoints(); // Shared spawn logic void SpawnComputePoints(const TArray& Points); // JSON → FComputePoint array static TArray ParseComputePointsJson(const FString& JsonStr); };