Files
ProjectEleri/Source/ProjectEleri/GameObjects/RainOcclusionActor.h

81 lines
2.9 KiB
C
Raw Normal View History

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "RainOcclusionActor.generated.h"
class ATimeOfDayManager;
class USceneCaptureComponent2D;
/**
* Base class for the rain occlusion capture actor.
* Add the Scene Capture Component 2D in the Blueprint child as before; this class finds it,
* keeps its ShowOnly list up to date incrementally, and re-gathers when the player has moved far enough.
*/
UCLASS()
class PROJECTELERI_API ARainOcclusionActor : public AActor
{
GENERATED_BODY()
public:
ARainOcclusionActor();
/** Gathers occluders and diffs against the current ShowOnly list (adds new, removes missing). */
UFUNCTION(BlueprintCallable, Category = "Rain Occlusion")
void GatherOccluders();
/** Clears the ShowOnly list and the tracked set, then gathers from scratch. */
UFUNCTION(BlueprintCallable, Category = "Rain Occlusion")
void RebuildOccluders();
UFUNCTION(BlueprintPure, Category = "Rain Occlusion")
USceneCaptureComponent2D* GetCaptureComponent() const { return CaptureComponent; }
protected:
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
UFUNCTION(BlueprintImplementableEvent, Category = "Rain Occlusion")
void CaptureRainOcclusionMap();
/** Optional. If empty, the first Scene Capture Component 2D found on this actor is used. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion")
FName CaptureComponentName = NAME_None;
/** Every actor of these classes is added (e.g. LandscapeProxy catches Landscape and streaming proxies). */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion|Gather")
TArray<TSubclassOf<AActor>> IncludedClasses;
/** Every actor carrying any of these tags is added. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion|Gather")
TArray<FName> IncludedTags;
/** Re-gather once the player has moved this far (cm, 2D) from where the last gather ran. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion|Gather", meta = (ClampMin = "0"))
float RegatherDistance = 2000.f;
/** How often (seconds) the distance check runs. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion|Gather", meta = (ClampMin = "0"))
float DistanceCheckInterval = 0.25f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Rain Occlusion|Gather")
bool bIncludeFromChildActors = false;
private:
bool GetPlayerLocation(FVector& OutLocation) const;
UPROPERTY(Transient)
TObjectPtr<USceneCaptureComponent2D> CaptureComponent;
UPROPERTY(Transient)
TObjectPtr<ATimeOfDayManager> TimeOfDayManager;
/** Actors whose components are currently in the capture's ShowOnly list. */
TSet<TWeakObjectPtr<AActor>> TrackedActors;
FVector LastGatherLocation = FVector::ZeroVector;
bool bHasGatherLocation = false;
};