#pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "DescentLightPool.generated.h" class UPointLightComponent; /** One request to the light pool: a light for this frame only (section 7.5). */ struct FDescentLightRequest { FVector PositionUU = FVector::ZeroVector; FLinearColor Color = FLinearColor::White; float Intensity = 1.f; float RadiusM = 10.f; /** Higher wins: the score is distance^2 / radius^2 - Priority. */ float Priority = 0.f; }; /** * The light pool (DESIGN_UE.md section 7.5; v2 `commitVL` with 14 lights, here 24): shadowless point lights that * flares, drill glow, bioluminescence, jellies, beacons and the refinery borrow. Systems Submit requests during their * step; the Light-pool late step calls Commit once, which keeps the 24 best (lowest score, and only below 9) and * moves a real light onto each. Requests are cleared by Commit. */ UCLASS() class THEDESCENT_API UDescentLightPool : public UActorComponent { GENERATED_BODY() public: UDescentLightPool(); virtual void BeginPlay() override; void Submit(const FDescentLightRequest& Request) { Requests.Add(Request); } /** Picks the winners for a camera at CameraUU, lights them, hides the other lights, clears the requests. */ void Commit(const FVector& CameraUU); int32 NumLit() const { return NumLitLights; } int32 NumRequestsLastCommit() const { return NumRequestsSeen; } /** The selection rule alone, for tests: indices of the requests that win, best first. */ static void Select(const TArray& Requests, const FVector& CameraUU, int32 MaxLights, double MaxScore, TArray& OutWinners); private: UPROPERTY() TArray> Lights; TArray Requests; int32 NumLitLights = 0; int32 NumRequestsSeen = 0; };